mirror of https://github.com/citusdata/citus.git
make tests run
parent
213eb93e6d
commit
3bb6554976
|
@ -199,6 +199,37 @@ jobs:
|
|||
flags: 'test_11,follower-cluster'
|
||||
- store_artifacts:
|
||||
path: '/tmp/core_dumps'
|
||||
|
||||
test-11_check-columnar:
|
||||
docker:
|
||||
- image: 'citus/exttester:11.9'
|
||||
working_directory: /home/circleci/project
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: 'Install and Test (check-columnar)'
|
||||
command: 'chown -R circleci:circleci /home/circleci && install-and-test-ext check-columnar'
|
||||
no_output_timeout: 2m
|
||||
- codecov/upload:
|
||||
flags: 'test_11,columnar'
|
||||
|
||||
test-11_check-columnar-isolation:
|
||||
docker:
|
||||
- image: 'citus/exttester:11.9'
|
||||
working_directory: /home/circleci/project
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: 'Install and Test (check-columnar-isolation)'
|
||||
command: 'chown -R circleci:circleci /home/circleci && install-and-test-ext check-columnar-isolation'
|
||||
no_output_timeout: 2m
|
||||
- codecov/upload:
|
||||
flags: 'test_11,columnar,isolation'
|
||||
|
||||
test-11_check-failure:
|
||||
docker:
|
||||
- image: 'citus/failtester:11.9'
|
||||
|
@ -337,6 +368,36 @@ jobs:
|
|||
- store_artifacts:
|
||||
path: '/tmp/core_dumps'
|
||||
|
||||
test-12_check-columnar:
|
||||
docker:
|
||||
- image: 'citus/exttester:12.4'
|
||||
working_directory: /home/circleci/project
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: 'Install and Test (check-columnar)'
|
||||
command: 'chown -R circleci:circleci /home/circleci && install-and-test-ext check-columnar'
|
||||
no_output_timeout: 2m
|
||||
- codecov/upload:
|
||||
flags: 'test_12,columnar'
|
||||
|
||||
test-12_check-columnar-isolation:
|
||||
docker:
|
||||
- image: 'citus/exttester:12.4'
|
||||
working_directory: /home/circleci/project
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: 'Install and Test (check-columnar-isolation)'
|
||||
command: 'chown -R circleci:circleci /home/circleci && install-and-test-ext check-columnar-isolation'
|
||||
no_output_timeout: 2m
|
||||
- codecov/upload:
|
||||
flags: 'test_12,columnar,isolation'
|
||||
|
||||
test-12_check-failure:
|
||||
docker:
|
||||
- image: 'citus/failtester:12.4'
|
||||
|
@ -473,6 +534,36 @@ jobs:
|
|||
- store_artifacts:
|
||||
path: '/tmp/core_dumps'
|
||||
|
||||
test-13_check-columnar:
|
||||
docker:
|
||||
- image: 'citus/exttester:13.0'
|
||||
working_directory: /home/circleci/project
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: 'Install and Test (check-columnar)'
|
||||
command: 'chown -R circleci:circleci /home/circleci && install-and-test-ext check-columnar'
|
||||
no_output_timeout: 2m
|
||||
- codecov/upload:
|
||||
flags: 'test_13,columnar'
|
||||
|
||||
test-13_check-columnar-isolation:
|
||||
docker:
|
||||
- image: 'citus/exttester:13.0'
|
||||
working_directory: /home/circleci/project
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- run:
|
||||
name: 'Install and Test (check-columnar-isolation)'
|
||||
command: 'chown -R circleci:circleci /home/circleci && install-and-test-ext check-columnar-isolation'
|
||||
no_output_timeout: 2m
|
||||
- codecov/upload:
|
||||
flags: 'test_13,columnar,isolation'
|
||||
|
||||
test-13_check-failure:
|
||||
docker:
|
||||
- image: 'citus/failtester:13.0'
|
||||
|
@ -556,6 +647,10 @@ workflows:
|
|||
requires: [build-11]
|
||||
- test-11_check-follower-cluster:
|
||||
requires: [build-11]
|
||||
- test-11_check-columnar:
|
||||
requires: [build-11]
|
||||
- test-11_check-columnar-isolation:
|
||||
requires: [build-11]
|
||||
- test-11_check-failure:
|
||||
requires: [build-11]
|
||||
|
||||
|
@ -571,6 +666,10 @@ workflows:
|
|||
requires: [build-12]
|
||||
- test-12_check-follower-cluster:
|
||||
requires: [build-12]
|
||||
- test-12_check-columnar:
|
||||
requires: [build-12]
|
||||
- test-12_check-columnar-isolation:
|
||||
requires: [build-12]
|
||||
- test-12_check-failure:
|
||||
requires: [build-12]
|
||||
|
||||
|
@ -586,6 +685,10 @@ workflows:
|
|||
requires: [build-13]
|
||||
- test-13_check-follower-cluster:
|
||||
requires: [build-13]
|
||||
- test-13_check-columnar:
|
||||
requires: [build-13]
|
||||
- test-13_check-columnar-isolation:
|
||||
requires: [build-13]
|
||||
- test-13_check-failure:
|
||||
requires: [build-13]
|
||||
|
||||
|
|
|
@ -161,6 +161,25 @@ check-follower-cluster: all
|
|||
$(pg_regress_multi_check) --load-extension=citus --follower-cluster \
|
||||
-- $(MULTI_REGRESS_OPTS) --schedule=$(citus_abs_srcdir)/multi_follower_schedule $(EXTRA_TESTS)
|
||||
|
||||
COLUMNAR_SCHEDULES =
|
||||
COLUMNAR_ISOLATION_SCHEDULES =
|
||||
ifeq ($(USE_FDW),yes)
|
||||
COLUMNAR_SCHEDULES += columnar_fdw_schedule
|
||||
COLUMNAR_ISOLATION_SCHEDULES += columnar_fdw_isolation_schedule
|
||||
endif
|
||||
ifeq ($(USE_TABLEAM),yes)
|
||||
COLUMNAR_SCHEDULES += columnar_am_schedule
|
||||
COLUMNAR_ISOLATION_SCHEDULES += columnar_am_isolation_schedule
|
||||
endif
|
||||
|
||||
check-columnar:
|
||||
$(pg_regress_multi_check) --load-extension=citus \
|
||||
-- $(MULTI_REGRESS_OPTS) $(addprefix --schedule=$(citus_abs_srcdir)/,$(COLUMNAR_SCHEDULES)) $(EXTRA_TESTS)
|
||||
|
||||
check-columnar-isolation: all $(isolation_test_files)
|
||||
$(pg_regress_multi_check) --load-extension=citus --isolationtester \
|
||||
-- $(MULTI_REGRESS_OPTS) --inputdir=$(citus_abs_srcdir)/build $(addprefix --schedule=$(citus_abs_srcdir)/,$(COLUMNAR_ISOLATION_SCHEDULES)) $(EXTRA_TESTS)
|
||||
|
||||
check-failure: all
|
||||
$(pg_regress_multi_check) --load-extension=citus --mitmproxy \
|
||||
-- $(MULTI_REGRESS_OPTS) --schedule=$(citus_abs_srcdir)/failure_schedule $(EXTRA_TESTS)
|
||||
|
|
|
@ -181,3 +181,6 @@ s/wrong data type: [0-9]+, expected [0-9]+/wrong data type: XXXX, expected XXXX/
|
|||
|
||||
# Errors with relation OID does not exist
|
||||
s/relation with OID [0-9]+ does not exist/relation with OID XXXX does not exist/g
|
||||
|
||||
# ignore event triggers, mainly due to the event trigger for columnar
|
||||
/^DEBUG: EventTriggerInvoke [0-9]+$/d
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
test: am_write_concurrency
|
||||
test: am_vacuum_vs_insert
|
|
@ -0,0 +1,18 @@
|
|||
test: am_create
|
||||
test: am_load
|
||||
test: am_query
|
||||
test: am_analyze
|
||||
test: am_data_types
|
||||
test: am_functions
|
||||
test: am_drop
|
||||
test: am_insert
|
||||
test: am_copyto
|
||||
test: am_alter
|
||||
test: am_rollback
|
||||
test: am_truncate
|
||||
test: am_vacuum
|
||||
test: am_clean
|
||||
test: am_block_filtering
|
||||
test: am_join
|
||||
test: am_trigger
|
||||
test: am_tableoptions
|
|
@ -0,0 +1 @@
|
|||
# just an empty file now, please remove when we have a test
|
|
@ -0,0 +1,14 @@
|
|||
test: fdw_create
|
||||
test: fdw_load
|
||||
test: fdw_query
|
||||
test: fdw_analyze
|
||||
test: fdw_data_types
|
||||
test: fdw_functions
|
||||
test: fdw_block_filtering
|
||||
test: fdw_drop
|
||||
test: fdw_insert
|
||||
test: fdw_copyto
|
||||
test: fdw_alter
|
||||
test: fdw_rollback
|
||||
test: fdw_truncate
|
||||
test: fdw_clean
|
|
@ -21,3 +21,13 @@
|
|||
/multi_behavioral_analytics_create_table.out
|
||||
/multi_insert_select_behavioral_analytics_create_table.out
|
||||
/hyperscale_tutorial.out
|
||||
/am_block_filtering.out
|
||||
/am_copyto.out
|
||||
/am_create.out
|
||||
/am_data_types.out
|
||||
/am_load.out
|
||||
/fdw_block_filtering.out
|
||||
/fdw_copyto.out
|
||||
/fdw_create.out
|
||||
/fdw_data_types.out
|
||||
/fdw_load.out
|
||||
|
|
|
@ -14,8 +14,8 @@ ALTER TABLE test_alter_table DROP COLUMN a;
|
|||
ANALYZE test_alter_table;
|
||||
-- verify select queries run as expected
|
||||
SELECT * FROM test_alter_table;
|
||||
b | c
|
||||
---+---
|
||||
b | c
|
||||
---------------------------------------------------------------------
|
||||
2 | 3
|
||||
5 | 6
|
||||
8 | 9
|
||||
|
@ -23,11 +23,9 @@ SELECT * FROM test_alter_table;
|
|||
|
||||
SELECT a FROM test_alter_table;
|
||||
ERROR: column "a" does not exist
|
||||
LINE 1: SELECT a FROM test_alter_table;
|
||||
^
|
||||
SELECT b FROM test_alter_table;
|
||||
b
|
||||
---
|
||||
b
|
||||
---------------------------------------------------------------------
|
||||
2
|
||||
5
|
||||
8
|
||||
|
@ -36,36 +34,34 @@ SELECT b FROM test_alter_table;
|
|||
-- verify insert runs as expected
|
||||
INSERT INTO test_alter_table (SELECT 3, 5, 8);
|
||||
ERROR: INSERT has more expressions than target columns
|
||||
LINE 1: INSERT INTO test_alter_table (SELECT 3, 5, 8);
|
||||
^
|
||||
INSERT INTO test_alter_table (SELECT 5, 8);
|
||||
-- add a column with no defaults
|
||||
ALTER TABLE test_alter_table ADD COLUMN d int;
|
||||
SELECT * FROM test_alter_table;
|
||||
b | c | d
|
||||
---+---+---
|
||||
2 | 3 |
|
||||
5 | 6 |
|
||||
8 | 9 |
|
||||
5 | 8 |
|
||||
b | c | d
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 |
|
||||
5 | 6 |
|
||||
8 | 9 |
|
||||
5 | 8 |
|
||||
(4 rows)
|
||||
|
||||
INSERT INTO test_alter_table (SELECT 3, 5, 8);
|
||||
SELECT * FROM test_alter_table;
|
||||
b | c | d
|
||||
---+---+---
|
||||
2 | 3 |
|
||||
5 | 6 |
|
||||
8 | 9 |
|
||||
5 | 8 |
|
||||
b | c | d
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 |
|
||||
5 | 6 |
|
||||
8 | 9 |
|
||||
5 | 8 |
|
||||
3 | 5 | 8
|
||||
(5 rows)
|
||||
|
||||
-- add a fixed-length column with default value
|
||||
ALTER TABLE test_alter_table ADD COLUMN e int default 3;
|
||||
SELECT * from test_alter_table;
|
||||
b | c | d | e
|
||||
---+---+---+---
|
||||
b | c | d | e
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 | | 3
|
||||
5 | 6 | | 3
|
||||
8 | 9 | | 3
|
||||
|
@ -75,8 +71,8 @@ SELECT * from test_alter_table;
|
|||
|
||||
INSERT INTO test_alter_table (SELECT 1, 2, 4, 8);
|
||||
SELECT * from test_alter_table;
|
||||
b | c | d | e
|
||||
---+---+---+---
|
||||
b | c | d | e
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 | | 3
|
||||
5 | 6 | | 3
|
||||
8 | 9 | | 3
|
||||
|
@ -88,8 +84,8 @@ SELECT * from test_alter_table;
|
|||
-- add a variable-length column with default value
|
||||
ALTER TABLE test_alter_table ADD COLUMN f text DEFAULT 'TEXT ME';
|
||||
SELECT * from test_alter_table;
|
||||
b | c | d | e | f
|
||||
---+---+---+---+---------
|
||||
b | c | d | e | f
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 | | 3 | TEXT ME
|
||||
5 | 6 | | 3 | TEXT ME
|
||||
8 | 9 | | 3 | TEXT ME
|
||||
|
@ -100,8 +96,8 @@ SELECT * from test_alter_table;
|
|||
|
||||
INSERT INTO test_alter_table (SELECT 1, 2, 4, 8, 'ABCDEF');
|
||||
SELECT * from test_alter_table;
|
||||
b | c | d | e | f
|
||||
---+---+---+---+---------
|
||||
b | c | d | e | f
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 | | 3 | TEXT ME
|
||||
5 | 6 | | 3 | TEXT ME
|
||||
8 | 9 | | 3 | TEXT ME
|
||||
|
@ -116,8 +112,8 @@ ALTER TABLE test_alter_table DROP COLUMN c;
|
|||
ALTER TABLE test_alter_table DROP COLUMN e;
|
||||
ANALYZE test_alter_table;
|
||||
SELECT * from test_alter_table;
|
||||
b | d | f
|
||||
---+---+---------
|
||||
b | d | f
|
||||
---------------------------------------------------------------------
|
||||
2 | | TEXT ME
|
||||
5 | | TEXT ME
|
||||
8 | | TEXT ME
|
||||
|
@ -128,14 +124,14 @@ SELECT * from test_alter_table;
|
|||
(7 rows)
|
||||
|
||||
SELECT count(*) from test_alter_table;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
7
|
||||
(1 row)
|
||||
|
||||
SELECT count(t.*) from test_alter_table t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
7
|
||||
(1 row)
|
||||
|
||||
|
@ -152,15 +148,15 @@ HINT: Expression is either mutable or does not evaluate to constant value
|
|||
ALTER TABLE test_alter_table ALTER COLUMN h DROP DEFAULT;
|
||||
ANALYZE test_alter_table;
|
||||
SELECT * FROM test_alter_table;
|
||||
b | d | f | g | h
|
||||
---+---+---------+---+---
|
||||
2 | | TEXT ME | |
|
||||
5 | | TEXT ME | |
|
||||
8 | | TEXT ME | |
|
||||
5 | | TEXT ME | |
|
||||
3 | 8 | TEXT ME | |
|
||||
1 | 4 | TEXT ME | |
|
||||
1 | 4 | ABCDEF | |
|
||||
b | d | f | g | h
|
||||
---------------------------------------------------------------------
|
||||
2 | | TEXT ME | |
|
||||
5 | | TEXT ME | |
|
||||
8 | | TEXT ME | |
|
||||
5 | | TEXT ME | |
|
||||
3 | 8 | TEXT ME | |
|
||||
1 | 4 | TEXT ME | |
|
||||
1 | 4 | ABCDEF | |
|
||||
(7 rows)
|
||||
|
||||
-- unsupported type change
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
-- ANALYZE uncompressed table
|
||||
ANALYZE contestant;
|
||||
SELECT count(*) FROM pg_stats WHERE tablename='contestant';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
6
|
||||
(1 row)
|
||||
|
||||
-- ANALYZE compressed table
|
||||
ANALYZE contestant_compressed;
|
||||
SELECT count(*) FROM pg_stats WHERE tablename='contestant_compressed';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
6
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ DROP TABLE contestant;
|
|||
DROP TABLE contestant_compressed;
|
||||
-- make sure DROP deletes metadata
|
||||
SELECT :cstore_data_files_before_drop - count(*) FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
|
@ -30,21 +30,24 @@ SELECT count(*) AS cstore_data_files_before_drop FROM cstore.cstore_data_files \
|
|||
DROP SCHEMA test_schema CASCADE;
|
||||
NOTICE: drop cascades to table test_schema.test_table
|
||||
SELECT :cstore_data_files_before_drop - count(*) FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT current_database() datname \gset
|
||||
CREATE DATABASE db_to_drop;
|
||||
NOTICE: Citus partially supports CREATE DATABASE for distributed databases
|
||||
DETAIL: Citus does not propagate CREATE DATABASE command to workers
|
||||
HINT: You can manually create a database and its extensions on workers.
|
||||
\c db_to_drop
|
||||
CREATE EXTENSION cstore_fdw;
|
||||
CREATE EXTENSION citus;
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database() \gset
|
||||
CREATE TABLE test_table(data int) USING cstore_tableam;
|
||||
DROP EXTENSION cstore_fdw CASCADE;
|
||||
DROP EXTENSION citus CASCADE;
|
||||
NOTICE: drop cascades to table test_table
|
||||
-- test database drop
|
||||
CREATE EXTENSION cstore_fdw;
|
||||
CREATE EXTENSION citus;
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database() \gset
|
||||
CREATE TABLE test_table(data int) USING cstore_tableam;
|
||||
\c :datname
|
||||
|
|
|
@ -6,8 +6,8 @@ CREATE TABLE table_with_data (a int) USING cstore_tableam;
|
|||
CREATE TABLE non_cstore_table (a int);
|
||||
COPY table_with_data FROM STDIN;
|
||||
SELECT pg_relation_size('empty_table') < pg_relation_size('table_with_data');
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -4,44 +4,44 @@
|
|||
CREATE TABLE test_insert_command (a int) USING cstore_tableam;
|
||||
-- test single row inserts fail
|
||||
select count(*) from test_insert_command;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
insert into test_insert_command values(1);
|
||||
select count(*) from test_insert_command;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
insert into test_insert_command default values;
|
||||
select count(*) from test_insert_command;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
-- test inserting from another table succeed
|
||||
CREATE TABLE test_insert_command_data (a int);
|
||||
select count(*) from test_insert_command_data;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
insert into test_insert_command_data values(1);
|
||||
select count(*) from test_insert_command_data;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
insert into test_insert_command select * from test_insert_command_data;
|
||||
select count(*) from test_insert_command;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
|
@ -68,8 +68,8 @@ DROP TABLE test_long_text;
|
|||
SELECT a.int_val
|
||||
FROM test_long_text_hash a, test_cstore_long_text c
|
||||
WHERE a.int_val = c.int_val AND a.hash = md5(c.text_val);
|
||||
int_val
|
||||
---------
|
||||
int_val
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
2
|
||||
3
|
||||
|
|
|
@ -12,8 +12,8 @@ SELECT count(*)
|
|||
FROM users
|
||||
JOIN things ON (users.id = things.user_id)
|
||||
WHERE things.id > 290;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
10
|
||||
(1 row)
|
||||
|
||||
|
@ -23,8 +23,8 @@ SELECT count(*)
|
|||
FROM users
|
||||
JOIN things ON (users.id = things.user_id)
|
||||
WHERE things.id > 299990;
|
||||
QUERY PLAN
|
||||
--------------------------------------------------
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------
|
||||
Aggregate
|
||||
-> Nested Loop
|
||||
Join Filter: (users.id = things.user_id)
|
||||
|
|
|
@ -5,21 +5,21 @@
|
|||
SET datestyle = "ISO, YMD";
|
||||
-- Query uncompressed data
|
||||
SELECT count(*) FROM contestant;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
8
|
||||
(1 row)
|
||||
|
||||
SELECT avg(rating), stddev_samp(rating) FROM contestant;
|
||||
avg | stddev_samp
|
||||
-----------------------+------------------
|
||||
avg | stddev_samp
|
||||
---------------------------------------------------------------------
|
||||
2344.3750000000000000 | 433.746119785032
|
||||
(1 row)
|
||||
|
||||
SELECT country, avg(rating) FROM contestant WHERE rating > 2200
|
||||
GROUP BY country ORDER BY country;
|
||||
country | avg
|
||||
---------+-----------------------
|
||||
country | avg
|
||||
---------------------------------------------------------------------
|
||||
XA | 2203.0000000000000000
|
||||
XB | 2610.5000000000000000
|
||||
XC | 2236.0000000000000000
|
||||
|
@ -27,8 +27,8 @@ SELECT country, avg(rating) FROM contestant WHERE rating > 2200
|
|||
(4 rows)
|
||||
|
||||
SELECT * FROM contestant ORDER BY handle;
|
||||
handle | birthdate | rating | percentile | country | achievements
|
||||
--------+------------+--------+------------+---------+--------------
|
||||
handle | birthdate | rating | percentile | country | achievements
|
||||
---------------------------------------------------------------------
|
||||
a | 1990-01-10 | 2090 | 97.1 | XA | {a}
|
||||
b | 1990-11-01 | 2203 | 98.1 | XA | {a,b}
|
||||
c | 1988-11-01 | 2907 | 99.4 | XB | {w,y}
|
||||
|
@ -41,21 +41,21 @@ SELECT * FROM contestant ORDER BY handle;
|
|||
|
||||
-- Query compressed data
|
||||
SELECT count(*) FROM contestant_compressed;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
8
|
||||
(1 row)
|
||||
|
||||
SELECT avg(rating), stddev_samp(rating) FROM contestant_compressed;
|
||||
avg | stddev_samp
|
||||
-----------------------+------------------
|
||||
avg | stddev_samp
|
||||
---------------------------------------------------------------------
|
||||
2344.3750000000000000 | 433.746119785032
|
||||
(1 row)
|
||||
|
||||
SELECT country, avg(rating) FROM contestant_compressed WHERE rating > 2200
|
||||
GROUP BY country ORDER BY country;
|
||||
country | avg
|
||||
---------+-----------------------
|
||||
country | avg
|
||||
---------------------------------------------------------------------
|
||||
XA | 2203.0000000000000000
|
||||
XB | 2610.5000000000000000
|
||||
XC | 2236.0000000000000000
|
||||
|
@ -63,8 +63,8 @@ SELECT country, avg(rating) FROM contestant_compressed WHERE rating > 2200
|
|||
(4 rows)
|
||||
|
||||
SELECT * FROM contestant_compressed ORDER BY handle;
|
||||
handle | birthdate | rating | percentile | country | achievements
|
||||
--------+------------+--------+------------+---------+--------------
|
||||
handle | birthdate | rating | percentile | country | achievements
|
||||
---------------------------------------------------------------------
|
||||
a | 1990-01-10 | 2090 | 97.1 | XA | {a}
|
||||
b | 1990-11-01 | 2203 | 98.1 | XA | {a,b}
|
||||
c | 1988-11-01 | 2907 | 99.4 | XB | {w,y}
|
||||
|
@ -77,8 +77,8 @@ SELECT * FROM contestant_compressed ORDER BY handle;
|
|||
|
||||
-- Verify that we handle whole-row references correctly
|
||||
SELECT to_json(v) FROM contestant v ORDER BY rating LIMIT 1;
|
||||
to_json
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
to_json
|
||||
---------------------------------------------------------------------
|
||||
{"handle":"g","birthdate":"1991-12-13","rating":1803,"percentile":85.1,"country":"XD ","achievements":["a","c"]}
|
||||
(1 row)
|
||||
|
||||
|
@ -88,8 +88,8 @@ CREATE TABLE union_second (a int, b int) USING cstore_tableam;
|
|||
INSERT INTO union_first SELECT a, a FROM generate_series(1, 5) a;
|
||||
INSERT INTO union_second SELECT a, a FROM generate_series(11, 15) a;
|
||||
(SELECT a*1, b FROM union_first) union all (SELECT a*1, b FROM union_second);
|
||||
?column? | b
|
||||
----------+----
|
||||
?column? | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
2 | 2
|
||||
3 | 3
|
||||
|
|
|
@ -6,30 +6,30 @@ BEGIN;
|
|||
INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
||||
ROLLBACK;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
-- check stripe metadata also have been rolled-back
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b
|
||||
WHERE a.relfilenode = b.relfilenode AND b.relname = 't';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
10
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b
|
||||
WHERE a.relfilenode = b.relfilenode AND b.relname = 't';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
|
@ -40,37 +40,37 @@ INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
|||
SAVEPOINT s1;
|
||||
INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
30
|
||||
(1 row)
|
||||
|
||||
ROLLBACK TO SAVEPOINT s1;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
20
|
||||
(1 row)
|
||||
|
||||
ROLLBACK TO SAVEPOINT s0;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
10
|
||||
(1 row)
|
||||
|
||||
INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
||||
COMMIT;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
20
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b
|
||||
WHERE a.relfilenode = b.relfilenode AND b.relname = 't';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -5,53 +5,53 @@ INSERT INTO table_options SELECT generate_series(1,100);
|
|||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 10000 | 150000 | none
|
||||
(1 row)
|
||||
|
||||
-- test changing the compression
|
||||
SELECT alter_cstore_table_set('table_options', compression => 'pglz');
|
||||
alter_cstore_table_set
|
||||
------------------------
|
||||
|
||||
alter_cstore_table_set
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 10000 | 150000 | pglz
|
||||
(1 row)
|
||||
|
||||
-- test changing the block_row_count
|
||||
SELECT alter_cstore_table_set('table_options', block_row_count => 10);
|
||||
alter_cstore_table_set
|
||||
------------------------
|
||||
|
||||
alter_cstore_table_set
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 10 | 150000 | pglz
|
||||
(1 row)
|
||||
|
||||
-- test changing the block_row_count
|
||||
SELECT alter_cstore_table_set('table_options', stripe_row_count => 100);
|
||||
alter_cstore_table_set
|
||||
------------------------
|
||||
|
||||
alter_cstore_table_set
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 10 | 100 | pglz
|
||||
(1 row)
|
||||
|
||||
|
@ -60,23 +60,23 @@ VACUUM FULL table_options;
|
|||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 10 | 100 | pglz
|
||||
(1 row)
|
||||
|
||||
-- set all settings at the same time
|
||||
SELECT alter_cstore_table_set('table_options', stripe_row_count => 1000, block_row_count => 100, compression => 'none');
|
||||
alter_cstore_table_set
|
||||
------------------------
|
||||
|
||||
alter_cstore_table_set
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 100 | 1000 | none
|
||||
(1 row)
|
||||
|
||||
|
@ -88,50 +88,50 @@ SET cstore.compression TO 'pglz';
|
|||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 100 | 1000 | none
|
||||
(1 row)
|
||||
|
||||
SELECT alter_cstore_table_reset('table_options', block_row_count => true);
|
||||
alter_cstore_table_reset
|
||||
--------------------------
|
||||
|
||||
alter_cstore_table_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 1000 | 1000 | none
|
||||
(1 row)
|
||||
|
||||
SELECT alter_cstore_table_reset('table_options', stripe_row_count => true);
|
||||
alter_cstore_table_reset
|
||||
--------------------------
|
||||
|
||||
alter_cstore_table_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 1000 | 10000 | none
|
||||
(1 row)
|
||||
|
||||
SELECT alter_cstore_table_reset('table_options', compression => true);
|
||||
alter_cstore_table_reset
|
||||
--------------------------
|
||||
|
||||
alter_cstore_table_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 1000 | 10000 | pglz
|
||||
(1 row)
|
||||
|
||||
|
@ -142,8 +142,8 @@ SET cstore.compression TO 'none';
|
|||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 1000 | 10000 | pglz
|
||||
(1 row)
|
||||
|
||||
|
@ -152,16 +152,16 @@ SELECT alter_cstore_table_reset(
|
|||
block_row_count => true,
|
||||
stripe_row_count => true,
|
||||
compression => true);
|
||||
alter_cstore_table_reset
|
||||
--------------------------
|
||||
|
||||
alter_cstore_table_reset
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- show table_options settings
|
||||
SELECT * FROM cstore.cstore_options
|
||||
WHERE regclass = 'table_options'::regclass;
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------+-----------------+------------------+-------------
|
||||
regclass | block_row_count | stripe_row_count | compression
|
||||
---------------------------------------------------------------------
|
||||
table_options | 10000 | 100000 | none
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -50,16 +50,28 @@ ERROR: AFTER ROW triggers are not supported for columnstore access method
|
|||
HINT: Consider an AFTER STATEMENT trigger instead.
|
||||
insert into test_tr values(1);
|
||||
NOTICE: BEFORE STATEMENT INSERT
|
||||
CONTEXT: PL/pgSQL function trs_before() line 3 at RAISE
|
||||
NOTICE: BEFORE ROW INSERT: (1)
|
||||
CONTEXT: PL/pgSQL function trr_before() line 3 at RAISE
|
||||
NOTICE: AFTER STATEMENT INSERT
|
||||
CONTEXT: PL/pgSQL function trs_after() line 5 at RAISE
|
||||
NOTICE: (1)
|
||||
CONTEXT: PL/pgSQL function trs_after() line 14 at RAISE
|
||||
insert into test_tr values(2),(3),(4);
|
||||
NOTICE: BEFORE STATEMENT INSERT
|
||||
CONTEXT: PL/pgSQL function trs_before() line 3 at RAISE
|
||||
NOTICE: BEFORE ROW INSERT: (2)
|
||||
CONTEXT: PL/pgSQL function trr_before() line 3 at RAISE
|
||||
NOTICE: BEFORE ROW INSERT: (3)
|
||||
CONTEXT: PL/pgSQL function trr_before() line 3 at RAISE
|
||||
NOTICE: BEFORE ROW INSERT: (4)
|
||||
CONTEXT: PL/pgSQL function trr_before() line 3 at RAISE
|
||||
NOTICE: AFTER STATEMENT INSERT
|
||||
CONTEXT: PL/pgSQL function trs_after() line 5 at RAISE
|
||||
NOTICE: (2)
|
||||
CONTEXT: PL/pgSQL function trs_after() line 14 at RAISE
|
||||
NOTICE: (3)
|
||||
CONTEXT: PL/pgSQL function trs_after() line 14 at RAISE
|
||||
NOTICE: (4)
|
||||
CONTEXT: PL/pgSQL function trs_after() line 14 at RAISE
|
||||
drop table test_tr;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
-- print whether we're using version > 10 to make version-specific tests clear
|
||||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int > 10 AS version_above_ten;
|
||||
version_above_ten
|
||||
-------------------
|
||||
version_above_ten
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
|
@ -23,8 +23,8 @@ INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1,
|
|||
set cstore.compression to default;
|
||||
-- query rows
|
||||
SELECT * FROM cstore_truncate_test;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
2 | 2
|
||||
3 | 3
|
||||
|
@ -39,32 +39,32 @@ SELECT * FROM cstore_truncate_test;
|
|||
|
||||
TRUNCATE TABLE cstore_truncate_test;
|
||||
SELECT * FROM cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT COUNT(*) from cstore_truncate_test;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore_truncate_test_compressed;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
20
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE cstore_truncate_test_compressed;
|
||||
SELECT count(*) FROM cstore_truncate_test_compressed;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT pg_relation_size('cstore_truncate_test_compressed');
|
||||
pg_relation_size
|
||||
------------------
|
||||
pg_relation_size
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -72,8 +72,8 @@ INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
|||
INSERT INTO cstore_truncate_test_regular select a, a from generate_series(10, 20) a;
|
||||
INSERT INTO cstore_truncate_test_second select a, a from generate_series(20, 30) a;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
2 | 2
|
||||
3 | 3
|
||||
|
@ -87,8 +87,8 @@ SELECT * from cstore_truncate_test;
|
|||
(10 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_second;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
20 | 20
|
||||
21 | 21
|
||||
22 | 22
|
||||
|
@ -103,8 +103,8 @@ SELECT * from cstore_truncate_test_second;
|
|||
(11 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_regular;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
10 | 10
|
||||
11 | 11
|
||||
12 | 12
|
||||
|
@ -125,31 +125,31 @@ TRUNCATE TABLE cstore_truncate_test,
|
|||
cstore_truncate_test_second,
|
||||
cstore_truncate_test;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_second;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_regular;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- test if truncate on empty table works
|
||||
TRUNCATE TABLE cstore_truncate_test;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- make sure TRUNATE deletes metadata for old relfilenode
|
||||
SELECT :cstore_data_files_before_truncate - count(*) FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -162,14 +162,14 @@ INSERT INTO cstore_same_transaction_truncate SELECT * FROM generate_series(20, 2
|
|||
COMMIT;
|
||||
-- should output "1" for the newly created relation
|
||||
SELECT count(*) - :cstore_data_files_before_truncate FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM cstore_same_transaction_truncate;
|
||||
a
|
||||
----
|
||||
a
|
||||
---------------------------------------------------------------------
|
||||
20
|
||||
21
|
||||
22
|
||||
|
@ -185,16 +185,16 @@ BEGIN
|
|||
END;$$
|
||||
LANGUAGE plpgsql;
|
||||
SELECT cstore_truncate_test_regular_func();
|
||||
cstore_truncate_test_regular_func
|
||||
-----------------------------------
|
||||
|
||||
cstore_truncate_test_regular_func
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- the cached plans are used stating from the second call
|
||||
SELECT cstore_truncate_test_regular_func();
|
||||
cstore_truncate_test_regular_func
|
||||
-----------------------------------
|
||||
|
||||
cstore_truncate_test_regular_func
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP FUNCTION cstore_truncate_test_regular_func();
|
||||
|
@ -209,15 +209,15 @@ set cstore.compression = 'pglz';
|
|||
INSERT INTO truncate_schema.truncate_tbl SELECT generate_series(1, 100);
|
||||
set cstore.compression to default;
|
||||
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -226,6 +226,8 @@ INSERT INTO truncate_schema.truncate_tbl SELECT generate_series(1, 100);
|
|||
set cstore.compression to default;
|
||||
-- create a user that can not truncate
|
||||
CREATE USER truncate_user;
|
||||
NOTICE: not propagating CREATE ROLE/USER commands to worker nodes
|
||||
HINT: Connect to worker nodes directly to manually create all necessary users and roles.
|
||||
GRANT USAGE ON SCHEMA truncate_schema TO truncate_user;
|
||||
GRANT SELECT ON TABLE truncate_schema.truncate_tbl TO truncate_user;
|
||||
REVOKE TRUNCATE ON TABLE truncate_schema.truncate_tbl FROM truncate_user;
|
||||
|
@ -233,34 +235,34 @@ SELECT current_user \gset
|
|||
\c - truncate_user
|
||||
-- verify truncate command fails and check number of rows
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
ERROR: permission denied for table truncate_tbl
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
-- switch to super user, grant truncate to truncate_user
|
||||
-- switch to super user, grant truncate to truncate_user
|
||||
\c - :current_user
|
||||
GRANT TRUNCATE ON TABLE truncate_schema.truncate_tbl TO truncate_user;
|
||||
-- verify truncate_user can truncate now
|
||||
\c - truncate_user
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
-- print whether we're using version > 10 to make version-specific tests clear
|
||||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int > 10 AS version_above_ten;
|
||||
version_above_ten
|
||||
-------------------
|
||||
version_above_ten
|
||||
---------------------------------------------------------------------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
|
@ -15,8 +15,8 @@ SELECT count(*) FROM (
|
|||
SELECT pg_ls_dir('cstore_fdw/' || databaseoid ) FROM (
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database()
|
||||
) AS q1) AS q2;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -30,8 +30,8 @@ INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1,
|
|||
INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1, 10) a;
|
||||
-- query rows
|
||||
SELECT * FROM cstore_truncate_test;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
2 | 2
|
||||
3 | 3
|
||||
|
@ -46,42 +46,42 @@ SELECT * FROM cstore_truncate_test;
|
|||
|
||||
TRUNCATE TABLE cstore_truncate_test;
|
||||
SELECT * FROM cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT COUNT(*) from cstore_truncate_test;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore_truncate_test_compressed;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
20
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE cstore_truncate_test_compressed;
|
||||
SELECT count(*) FROM cstore_truncate_test_compressed;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT cstore_table_size('cstore_truncate_test_compressed');
|
||||
cstore_table_size
|
||||
-------------------
|
||||
cstore_table_size
|
||||
---------------------------------------------------------------------
|
||||
26
|
||||
(1 row)
|
||||
|
||||
-- make sure data files still present
|
||||
-- make sure data files still present
|
||||
SELECT count(*) FROM (
|
||||
SELECT pg_ls_dir('cstore_fdw/' || databaseoid ) FROM (
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database()
|
||||
) AS q1) AS q2;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
6
|
||||
(1 row)
|
||||
|
||||
|
@ -89,8 +89,8 @@ INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
|||
INSERT INTO cstore_truncate_test_regular select a, a from generate_series(10, 20) a;
|
||||
INSERT INTO cstore_truncate_test_second select a, a from generate_series(20, 30) a;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
2 | 2
|
||||
3 | 3
|
||||
|
@ -104,8 +104,8 @@ SELECT * from cstore_truncate_test;
|
|||
(10 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_second;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
20 | 20
|
||||
21 | 21
|
||||
22 | 22
|
||||
|
@ -120,8 +120,8 @@ SELECT * from cstore_truncate_test_second;
|
|||
(11 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_regular;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
10 | 10
|
||||
11 | 11
|
||||
12 | 12
|
||||
|
@ -142,25 +142,25 @@ TRUNCATE TABLE cstore_truncate_test,
|
|||
cstore_truncate_test_second,
|
||||
cstore_truncate_test;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_second;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_regular;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- test if truncate on empty table works
|
||||
TRUNCATE TABLE cstore_truncate_test;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- test if a cached truncate from a pl/pgsql function works
|
||||
|
@ -171,16 +171,16 @@ BEGIN
|
|||
END;$$
|
||||
LANGUAGE plpgsql;
|
||||
SELECT cstore_truncate_test_regular_func();
|
||||
cstore_truncate_test_regular_func
|
||||
-----------------------------------
|
||||
|
||||
cstore_truncate_test_regular_func
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- the cached plans are used stating from the second call
|
||||
SELECT cstore_truncate_test_regular_func();
|
||||
cstore_truncate_test_regular_func
|
||||
-----------------------------------
|
||||
|
||||
cstore_truncate_test_regular_func
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP FUNCTION cstore_truncate_test_regular_func();
|
||||
|
@ -192,15 +192,15 @@ CREATE SCHEMA truncate_schema;
|
|||
CREATE FOREIGN TABLE truncate_schema.truncate_tbl (id int) SERVER cstore_server OPTIONS(compression 'pglz');
|
||||
INSERT INTO truncate_schema.truncate_tbl SELECT generate_series(1, 100);
|
||||
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -214,34 +214,34 @@ SELECT current_user \gset
|
|||
\c - truncate_user
|
||||
-- verify truncate command fails and check number of rows
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
ERROR: permission denied for relation truncate_tbl
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
-- switch to super user, grant truncate to truncate_user
|
||||
-- switch to super user, grant truncate to truncate_user
|
||||
\c - :current_user
|
||||
GRANT TRUNCATE ON TABLE truncate_schema.truncate_tbl TO truncate_user;
|
||||
-- verify truncate_user can truncate now
|
||||
\c - truncate_user
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -255,8 +255,8 @@ SELECT count(*) FROM (
|
|||
SELECT pg_ls_dir('cstore_fdw/' || databaseoid ) FROM (
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database()
|
||||
) AS q1) AS q2;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
SELECT count(*) AS columnar_table_count FROM cstore.cstore_data_files \gset
|
||||
CREATE TABLE t(a int, b int) USING cstore_tableam;
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -10,69 +10,69 @@ INSERT INTO t SELECT i, i * i FROM generate_series(1, 10) i;
|
|||
INSERT INTO t SELECT i, i * i FROM generate_series(11, 20) i;
|
||||
INSERT INTO t SELECT i, i * i FROM generate_series(21, 30) i;
|
||||
SELECT sum(a), sum(b) FROM t;
|
||||
sum | sum
|
||||
-----+------
|
||||
sum | sum
|
||||
---------------------------------------------------------------------
|
||||
465 | 9455
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
-- vacuum full should merge stripes together
|
||||
VACUUM FULL t;
|
||||
SELECT sum(a), sum(b) FROM t;
|
||||
sum | sum
|
||||
-----+------
|
||||
sum | sum
|
||||
---------------------------------------------------------------------
|
||||
465 | 9455
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
-- test the case when all data cannot fit into a single stripe
|
||||
SELECT alter_cstore_table_set('t', stripe_row_count => 1000);
|
||||
alter_cstore_table_set
|
||||
------------------------
|
||||
|
||||
alter_cstore_table_set
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO t SELECT i, 2 * i FROM generate_series(1,2500) i;
|
||||
SELECT sum(a), sum(b) FROM t;
|
||||
sum | sum
|
||||
---------+---------
|
||||
sum | sum
|
||||
---------------------------------------------------------------------
|
||||
3126715 | 6261955
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
VACUUM FULL t;
|
||||
SELECT sum(a), sum(b) FROM t;
|
||||
sum | sum
|
||||
---------+---------
|
||||
sum | sum
|
||||
---------------------------------------------------------------------
|
||||
3126715 | 6261955
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
3
|
||||
(1 row)
|
||||
|
||||
-- VACUUM FULL doesn't reclaim dropped columns, but converts them to NULLs
|
||||
ALTER TABLE t DROP COLUMN a;
|
||||
SELECT stripe, attr, block, minimum_value IS NULL, maximum_value IS NULL FROM cstore.cstore_skipnodes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t' ORDER BY 1, 2, 3;
|
||||
stripe | attr | block | ?column? | ?column?
|
||||
--------+------+-------+----------+----------
|
||||
stripe | attr | block | ?column? | ?column?
|
||||
---------------------------------------------------------------------
|
||||
1 | 1 | 0 | f | f
|
||||
1 | 2 | 0 | f | f
|
||||
2 | 1 | 0 | f | f
|
||||
|
@ -83,8 +83,8 @@ SELECT stripe, attr, block, minimum_value IS NULL, maximum_value IS NULL FROM cs
|
|||
|
||||
VACUUM FULL t;
|
||||
SELECT stripe, attr, block, minimum_value IS NULL, maximum_value IS NULL FROM cstore.cstore_skipnodes a, pg_class b WHERE a.relfilenode=b.relfilenode AND b.relname='t' ORDER BY 1, 2, 3;
|
||||
stripe | attr | block | ?column? | ?column?
|
||||
--------+------+-------+----------+----------
|
||||
stripe | attr | block | ?column? | ?column?
|
||||
---------------------------------------------------------------------
|
||||
1 | 1 | 0 | t | t
|
||||
1 | 2 | 0 | f | f
|
||||
2 | 1 | 0 | t | t
|
||||
|
@ -95,8 +95,8 @@ SELECT stripe, attr, block, minimum_value IS NULL, maximum_value IS NULL FROM cs
|
|||
|
||||
-- Make sure we cleaned-up the transient table metadata after VACUUM FULL commands
|
||||
SELECT count(*) - :columnar_table_count FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
|
@ -104,27 +104,27 @@ SELECT count(*) - :columnar_table_count FROM cstore.cstore_data_files;
|
|||
BEGIN;
|
||||
SAVEPOINT s1;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
2530
|
||||
(1 row)
|
||||
|
||||
SELECT pg_size_pretty(pg_relation_size('t'));
|
||||
pg_size_pretty
|
||||
----------------
|
||||
pg_size_pretty
|
||||
---------------------------------------------------------------------
|
||||
32 kB
|
||||
(1 row)
|
||||
|
||||
INSERT INTO t SELECT i FROM generate_series(1, 10000) i;
|
||||
SELECT pg_size_pretty(pg_relation_size('t'));
|
||||
pg_size_pretty
|
||||
----------------
|
||||
pg_size_pretty
|
||||
---------------------------------------------------------------------
|
||||
112 kB
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
12530
|
||||
(1 row)
|
||||
|
||||
|
@ -132,8 +132,8 @@ ROLLBACK TO SAVEPOINT s1;
|
|||
-- not truncated by VACUUM or autovacuum yet (being in transaction ensures this),
|
||||
-- so relation size should be same as before.
|
||||
SELECT pg_size_pretty(pg_relation_size('t'));
|
||||
pg_size_pretty
|
||||
----------------
|
||||
pg_size_pretty
|
||||
---------------------------------------------------------------------
|
||||
112 kB
|
||||
(1 row)
|
||||
|
||||
|
@ -148,14 +148,14 @@ block count: 3, containing data for dropped columns: 0, none compressed: 3, pglz
|
|||
INFO: "t": truncated 14 to 4 pages
|
||||
DETAIL: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
|
||||
SELECT pg_size_pretty(pg_relation_size('t'));
|
||||
pg_size_pretty
|
||||
----------------
|
||||
pg_size_pretty
|
||||
---------------------------------------------------------------------
|
||||
32 kB
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
2530
|
||||
(1 row)
|
||||
|
||||
|
@ -166,9 +166,9 @@ SELECT alter_cstore_table_set('t',
|
|||
block_row_count => 1000,
|
||||
stripe_row_count => 2000,
|
||||
compression => 'pglz');
|
||||
alter_cstore_table_set
|
||||
------------------------
|
||||
|
||||
alter_cstore_table_set
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SAVEPOINT s1;
|
||||
|
@ -176,9 +176,9 @@ INSERT INTO t SELECT i FROM generate_series(1, 1500) i;
|
|||
ROLLBACK TO SAVEPOINT s1;
|
||||
INSERT INTO t SELECT i / 5 FROM generate_series(1, 1500) i;
|
||||
SELECT alter_cstore_table_set('t', compression => 'none');
|
||||
alter_cstore_table_set
|
||||
------------------------
|
||||
|
||||
alter_cstore_table_set
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SAVEPOINT s2;
|
||||
|
@ -193,8 +193,8 @@ total row count: 5530, stripe count: 5, average rows per stripe: 1106
|
|||
block count: 7, containing data for dropped columns: 0, none compressed: 5, pglz compressed: 2
|
||||
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
5530
|
||||
(1 row)
|
||||
|
||||
|
@ -212,9 +212,9 @@ block count: 11, containing data for dropped columns: 2, none compressed: 9, pgl
|
|||
-- note that, a block will be stored in non-compressed for if compression
|
||||
-- doesn't reduce its size.
|
||||
SELECT alter_cstore_table_set('t', compression => 'pglz');
|
||||
alter_cstore_table_set
|
||||
------------------------
|
||||
|
||||
alter_cstore_table_set
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
VACUUM FULL t;
|
||||
|
@ -227,8 +227,8 @@ block count: 8, containing data for dropped columns: 0, none compressed: 2, pglz
|
|||
DROP TABLE t;
|
||||
-- Make sure we cleaned the metadata for t too
|
||||
SELECT count(*) - :columnar_table_count FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
-- Install cstore_fdw
|
||||
CREATE EXTENSION cstore_fdw;
|
|
@ -14,8 +14,8 @@ ALTER FOREIGN TABLE test_alter_table DROP COLUMN a;
|
|||
ANALYZE test_alter_table;
|
||||
-- verify select queries run as expected
|
||||
SELECT * FROM test_alter_table;
|
||||
b | c
|
||||
---+---
|
||||
b | c
|
||||
---------------------------------------------------------------------
|
||||
2 | 3
|
||||
5 | 6
|
||||
8 | 9
|
||||
|
@ -23,11 +23,9 @@ SELECT * FROM test_alter_table;
|
|||
|
||||
SELECT a FROM test_alter_table;
|
||||
ERROR: column "a" does not exist
|
||||
LINE 1: SELECT a FROM test_alter_table;
|
||||
^
|
||||
SELECT b FROM test_alter_table;
|
||||
b
|
||||
---
|
||||
b
|
||||
---------------------------------------------------------------------
|
||||
2
|
||||
5
|
||||
8
|
||||
|
@ -36,36 +34,34 @@ SELECT b FROM test_alter_table;
|
|||
-- verify insert runs as expected
|
||||
INSERT INTO test_alter_table (SELECT 3, 5, 8);
|
||||
ERROR: INSERT has more expressions than target columns
|
||||
LINE 1: INSERT INTO test_alter_table (SELECT 3, 5, 8);
|
||||
^
|
||||
INSERT INTO test_alter_table (SELECT 5, 8);
|
||||
-- add a column with no defaults
|
||||
ALTER FOREIGN TABLE test_alter_table ADD COLUMN d int;
|
||||
SELECT * FROM test_alter_table;
|
||||
b | c | d
|
||||
---+---+---
|
||||
2 | 3 |
|
||||
5 | 6 |
|
||||
8 | 9 |
|
||||
5 | 8 |
|
||||
b | c | d
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 |
|
||||
5 | 6 |
|
||||
8 | 9 |
|
||||
5 | 8 |
|
||||
(4 rows)
|
||||
|
||||
INSERT INTO test_alter_table (SELECT 3, 5, 8);
|
||||
SELECT * FROM test_alter_table;
|
||||
b | c | d
|
||||
---+---+---
|
||||
2 | 3 |
|
||||
5 | 6 |
|
||||
8 | 9 |
|
||||
5 | 8 |
|
||||
b | c | d
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 |
|
||||
5 | 6 |
|
||||
8 | 9 |
|
||||
5 | 8 |
|
||||
3 | 5 | 8
|
||||
(5 rows)
|
||||
|
||||
-- add a fixed-length column with default value
|
||||
ALTER FOREIGN TABLE test_alter_table ADD COLUMN e int default 3;
|
||||
SELECT * from test_alter_table;
|
||||
b | c | d | e
|
||||
---+---+---+---
|
||||
b | c | d | e
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 | | 3
|
||||
5 | 6 | | 3
|
||||
8 | 9 | | 3
|
||||
|
@ -75,8 +71,8 @@ SELECT * from test_alter_table;
|
|||
|
||||
INSERT INTO test_alter_table (SELECT 1, 2, 4, 8);
|
||||
SELECT * from test_alter_table;
|
||||
b | c | d | e
|
||||
---+---+---+---
|
||||
b | c | d | e
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 | | 3
|
||||
5 | 6 | | 3
|
||||
8 | 9 | | 3
|
||||
|
@ -88,8 +84,8 @@ SELECT * from test_alter_table;
|
|||
-- add a variable-length column with default value
|
||||
ALTER FOREIGN TABLE test_alter_table ADD COLUMN f text DEFAULT 'TEXT ME';
|
||||
SELECT * from test_alter_table;
|
||||
b | c | d | e | f
|
||||
---+---+---+---+---------
|
||||
b | c | d | e | f
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 | | 3 | TEXT ME
|
||||
5 | 6 | | 3 | TEXT ME
|
||||
8 | 9 | | 3 | TEXT ME
|
||||
|
@ -100,8 +96,8 @@ SELECT * from test_alter_table;
|
|||
|
||||
INSERT INTO test_alter_table (SELECT 1, 2, 4, 8, 'ABCDEF');
|
||||
SELECT * from test_alter_table;
|
||||
b | c | d | e | f
|
||||
---+---+---+---+---------
|
||||
b | c | d | e | f
|
||||
---------------------------------------------------------------------
|
||||
2 | 3 | | 3 | TEXT ME
|
||||
5 | 6 | | 3 | TEXT ME
|
||||
8 | 9 | | 3 | TEXT ME
|
||||
|
@ -116,8 +112,8 @@ ALTER FOREIGN TABLE test_alter_table DROP COLUMN c;
|
|||
ALTER FOREIGN TABLE test_alter_table DROP COLUMN e;
|
||||
ANALYZE test_alter_table;
|
||||
SELECT * from test_alter_table;
|
||||
b | d | f
|
||||
---+---+---------
|
||||
b | d | f
|
||||
---------------------------------------------------------------------
|
||||
2 | | TEXT ME
|
||||
5 | | TEXT ME
|
||||
8 | | TEXT ME
|
||||
|
@ -128,14 +124,14 @@ SELECT * from test_alter_table;
|
|||
(7 rows)
|
||||
|
||||
SELECT count(*) from test_alter_table;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
7
|
||||
(1 row)
|
||||
|
||||
SELECT count(t.*) from test_alter_table t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
7
|
||||
(1 row)
|
||||
|
||||
|
@ -152,15 +148,15 @@ HINT: Expression is either mutable or does not evaluate to constant value
|
|||
ALTER FOREIGN TABLE test_alter_table ALTER COLUMN h DROP DEFAULT;
|
||||
ANALYZE test_alter_table;
|
||||
SELECT * FROM test_alter_table;
|
||||
b | d | f | g | h
|
||||
---+---+---------+---+---
|
||||
2 | | TEXT ME | |
|
||||
5 | | TEXT ME | |
|
||||
8 | | TEXT ME | |
|
||||
5 | | TEXT ME | |
|
||||
3 | 8 | TEXT ME | |
|
||||
1 | 4 | TEXT ME | |
|
||||
1 | 4 | ABCDEF | |
|
||||
b | d | f | g | h
|
||||
---------------------------------------------------------------------
|
||||
2 | | TEXT ME | |
|
||||
5 | | TEXT ME | |
|
||||
8 | | TEXT ME | |
|
||||
5 | | TEXT ME | |
|
||||
3 | 8 | TEXT ME | |
|
||||
1 | 4 | TEXT ME | |
|
||||
1 | 4 | ABCDEF | |
|
||||
(7 rows)
|
||||
|
||||
-- unsupported type change
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
-- ANALYZE uncompressed table
|
||||
ANALYZE contestant;
|
||||
SELECT count(*) FROM pg_stats WHERE tablename='contestant';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
6
|
||||
(1 row)
|
||||
|
||||
-- ANALYZE compressed table
|
||||
ANALYZE contestant_compressed;
|
||||
SELECT count(*) FROM pg_stats WHERE tablename='contestant_compressed';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
6
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ DROP FOREIGN TABLE contestant;
|
|||
DROP FOREIGN TABLE contestant_compressed;
|
||||
-- make sure DROP deletes metadata
|
||||
SELECT :cstore_data_files_before_drop - count(*) FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
|
@ -30,24 +30,27 @@ SELECT count(*) AS cstore_data_files_before_drop FROM cstore.cstore_data_files \
|
|||
DROP SCHEMA test_schema CASCADE;
|
||||
NOTICE: drop cascades to foreign table test_schema.test_table
|
||||
SELECT :cstore_data_files_before_drop - count(*) FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT current_database() datname \gset
|
||||
CREATE DATABASE db_to_drop;
|
||||
NOTICE: Citus partially supports CREATE DATABASE for distributed databases
|
||||
DETAIL: Citus does not propagate CREATE DATABASE command to workers
|
||||
HINT: You can manually create a database and its extensions on workers.
|
||||
\c db_to_drop
|
||||
CREATE EXTENSION cstore_fdw;
|
||||
CREATE EXTENSION citus;
|
||||
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database() \gset
|
||||
CREATE FOREIGN TABLE test_table(data int) SERVER cstore_server;
|
||||
DROP EXTENSION cstore_fdw CASCADE;
|
||||
DROP EXTENSION citus CASCADE;
|
||||
NOTICE: drop cascades to 2 other objects
|
||||
DETAIL: drop cascades to server cstore_server
|
||||
drop cascades to foreign table test_table
|
||||
-- test database drop
|
||||
CREATE EXTENSION cstore_fdw;
|
||||
CREATE EXTENSION citus;
|
||||
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database() \gset
|
||||
CREATE FOREIGN TABLE test_table(data int) SERVER cstore_server;
|
||||
|
|
|
@ -6,8 +6,8 @@ CREATE FOREIGN TABLE table_with_data (a int) SERVER cstore_server;
|
|||
CREATE TABLE non_cstore_table (a int);
|
||||
COPY table_with_data FROM STDIN;
|
||||
SELECT cstore_table_size('empty_table') < cstore_table_size('table_with_data');
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -4,46 +4,46 @@
|
|||
CREATE FOREIGN TABLE test_insert_command (a int) SERVER cstore_server;
|
||||
-- test single row inserts fail
|
||||
select count(*) from test_insert_command;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
insert into test_insert_command values(1);
|
||||
ERROR: operation is not supported
|
||||
select count(*) from test_insert_command;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
insert into test_insert_command default values;
|
||||
ERROR: operation is not supported
|
||||
select count(*) from test_insert_command;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
-- test inserting from another table succeed
|
||||
CREATE TABLE test_insert_command_data (a int);
|
||||
select count(*) from test_insert_command_data;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
insert into test_insert_command_data values(1);
|
||||
select count(*) from test_insert_command_data;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
insert into test_insert_command select * from test_insert_command_data;
|
||||
select count(*) from test_insert_command;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
|
@ -70,8 +70,8 @@ DROP TABLE test_long_text;
|
|||
SELECT a.int_val
|
||||
FROM test_long_text_hash a, test_cstore_long_text c
|
||||
WHERE a.int_val = c.int_val AND a.hash = md5(c.text_val);
|
||||
int_val
|
||||
---------
|
||||
int_val
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
2
|
||||
3
|
||||
|
|
|
@ -5,21 +5,21 @@
|
|||
SET datestyle = "ISO, YMD";
|
||||
-- Query uncompressed data
|
||||
SELECT count(*) FROM contestant;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
8
|
||||
(1 row)
|
||||
|
||||
SELECT avg(rating), stddev_samp(rating) FROM contestant;
|
||||
avg | stddev_samp
|
||||
-----------------------+------------------
|
||||
avg | stddev_samp
|
||||
---------------------------------------------------------------------
|
||||
2344.3750000000000000 | 433.746119785032
|
||||
(1 row)
|
||||
|
||||
SELECT country, avg(rating) FROM contestant WHERE rating > 2200
|
||||
GROUP BY country ORDER BY country;
|
||||
country | avg
|
||||
---------+-----------------------
|
||||
country | avg
|
||||
---------------------------------------------------------------------
|
||||
XA | 2203.0000000000000000
|
||||
XB | 2610.5000000000000000
|
||||
XC | 2236.0000000000000000
|
||||
|
@ -27,8 +27,8 @@ SELECT country, avg(rating) FROM contestant WHERE rating > 2200
|
|||
(4 rows)
|
||||
|
||||
SELECT * FROM contestant ORDER BY handle;
|
||||
handle | birthdate | rating | percentile | country | achievements
|
||||
--------+------------+--------+------------+---------+--------------
|
||||
handle | birthdate | rating | percentile | country | achievements
|
||||
---------------------------------------------------------------------
|
||||
a | 1990-01-10 | 2090 | 97.1 | XA | {a}
|
||||
b | 1990-11-01 | 2203 | 98.1 | XA | {a,b}
|
||||
c | 1988-11-01 | 2907 | 99.4 | XB | {w,y}
|
||||
|
@ -41,21 +41,21 @@ SELECT * FROM contestant ORDER BY handle;
|
|||
|
||||
-- Query compressed data
|
||||
SELECT count(*) FROM contestant_compressed;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
8
|
||||
(1 row)
|
||||
|
||||
SELECT avg(rating), stddev_samp(rating) FROM contestant_compressed;
|
||||
avg | stddev_samp
|
||||
-----------------------+------------------
|
||||
avg | stddev_samp
|
||||
---------------------------------------------------------------------
|
||||
2344.3750000000000000 | 433.746119785032
|
||||
(1 row)
|
||||
|
||||
SELECT country, avg(rating) FROM contestant_compressed WHERE rating > 2200
|
||||
GROUP BY country ORDER BY country;
|
||||
country | avg
|
||||
---------+-----------------------
|
||||
country | avg
|
||||
---------------------------------------------------------------------
|
||||
XA | 2203.0000000000000000
|
||||
XB | 2610.5000000000000000
|
||||
XC | 2236.0000000000000000
|
||||
|
@ -63,8 +63,8 @@ SELECT country, avg(rating) FROM contestant_compressed WHERE rating > 2200
|
|||
(4 rows)
|
||||
|
||||
SELECT * FROM contestant_compressed ORDER BY handle;
|
||||
handle | birthdate | rating | percentile | country | achievements
|
||||
--------+------------+--------+------------+---------+--------------
|
||||
handle | birthdate | rating | percentile | country | achievements
|
||||
---------------------------------------------------------------------
|
||||
a | 1990-01-10 | 2090 | 97.1 | XA | {a}
|
||||
b | 1990-11-01 | 2203 | 98.1 | XA | {a,b}
|
||||
c | 1988-11-01 | 2907 | 99.4 | XB | {w,y}
|
||||
|
@ -77,8 +77,8 @@ SELECT * FROM contestant_compressed ORDER BY handle;
|
|||
|
||||
-- Verify that we handle whole-row references correctly
|
||||
SELECT to_json(v) FROM contestant v ORDER BY rating LIMIT 1;
|
||||
to_json
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
to_json
|
||||
---------------------------------------------------------------------
|
||||
{"handle":"g","birthdate":"1991-12-13","rating":1803,"percentile":85.1,"country":"XD ","achievements":["a","c"]}
|
||||
(1 row)
|
||||
|
||||
|
@ -88,8 +88,8 @@ CREATE FOREIGN TABLE union_second (a int, b int) SERVER cstore_server;
|
|||
INSERT INTO union_first SELECT a, a FROM generate_series(1, 5) a;
|
||||
INSERT INTO union_second SELECT a, a FROM generate_series(11, 15) a;
|
||||
(SELECT a*1, b FROM union_first) union all (SELECT a*1, b FROM union_second);
|
||||
?column? | b
|
||||
----------+----
|
||||
?column? | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
2 | 2
|
||||
3 | 3
|
||||
|
|
|
@ -6,30 +6,30 @@ BEGIN;
|
|||
INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
||||
ROLLBACK;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
-- check stripe metadata also have been rolled-back
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b
|
||||
WHERE a.relfilenode = b.relfilenode AND b.relname = 't';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
10
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b
|
||||
WHERE a.relfilenode = b.relfilenode AND b.relname = 't';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
|
@ -40,37 +40,37 @@ INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
|||
SAVEPOINT s1;
|
||||
INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
30
|
||||
(1 row)
|
||||
|
||||
ROLLBACK TO SAVEPOINT s1;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
20
|
||||
(1 row)
|
||||
|
||||
ROLLBACK TO SAVEPOINT s0;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
10
|
||||
(1 row)
|
||||
|
||||
INSERT INTO t SELECT i, i+1 FROM generate_series(1, 10) i;
|
||||
COMMIT;
|
||||
SELECT count(*) FROM t;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
20
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore.cstore_stripes a, pg_class b
|
||||
WHERE a.relfilenode = b.relfilenode AND b.relname = 't';
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
-- print whether we're using version > 10 to make version-specific tests clear
|
||||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int > 10 AS version_above_ten;
|
||||
version_above_ten
|
||||
-------------------
|
||||
version_above_ten
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
|
@ -20,8 +20,8 @@ INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1,
|
|||
INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1, 10) a;
|
||||
-- query rows
|
||||
SELECT * FROM cstore_truncate_test;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
2 | 2
|
||||
3 | 3
|
||||
|
@ -36,32 +36,32 @@ SELECT * FROM cstore_truncate_test;
|
|||
|
||||
TRUNCATE TABLE cstore_truncate_test;
|
||||
SELECT * FROM cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT COUNT(*) from cstore_truncate_test;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore_truncate_test_compressed;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
20
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE cstore_truncate_test_compressed;
|
||||
SELECT count(*) FROM cstore_truncate_test_compressed;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT cstore_table_size('cstore_truncate_test_compressed');
|
||||
cstore_table_size
|
||||
-------------------
|
||||
cstore_table_size
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -69,8 +69,8 @@ INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
|||
INSERT INTO cstore_truncate_test_regular select a, a from generate_series(10, 20) a;
|
||||
INSERT INTO cstore_truncate_test_second select a, a from generate_series(20, 30) a;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
2 | 2
|
||||
3 | 3
|
||||
|
@ -84,8 +84,8 @@ SELECT * from cstore_truncate_test;
|
|||
(10 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_second;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
20 | 20
|
||||
21 | 21
|
||||
22 | 22
|
||||
|
@ -100,8 +100,8 @@ SELECT * from cstore_truncate_test_second;
|
|||
(11 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_regular;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
10 | 10
|
||||
11 | 11
|
||||
12 | 12
|
||||
|
@ -122,31 +122,31 @@ TRUNCATE TABLE cstore_truncate_test,
|
|||
cstore_truncate_test_second,
|
||||
cstore_truncate_test;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_second;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_regular;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- test if truncate on empty table works
|
||||
TRUNCATE TABLE cstore_truncate_test;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- make sure TRUNATE deletes metadata for old relfilenode
|
||||
SELECT :cstore_data_files_before_truncate - count(*) FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -159,14 +159,14 @@ INSERT INTO cstore_same_transaction_truncate SELECT * FROM generate_series(20, 2
|
|||
COMMIT;
|
||||
-- should output "1" for the newly created relation
|
||||
SELECT count(*) - :cstore_data_files_before_truncate FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT * FROM cstore_same_transaction_truncate;
|
||||
a
|
||||
----
|
||||
a
|
||||
---------------------------------------------------------------------
|
||||
20
|
||||
21
|
||||
22
|
||||
|
@ -182,16 +182,16 @@ BEGIN
|
|||
END;$$
|
||||
LANGUAGE plpgsql;
|
||||
SELECT cstore_truncate_test_regular_func();
|
||||
cstore_truncate_test_regular_func
|
||||
-----------------------------------
|
||||
|
||||
cstore_truncate_test_regular_func
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- the cached plans are used stating from the second call
|
||||
SELECT cstore_truncate_test_regular_func();
|
||||
cstore_truncate_test_regular_func
|
||||
-----------------------------------
|
||||
|
||||
cstore_truncate_test_regular_func
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP FUNCTION cstore_truncate_test_regular_func();
|
||||
|
@ -203,21 +203,23 @@ CREATE SCHEMA truncate_schema;
|
|||
CREATE FOREIGN TABLE truncate_schema.truncate_tbl (id int) SERVER cstore_server OPTIONS(compression 'pglz');
|
||||
INSERT INTO truncate_schema.truncate_tbl SELECT generate_series(1, 100);
|
||||
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
INSERT INTO truncate_schema.truncate_tbl SELECT generate_series(1, 100);
|
||||
-- create a user that can not truncate
|
||||
CREATE USER truncate_user;
|
||||
NOTICE: not propagating CREATE ROLE/USER commands to worker nodes
|
||||
HINT: Connect to worker nodes directly to manually create all necessary users and roles.
|
||||
GRANT USAGE ON SCHEMA truncate_schema TO truncate_user;
|
||||
GRANT SELECT ON TABLE truncate_schema.truncate_tbl TO truncate_user;
|
||||
REVOKE TRUNCATE ON TABLE truncate_schema.truncate_tbl FROM truncate_user;
|
||||
|
@ -225,34 +227,34 @@ SELECT current_user \gset
|
|||
\c - truncate_user
|
||||
-- verify truncate command fails and check number of rows
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
ERROR: permission denied for table truncate_tbl
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
-- switch to super user, grant truncate to truncate_user
|
||||
-- switch to super user, grant truncate to truncate_user
|
||||
\c - :current_user
|
||||
GRANT TRUNCATE ON TABLE truncate_schema.truncate_tbl TO truncate_user;
|
||||
-- verify truncate_user can truncate now
|
||||
\c - truncate_user
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
-- print whether we're using version > 10 to make version-specific tests clear
|
||||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int > 10 AS version_above_ten;
|
||||
version_above_ten
|
||||
-------------------
|
||||
version_above_ten
|
||||
---------------------------------------------------------------------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
|
@ -15,8 +15,8 @@ SELECT count(*) FROM (
|
|||
SELECT pg_ls_dir('cstore_fdw/' || databaseoid ) FROM (
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database()
|
||||
) AS q1) AS q2;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -30,8 +30,8 @@ INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1,
|
|||
INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1, 10) a;
|
||||
-- query rows
|
||||
SELECT * FROM cstore_truncate_test;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
2 | 2
|
||||
3 | 3
|
||||
|
@ -46,42 +46,42 @@ SELECT * FROM cstore_truncate_test;
|
|||
|
||||
TRUNCATE TABLE cstore_truncate_test;
|
||||
SELECT * FROM cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT COUNT(*) from cstore_truncate_test;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT count(*) FROM cstore_truncate_test_compressed;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
20
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE cstore_truncate_test_compressed;
|
||||
SELECT count(*) FROM cstore_truncate_test_compressed;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
SELECT cstore_table_size('cstore_truncate_test_compressed');
|
||||
cstore_table_size
|
||||
-------------------
|
||||
cstore_table_size
|
||||
---------------------------------------------------------------------
|
||||
26
|
||||
(1 row)
|
||||
|
||||
-- make sure data files still present
|
||||
-- make sure data files still present
|
||||
SELECT count(*) FROM (
|
||||
SELECT pg_ls_dir('cstore_fdw/' || databaseoid ) FROM (
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database()
|
||||
) AS q1) AS q2;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
6
|
||||
(1 row)
|
||||
|
||||
|
@ -89,8 +89,8 @@ INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
|||
INSERT INTO cstore_truncate_test_regular select a, a from generate_series(10, 20) a;
|
||||
INSERT INTO cstore_truncate_test_second select a, a from generate_series(20, 30) a;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
2 | 2
|
||||
3 | 3
|
||||
|
@ -104,8 +104,8 @@ SELECT * from cstore_truncate_test;
|
|||
(10 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_second;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
20 | 20
|
||||
21 | 21
|
||||
22 | 22
|
||||
|
@ -120,8 +120,8 @@ SELECT * from cstore_truncate_test_second;
|
|||
(11 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_regular;
|
||||
a | b
|
||||
----+----
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
10 | 10
|
||||
11 | 11
|
||||
12 | 12
|
||||
|
@ -142,25 +142,25 @@ TRUNCATE TABLE cstore_truncate_test,
|
|||
cstore_truncate_test_second,
|
||||
cstore_truncate_test;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_second;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
SELECT * from cstore_truncate_test_regular;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- test if truncate on empty table works
|
||||
TRUNCATE TABLE cstore_truncate_test;
|
||||
SELECT * from cstore_truncate_test;
|
||||
a | b
|
||||
---+---
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- test if a cached truncate from a pl/pgsql function works
|
||||
|
@ -171,16 +171,16 @@ BEGIN
|
|||
END;$$
|
||||
LANGUAGE plpgsql;
|
||||
SELECT cstore_truncate_test_regular_func();
|
||||
cstore_truncate_test_regular_func
|
||||
-----------------------------------
|
||||
|
||||
cstore_truncate_test_regular_func
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- the cached plans are used stating from the second call
|
||||
SELECT cstore_truncate_test_regular_func();
|
||||
cstore_truncate_test_regular_func
|
||||
-----------------------------------
|
||||
|
||||
cstore_truncate_test_regular_func
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP FUNCTION cstore_truncate_test_regular_func();
|
||||
|
@ -192,15 +192,15 @@ CREATE SCHEMA truncate_schema;
|
|||
CREATE FOREIGN TABLE truncate_schema.truncate_tbl (id int) SERVER cstore_server OPTIONS(compression 'pglz');
|
||||
INSERT INTO truncate_schema.truncate_tbl SELECT generate_series(1, 100);
|
||||
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
SELECT COUNT(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -214,34 +214,34 @@ SELECT current_user \gset
|
|||
\c - truncate_user
|
||||
-- verify truncate command fails and check number of rows
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
ERROR: permission denied for relation truncate_tbl
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
-- switch to super user, grant truncate to truncate_user
|
||||
-- switch to super user, grant truncate to truncate_user
|
||||
\c - :current_user
|
||||
GRANT TRUNCATE ON TABLE truncate_schema.truncate_tbl TO truncate_user;
|
||||
-- verify truncate_user can truncate now
|
||||
\c - truncate_user
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
100
|
||||
(1 row)
|
||||
|
||||
TRUNCATE TABLE truncate_schema.truncate_tbl;
|
||||
SELECT count(*) FROM truncate_schema.truncate_tbl;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
@ -255,8 +255,8 @@ SELECT count(*) FROM (
|
|||
SELECT pg_ls_dir('cstore_fdw/' || databaseoid ) FROM (
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database()
|
||||
) AS q1) AS q2;
|
||||
count
|
||||
-------
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -20,3 +20,13 @@
|
|||
/multi_behavioral_analytics_create_table.sql
|
||||
/multi_insert_select_behavioral_analytics_create_table.sql
|
||||
/hyperscale_tutorial.sql
|
||||
/am_block_filtering.sql
|
||||
/am_copyto.sql
|
||||
/am_create.sql
|
||||
/am_data_types.sql
|
||||
/am_load.sql
|
||||
/fdw_block_filtering.sql
|
||||
/fdw_copyto.sql
|
||||
/fdw_create.sql
|
||||
/fdw_data_types.sql
|
||||
/fdw_load.sql
|
||||
|
|
|
@ -36,15 +36,15 @@ SELECT current_database() datname \gset
|
|||
|
||||
CREATE DATABASE db_to_drop;
|
||||
\c db_to_drop
|
||||
CREATE EXTENSION cstore_fdw;
|
||||
CREATE EXTENSION citus;
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database() \gset
|
||||
|
||||
CREATE TABLE test_table(data int) USING cstore_tableam;
|
||||
|
||||
DROP EXTENSION cstore_fdw CASCADE;
|
||||
DROP EXTENSION citus CASCADE;
|
||||
|
||||
-- test database drop
|
||||
CREATE EXTENSION cstore_fdw;
|
||||
CREATE EXTENSION citus;
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database() \gset
|
||||
|
||||
CREATE TABLE test_table(data int) USING cstore_tableam;
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
-- Install cstore_fdw
|
||||
CREATE EXTENSION cstore_fdw;
|
||||
|
|
@ -36,16 +36,16 @@ SELECT current_database() datname \gset
|
|||
|
||||
CREATE DATABASE db_to_drop;
|
||||
\c db_to_drop
|
||||
CREATE EXTENSION cstore_fdw;
|
||||
CREATE EXTENSION citus;
|
||||
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database() \gset
|
||||
|
||||
CREATE FOREIGN TABLE test_table(data int) SERVER cstore_server;
|
||||
|
||||
DROP EXTENSION cstore_fdw CASCADE;
|
||||
DROP EXTENSION citus CASCADE;
|
||||
|
||||
-- test database drop
|
||||
CREATE EXTENSION cstore_fdw;
|
||||
CREATE EXTENSION citus;
|
||||
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
|
||||
SELECT oid::text databaseoid FROM pg_database WHERE datname = current_database() \gset
|
||||
|
||||
|
|
Loading…
Reference in New Issue