Modify tests to be consistent between versions

Normalize
UNION to prevent optimization
Remove WITH OIDS
Sort ddl events
client_min_messages no longer accepts FATAL
pull/2844/head
Philip Dubé 2019-08-07 18:18:54 +00:00
parent e5cd298a98
commit e84fcc0b12
29 changed files with 197 additions and 593 deletions

View File

@ -12,6 +12,10 @@ s/ port=[0-9]+ / port=xxxxx /g
s/placement [0-9]+/placement xxxxx/g s/placement [0-9]+/placement xxxxx/g
s/shard [0-9]+/shard xxxxx/g s/shard [0-9]+/shard xxxxx/g
s/assigned task [0-9]+ to node/assigned task to node/ s/assigned task [0-9]+ to node/assigned task to node/
s/node group [12] (but|does)/node group \1/
# Differing names can have differing table column widths
s/(-+\|)+-+/---/g
# In foreign_key_to_reference_table, normalize shard table names, etc in # In foreign_key_to_reference_table, normalize shard table names, etc in
# the generated plan # the generated plan
@ -69,3 +73,16 @@ s/(job_[0-9]+\/task_[0-9]+\/p_[0-9]+\.)[0-9]+/\1xxxx/g
# isolation_ref2ref_foreign_keys # isolation_ref2ref_foreign_keys
s/"(ref_table_[0-9]_|ref_table_[0-9]_value_fkey_)[0-9]+"/"\1xxxxxxx"/g s/"(ref_table_[0-9]_|ref_table_[0-9]_value_fkey_)[0-9]+"/"\1xxxxxxx"/g
# Line info varies between versions
/^LINE [0-9]+:.*$/d
/^ *\^$/d
# pg12 changes
s/Partitioned table "/Table "/g
s/\) TABLESPACE pg_default$/\)/g
s/invalid input syntax for type /invalid input syntax for /g
s/_id_ref_id_fkey/_id_fkey/g
s/_ref_id_id_fkey_/_ref_id_fkey_/g
s/fk_test_2_col1_col2_fkey/fk_test_2_col1_fkey/g
s/_id_other_column_ref_fkey/_id_fkey/g

View File

@ -1,41 +1,44 @@
# List of tests whose output we want to normalize, one per line # List of tests whose output we want to normalize, one per line
multi_alter_table_add_constraints custom_aggregate_support
multi_alter_table_statements
foreign_key_to_reference_table
failure_copy_on_hash failure_copy_on_hash
failure_savepoints
foreign_key_restriction_enforcement
failure_real_time_select failure_real_time_select
failure_savepoints
failure_vacuum failure_vacuum
foreign_key_restriction_enforcement
foreign_key_to_reference_table
intermediate_results
isolation_citus_dist_activity isolation_citus_dist_activity
isolation_ref2ref_foreign_keys isolation_ref2ref_foreign_keys
multi_alter_table_add_constraints
multi_alter_table_statements
multi_copy
multi_create_table_constraints
multi_explain
multi_foreign_key
multi_generate_ddl_commands
multi_having_pushdown
multi_insert_select multi_insert_select
multi_insert_select_conflict multi_insert_select_conflict
multi_multiuser
multi_name_lengths
multi_partition_pruning
multi_subtransactions
multi_modifying_xacts
multi_insert_select
sql_procedure
multi_reference_table
multi_create_table_constraints
# the following tests' output are
# normalized for EXPLAIN outputs
# where the executor name is wiped out
multi_join_order_tpch_small multi_join_order_tpch_small
multi_join_pruning multi_join_pruning
multi_master_protocol
multi_metadata_sync
multi_modifying_xacts
multi_multiuser
multi_mx_explain
multi_name_lengths
multi_null_minmax_value_pruning
multi_orderby_limit_pushdown multi_orderby_limit_pushdown
multi_partitioning
multi_partitioning_utils
multi_partition_pruning multi_partition_pruning
multi_reference_table
multi_select_distinct multi_select_distinct
multi_subquery_window_functions multi_subquery_window_functions
multi_subtransactions
multi_task_assignment_policy multi_task_assignment_policy
multi_view multi_view
multi_explain sql_procedure
multi_null_minmax_value_pruning
window_functions window_functions
multi_having_pushdown worker_check_invalid_arguments
multi_partitioning
multi_mx_explain
custom_aggregate_support

View File

@ -305,7 +305,7 @@ SELECT citus.mitmproxy('conn.onQuery(query="^COMMIT").kill()');
-- hide the error message (it has the PID)... -- hide the error message (it has the PID)...
-- we'll test for the txn side-effects to ensure it didn't run -- we'll test for the txn side-effects to ensure it didn't run
SET client_min_messages TO FATAL; SET client_min_messages TO ERROR;
BEGIN; BEGIN;
DELETE FROM dml_test WHERE id = 1; DELETE FROM dml_test WHERE id = 1;
DELETE FROM dml_test WHERE id = 2; DELETE FROM dml_test WHERE id = 2;

View File

@ -305,7 +305,7 @@ SELECT citus.mitmproxy('conn.onQuery(query="^COMMIT").kill()');
-- hide the error message (it has the PID)... -- hide the error message (it has the PID)...
-- we'll test for the txn side-effects to ensure it didn't run -- we'll test for the txn side-effects to ensure it didn't run
SET client_min_messages TO FATAL; SET client_min_messages TO ERROR;
BEGIN; BEGIN;
DELETE FROM dml_test WHERE id = 1; DELETE FROM dml_test WHERE id = 1;
DELETE FROM dml_test WHERE id = 2; DELETE FROM dml_test WHERE id = 2;

View File

@ -532,7 +532,7 @@ BEGIN;
DEBUG: switching to sequential query execution mode DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "transitive_reference_table" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode DETAIL: Reference relation "transitive_reference_table" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
COPY on_update_fkey_table FROM STDIN WITH CSV; COPY on_update_fkey_table FROM STDIN WITH CSV;
ERROR: insert or update on table "on_update_fkey_table_2380005" violates foreign key constraint "fkey_2380005" ERROR: insert or update on table "on_update_fkey_table_2380004" violates foreign key constraint "fkey_2380004"
DETAIL: Key (value_1)=(101) is not present in table "reference_table_2380001". DETAIL: Key (value_1)=(101) is not present in table "reference_table_2380001".
ROLLBACK; ROLLBACK;
-- case 2.8: UPDATE to a reference table is followed by TRUNCATE -- case 2.8: UPDATE to a reference table is followed by TRUNCATE
@ -817,6 +817,8 @@ ERROR: cannot execute DDL on reference relation "transitive_reference_table" be
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
ROLLBACK; ROLLBACK;
-- case 4.5: SELECT to a dist table is follwed by a TRUNCATE -- case 4.5: SELECT to a dist table is follwed by a TRUNCATE
\set VERBOSITY terse
SET client_min_messages to LOG;
BEGIN; BEGIN;
SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99;
count count
@ -825,11 +827,8 @@ BEGIN;
(1 row) (1 row)
TRUNCATE reference_table CASCADE; TRUNCATE reference_table CASCADE;
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "reference_table" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
NOTICE: truncate cascades to table "on_update_fkey_table" NOTICE: truncate cascades to table "on_update_fkey_table"
ERROR: cannot execute DDL on reference relation "reference_table" because there was a parallel SELECT access to distributed relation "on_update_fkey_table" in the same transaction ERROR: cannot execute DDL on reference relation "reference_table" because there was a parallel SELECT access to distributed relation "on_update_fkey_table" in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99;
@ -839,12 +838,9 @@ BEGIN;
(1 row) (1 row)
TRUNCATE transitive_reference_table CASCADE; TRUNCATE transitive_reference_table CASCADE;
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "transitive_reference_table" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
NOTICE: truncate cascades to table "reference_table" NOTICE: truncate cascades to table "reference_table"
NOTICE: truncate cascades to table "on_update_fkey_table" NOTICE: truncate cascades to table "on_update_fkey_table"
ERROR: cannot execute DDL on reference relation "transitive_reference_table" because there was a parallel SELECT access to distributed relation "on_update_fkey_table" in the same transaction ERROR: cannot execute DDL on reference relation "transitive_reference_table" because there was a parallel SELECT access to distributed relation "on_update_fkey_table" in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
ROLLBACK; ROLLBACK;
-- case 4.6: Router SELECT to a dist table is followed by a TRUNCATE -- case 4.6: Router SELECT to a dist table is followed by a TRUNCATE
BEGIN; BEGIN;
@ -855,19 +851,7 @@ BEGIN;
(1 row) (1 row)
TRUNCATE reference_table CASCADE; TRUNCATE reference_table CASCADE;
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "reference_table" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
NOTICE: truncate cascades to table "on_update_fkey_table" NOTICE: truncate cascades to table "on_update_fkey_table"
DEBUG: truncate cascades to table "on_update_fkey_table_2380003"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "on_update_fkey_table_2380005"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "on_update_fkey_table_2380002"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380004"
DETAIL: NOTICE from localhost:57637
DEBUG: building index "reference_table_pkey" on table "reference_table" serially
DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table" serially
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
SELECT count(*) FROM on_update_fkey_table WHERE id = 9; SELECT count(*) FROM on_update_fkey_table WHERE id = 9;
@ -877,34 +861,11 @@ BEGIN;
(1 row) (1 row)
TRUNCATE transitive_reference_table CASCADE; TRUNCATE transitive_reference_table CASCADE;
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "transitive_reference_table" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
NOTICE: truncate cascades to table "reference_table" NOTICE: truncate cascades to table "reference_table"
NOTICE: truncate cascades to table "on_update_fkey_table" NOTICE: truncate cascades to table "on_update_fkey_table"
DEBUG: truncate cascades to table "reference_table_2380001"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "on_update_fkey_table_2380003"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "on_update_fkey_table_2380005"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "reference_table_2380001"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380002"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380004"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380002"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380003"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "on_update_fkey_table_2380004"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380005"
DETAIL: NOTICE from localhost:57638
DEBUG: building index "transitive_reference_table_pkey" on table "transitive_reference_table" serially
DEBUG: building index "reference_table_pkey" on table "reference_table" serially
DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table" serially
ROLLBACK; ROLLBACK;
RESET client_min_messages;
\set VERBOSITY default
-- case 5.1: Parallel UPDATE on distributed table follow by a SELECT -- case 5.1: Parallel UPDATE on distributed table follow by a SELECT
BEGIN; BEGIN;
UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15;
@ -954,18 +915,12 @@ ROLLBACK;
BEGIN; BEGIN;
UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15;
ALTER TABLE reference_table ALTER COLUMN id SET DATA TYPE smallint; ALTER TABLE reference_table ALTER COLUMN id SET DATA TYPE smallint;
DEBUG: rewriting table "reference_table"
DEBUG: building index "reference_table_pkey" on table "reference_table" serially
DEBUG: validating foreign key constraint "fkey"
ERROR: cannot execute DDL on reference relation "reference_table" because there was a parallel DML access to distributed relation "on_update_fkey_table" in the same transaction ERROR: cannot execute DDL on reference relation "reference_table" because there was a parallel DML access to distributed relation "on_update_fkey_table" in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15;
ALTER TABLE transitive_reference_table ALTER COLUMN id SET DATA TYPE smallint; ALTER TABLE transitive_reference_table ALTER COLUMN id SET DATA TYPE smallint;
DEBUG: rewriting table "transitive_reference_table"
DEBUG: building index "transitive_reference_table_pkey" on table "transitive_reference_table" serially
DEBUG: validating foreign key constraint "fkey"
ERROR: cannot execute DDL on reference relation "transitive_reference_table" because there was a parallel DML access to distributed relation "on_update_fkey_table" in the same transaction ERROR: cannot execute DDL on reference relation "transitive_reference_table" because there was a parallel DML access to distributed relation "on_update_fkey_table" in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
ROLLBACK; ROLLBACK;
@ -985,16 +940,10 @@ ROLLBACK;
-- case 6:2: Related parallel DDL on distributed table followed by SELECT on ref. table -- case 6:2: Related parallel DDL on distributed table followed by SELECT on ref. table
BEGIN; BEGIN;
ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE smallint; ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE smallint;
DEBUG: rewriting table "on_update_fkey_table"
DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table" serially
DEBUG: validating foreign key constraint "fkey"
UPDATE reference_table SET id = 160 WHERE id = 15; UPDATE reference_table SET id = 160 WHERE id = 15;
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE smallint; ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE smallint;
DEBUG: rewriting table "on_update_fkey_table"
DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table" serially
DEBUG: validating foreign key constraint "fkey"
UPDATE transitive_reference_table SET id = 160 WHERE id = 15; UPDATE transitive_reference_table SET id = 160 WHERE id = 15;
ROLLBACK; ROLLBACK;
-- case 6:3: Unrelated parallel DDL on distributed table followed by UPDATE on ref. table -- case 6:3: Unrelated parallel DDL on distributed table followed by UPDATE on ref. table
@ -1090,26 +1039,14 @@ ERROR: current transaction is aborted, commands ignored until end of transactio
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1" serially
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
@ -1123,39 +1060,21 @@ ROLLBACK;
-- already executed a parallel query -- already executed a parallel query
BEGIN; BEGIN;
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1" serially
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
CREATE TABLE tt4(id int PRIMARY KEY, value_1 int, FOREIGN KEY(id) REFERENCES tt4(id)); CREATE TABLE tt4(id int PRIMARY KEY, value_1 int, FOREIGN KEY(id) REFERENCES tt4(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "tt4_pkey" for table "tt4"
DEBUG: building index "tt4_pkey" on table "tt4" serially
SELECT create_distributed_table('tt4', 'id'); SELECT create_distributed_table('tt4', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
(1 row) (1 row)
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id), FOREIGN KEY(id) REFERENCES tt4(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id), FOREIGN KEY(id) REFERENCES tt4(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
ERROR: cannot distribute relation "test_table_2" in this transaction because it has a foreign key to a reference table ERROR: cannot distribute relation "test_table_2" in this transaction because it has a foreign key to a reference table
DETAIL: If a hash distributed table has a foreign key to a reference table, it has to be created in sequential mode before any parallel commands have been executed in the same transaction DETAIL: If a hash distributed table has a foreign key to a reference table, it has to be created in sequential mode before any parallel commands have been executed in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
@ -1170,39 +1089,21 @@ ROLLBACK;
BEGIN; BEGIN;
SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1" serially
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
CREATE TABLE tt4(id int PRIMARY KEY, value_1 int, FOREIGN KEY(id) REFERENCES tt4(id)); CREATE TABLE tt4(id int PRIMARY KEY, value_1 int, FOREIGN KEY(id) REFERENCES tt4(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "tt4_pkey" for table "tt4"
DEBUG: building index "tt4_pkey" on table "tt4" serially
SELECT create_distributed_table('tt4', 'id'); SELECT create_distributed_table('tt4', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
(1 row) (1 row)
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id), FOREIGN KEY(id) REFERENCES tt4(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id), FOREIGN KEY(id) REFERENCES tt4(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
@ -1218,26 +1119,14 @@ ROLLBACK;
BEGIN; BEGIN;
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1" serially
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
@ -1258,26 +1147,14 @@ BEGIN;
SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1" serially
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
@ -1293,26 +1170,14 @@ COMMIT;
-- changed -- changed
BEGIN; BEGIN;
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
(1 row) (1 row)
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1" serially
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
@ -1332,26 +1197,14 @@ ROLLBACK;
BEGIN; BEGIN;
SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
(1 row) (1 row)
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1" serially
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
@ -1374,13 +1227,7 @@ BEGIN;
SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
ERROR: cannot distribute relation "test_table_2" in this transaction because it has a foreign key to a reference table ERROR: cannot distribute relation "test_table_2" in this transaction because it has a foreign key to a reference table
DETAIL: If a hash distributed table has a foreign key to a reference table, it has to be created in sequential mode before any parallel commands have been executed in the same transaction DETAIL: If a hash distributed table has a foreign key to a reference table, it has to be created in sequential mode before any parallel commands have been executed in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
@ -1401,32 +1248,17 @@ ROLLBACK;
BEGIN; BEGIN;
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1" serially
INSERT INTO test_table_1 SELECT i FROM generate_series(0,100) i; INSERT INTO test_table_1 SELECT i FROM generate_series(0,100) i;
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
INSERT INTO test_table_2 SELECT i, i FROM generate_series(0,100) i; INSERT INTO test_table_2 SELECT i, i FROM generate_series(0,100) i;
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "test_table_1" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
NOTICE: Copying data from local table... NOTICE: Copying data from local table...
DEBUG: Copied 101 rows
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
ERROR: cannot distribute "test_table_2" in sequential mode because it is not empty ERROR: cannot distribute "test_table_2" in sequential mode because it is not empty
HINT: If you have manually set citus.multi_shard_modify_mode to 'sequential', try with 'parallel' option. If that is not the case, try distributing local tables when they are empty. HINT: If you have manually set citus.multi_shard_modify_mode to 'sequential', try with 'parallel' option. If that is not the case, try distributing local tables when they are empty.
-- make sure that the output isn't too verbose -- make sure that the output isn't too verbose
@ -1441,30 +1273,17 @@ BEGIN;
SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1" serially
INSERT INTO test_table_1 SELECT i FROM generate_series(0,100) i; INSERT INTO test_table_1 SELECT i FROM generate_series(0,100) i;
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
INSERT INTO test_table_2 SELECT i, i FROM generate_series(0,100) i; INSERT INTO test_table_2 SELECT i, i FROM generate_series(0,100) i;
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
NOTICE: Copying data from local table... NOTICE: Copying data from local table...
DEBUG: Copied 101 rows
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
ERROR: cannot distribute "test_table_2" in sequential mode because it is not empty ERROR: cannot distribute "test_table_2" in sequential mode because it is not empty
HINT: If you have manually set citus.multi_shard_modify_mode to 'sequential', try with 'parallel' option. If that is not the case, try distributing local tables when they are empty. HINT: If you have manually set citus.multi_shard_modify_mode to 'sequential', try with 'parallel' option. If that is not the case, try distributing local tables when they are empty.
@ -1479,28 +1298,14 @@ COMMIT;
BEGIN; BEGIN;
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1" serially
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2" serially
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "test_table_1" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
@ -1508,9 +1313,7 @@ DETAIL: NOTICE from localhost:57637
-- and maybe some other test -- and maybe some other test
CREATE INDEX i1 ON test_table_1(id); CREATE INDEX i1 ON test_table_1(id);
DEBUG: building index "i1" on table "test_table_1" serially
ALTER TABLE test_table_2 ADD CONSTRAINT check_val CHECK (id > 0); ALTER TABLE test_table_2 ADD CONSTRAINT check_val CHECK (id > 0);
DEBUG: verifying table "test_table_2"
SELECT count(*) FROM test_table_2; SELECT count(*) FROM test_table_2;
count count
------- -------
@ -1655,11 +1458,8 @@ DEBUG: Plan 184 query after replacing subqueries and CTEs: DELETE FROM test_fke
ROLLBACK; ROLLBACK;
RESET client_min_messages; RESET client_min_messages;
\set VERBOSITY terse
DROP SCHEMA test_fkey_to_ref_in_tx CASCADE; DROP SCHEMA test_fkey_to_ref_in_tx CASCADE;
NOTICE: drop cascades to 5 other objects NOTICE: drop cascades to 5 other objects
DETAIL: drop cascades to table transitive_reference_table \set VERBOSITY default
drop cascades to table on_update_fkey_table
drop cascades to table unrelated_dist_table
drop cascades to table reference_table
drop cascades to table distributed_table
SET search_path TO public; SET search_path TO public;

View File

@ -817,6 +817,8 @@ ERROR: cannot execute DDL on reference relation "transitive_reference_table" be
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
ROLLBACK; ROLLBACK;
-- case 4.5: SELECT to a dist table is follwed by a TRUNCATE -- case 4.5: SELECT to a dist table is follwed by a TRUNCATE
\set VERBOSITY terse
SET client_min_messages to LOG;
BEGIN; BEGIN;
SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99;
count count
@ -825,11 +827,8 @@ BEGIN;
(1 row) (1 row)
TRUNCATE reference_table CASCADE; TRUNCATE reference_table CASCADE;
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "reference_table" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
NOTICE: truncate cascades to table "on_update_fkey_table" NOTICE: truncate cascades to table "on_update_fkey_table"
ERROR: cannot execute DDL on reference relation "reference_table" because there was a parallel SELECT access to distributed relation "on_update_fkey_table" in the same transaction ERROR: cannot execute DDL on reference relation "reference_table" because there was a parallel SELECT access to distributed relation "on_update_fkey_table" in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99;
@ -839,12 +838,9 @@ BEGIN;
(1 row) (1 row)
TRUNCATE transitive_reference_table CASCADE; TRUNCATE transitive_reference_table CASCADE;
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "transitive_reference_table" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
NOTICE: truncate cascades to table "reference_table" NOTICE: truncate cascades to table "reference_table"
NOTICE: truncate cascades to table "on_update_fkey_table" NOTICE: truncate cascades to table "on_update_fkey_table"
ERROR: cannot execute DDL on reference relation "transitive_reference_table" because there was a parallel SELECT access to distributed relation "on_update_fkey_table" in the same transaction ERROR: cannot execute DDL on reference relation "transitive_reference_table" because there was a parallel SELECT access to distributed relation "on_update_fkey_table" in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
ROLLBACK; ROLLBACK;
-- case 4.6: Router SELECT to a dist table is followed by a TRUNCATE -- case 4.6: Router SELECT to a dist table is followed by a TRUNCATE
BEGIN; BEGIN;
@ -855,19 +851,7 @@ BEGIN;
(1 row) (1 row)
TRUNCATE reference_table CASCADE; TRUNCATE reference_table CASCADE;
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "reference_table" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
NOTICE: truncate cascades to table "on_update_fkey_table" NOTICE: truncate cascades to table "on_update_fkey_table"
DEBUG: truncate cascades to table "on_update_fkey_table_2380003"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "on_update_fkey_table_2380005"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "on_update_fkey_table_2380002"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380004"
DETAIL: NOTICE from localhost:57637
DEBUG: building index "reference_table_pkey" on table "reference_table"
DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table"
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
SELECT count(*) FROM on_update_fkey_table WHERE id = 9; SELECT count(*) FROM on_update_fkey_table WHERE id = 9;
@ -877,34 +861,11 @@ BEGIN;
(1 row) (1 row)
TRUNCATE transitive_reference_table CASCADE; TRUNCATE transitive_reference_table CASCADE;
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "transitive_reference_table" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
NOTICE: truncate cascades to table "reference_table" NOTICE: truncate cascades to table "reference_table"
NOTICE: truncate cascades to table "on_update_fkey_table" NOTICE: truncate cascades to table "on_update_fkey_table"
DEBUG: truncate cascades to table "reference_table_2380001"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "on_update_fkey_table_2380003"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "on_update_fkey_table_2380005"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "reference_table_2380001"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380002"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380004"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380002"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380004"
DETAIL: NOTICE from localhost:57637
DEBUG: truncate cascades to table "on_update_fkey_table_2380003"
DETAIL: NOTICE from localhost:57638
DEBUG: truncate cascades to table "on_update_fkey_table_2380005"
DETAIL: NOTICE from localhost:57638
DEBUG: building index "transitive_reference_table_pkey" on table "transitive_reference_table"
DEBUG: building index "reference_table_pkey" on table "reference_table"
DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table"
ROLLBACK; ROLLBACK;
RESET client_min_messages;
\set VERBOSITY default
-- case 5.1: Parallel UPDATE on distributed table follow by a SELECT -- case 5.1: Parallel UPDATE on distributed table follow by a SELECT
BEGIN; BEGIN;
UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15;
@ -954,18 +915,12 @@ ROLLBACK;
BEGIN; BEGIN;
UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15;
ALTER TABLE reference_table ALTER COLUMN id SET DATA TYPE smallint; ALTER TABLE reference_table ALTER COLUMN id SET DATA TYPE smallint;
DEBUG: rewriting table "reference_table"
DEBUG: building index "reference_table_pkey" on table "reference_table"
DEBUG: validating foreign key constraint "fkey"
ERROR: cannot execute DDL on reference relation "reference_table" because there was a parallel DML access to distributed relation "on_update_fkey_table" in the same transaction ERROR: cannot execute DDL on reference relation "reference_table" because there was a parallel DML access to distributed relation "on_update_fkey_table" in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15;
ALTER TABLE transitive_reference_table ALTER COLUMN id SET DATA TYPE smallint; ALTER TABLE transitive_reference_table ALTER COLUMN id SET DATA TYPE smallint;
DEBUG: rewriting table "transitive_reference_table"
DEBUG: building index "transitive_reference_table_pkey" on table "transitive_reference_table"
DEBUG: validating foreign key constraint "fkey"
ERROR: cannot execute DDL on reference relation "transitive_reference_table" because there was a parallel DML access to distributed relation "on_update_fkey_table" in the same transaction ERROR: cannot execute DDL on reference relation "transitive_reference_table" because there was a parallel DML access to distributed relation "on_update_fkey_table" in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
ROLLBACK; ROLLBACK;
@ -985,16 +940,10 @@ ROLLBACK;
-- case 6:2: Related parallel DDL on distributed table followed by SELECT on ref. table -- case 6:2: Related parallel DDL on distributed table followed by SELECT on ref. table
BEGIN; BEGIN;
ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE smallint; ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE smallint;
DEBUG: rewriting table "on_update_fkey_table"
DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table"
DEBUG: validating foreign key constraint "fkey"
UPDATE reference_table SET id = 160 WHERE id = 15; UPDATE reference_table SET id = 160 WHERE id = 15;
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE smallint; ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE smallint;
DEBUG: rewriting table "on_update_fkey_table"
DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table"
DEBUG: validating foreign key constraint "fkey"
UPDATE transitive_reference_table SET id = 160 WHERE id = 15; UPDATE transitive_reference_table SET id = 160 WHERE id = 15;
ROLLBACK; ROLLBACK;
-- case 6:3: Unrelated parallel DDL on distributed table followed by UPDATE on ref. table -- case 6:3: Unrelated parallel DDL on distributed table followed by UPDATE on ref. table
@ -1090,26 +1039,14 @@ ERROR: current transaction is aborted, commands ignored until end of transactio
ROLLBACK; ROLLBACK;
BEGIN; BEGIN;
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1"
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
@ -1123,39 +1060,21 @@ ROLLBACK;
-- already executed a parallel query -- already executed a parallel query
BEGIN; BEGIN;
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1"
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
CREATE TABLE tt4(id int PRIMARY KEY, value_1 int, FOREIGN KEY(id) REFERENCES tt4(id)); CREATE TABLE tt4(id int PRIMARY KEY, value_1 int, FOREIGN KEY(id) REFERENCES tt4(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "tt4_pkey" for table "tt4"
DEBUG: building index "tt4_pkey" on table "tt4"
SELECT create_distributed_table('tt4', 'id'); SELECT create_distributed_table('tt4', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
(1 row) (1 row)
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id), FOREIGN KEY(id) REFERENCES tt4(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id), FOREIGN KEY(id) REFERENCES tt4(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
ERROR: cannot distribute relation "test_table_2" in this transaction because it has a foreign key to a reference table ERROR: cannot distribute relation "test_table_2" in this transaction because it has a foreign key to a reference table
DETAIL: If a hash distributed table has a foreign key to a reference table, it has to be created in sequential mode before any parallel commands have been executed in the same transaction DETAIL: If a hash distributed table has a foreign key to a reference table, it has to be created in sequential mode before any parallel commands have been executed in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
@ -1170,39 +1089,21 @@ ROLLBACK;
BEGIN; BEGIN;
SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1"
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
CREATE TABLE tt4(id int PRIMARY KEY, value_1 int, FOREIGN KEY(id) REFERENCES tt4(id)); CREATE TABLE tt4(id int PRIMARY KEY, value_1 int, FOREIGN KEY(id) REFERENCES tt4(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "tt4_pkey" for table "tt4"
DEBUG: building index "tt4_pkey" on table "tt4"
SELECT create_distributed_table('tt4', 'id'); SELECT create_distributed_table('tt4', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
(1 row) (1 row)
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id), FOREIGN KEY(id) REFERENCES tt4(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id), FOREIGN KEY(id) REFERENCES tt4(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
@ -1218,26 +1119,14 @@ ROLLBACK;
BEGIN; BEGIN;
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1"
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
@ -1258,26 +1147,14 @@ BEGIN;
SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1"
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
@ -1293,26 +1170,14 @@ COMMIT;
-- changed -- changed
BEGIN; BEGIN;
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
(1 row) (1 row)
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1"
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
@ -1332,26 +1197,14 @@ ROLLBACK;
BEGIN; BEGIN;
SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
(1 row) (1 row)
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1"
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_reference_table create_reference_table
------------------------ ------------------------
@ -1374,13 +1227,7 @@ BEGIN;
SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
ERROR: cannot distribute relation "test_table_2" in this transaction because it has a foreign key to a reference table ERROR: cannot distribute relation "test_table_2" in this transaction because it has a foreign key to a reference table
DETAIL: If a hash distributed table has a foreign key to a reference table, it has to be created in sequential mode before any parallel commands have been executed in the same transaction DETAIL: If a hash distributed table has a foreign key to a reference table, it has to be created in sequential mode before any parallel commands have been executed in the same transaction
HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';"
@ -1401,32 +1248,17 @@ ROLLBACK;
BEGIN; BEGIN;
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1"
INSERT INTO test_table_1 SELECT i FROM generate_series(0,100) i; INSERT INTO test_table_1 SELECT i FROM generate_series(0,100) i;
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
INSERT INTO test_table_2 SELECT i, i FROM generate_series(0,100) i; INSERT INTO test_table_2 SELECT i, i FROM generate_series(0,100) i;
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "test_table_1" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
NOTICE: Copying data from local table... NOTICE: Copying data from local table...
DEBUG: Copied 101 rows
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
ERROR: cannot distribute "test_table_2" in sequential mode because it is not empty ERROR: cannot distribute "test_table_2" in sequential mode because it is not empty
HINT: If you have manually set citus.multi_shard_modify_mode to 'sequential', try with 'parallel' option. If that is not the case, try distributing local tables when they are empty. HINT: If you have manually set citus.multi_shard_modify_mode to 'sequential', try with 'parallel' option. If that is not the case, try distributing local tables when they are empty.
-- make sure that the output isn't too verbose -- make sure that the output isn't too verbose
@ -1441,30 +1273,17 @@ BEGIN;
SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; SET LOCAL citus.multi_shard_modify_mode TO 'sequential';
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1"
INSERT INTO test_table_1 SELECT i FROM generate_series(0,100) i; INSERT INTO test_table_1 SELECT i FROM generate_series(0,100) i;
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
INSERT INTO test_table_2 SELECT i, i FROM generate_series(0,100) i; INSERT INTO test_table_2 SELECT i, i FROM generate_series(0,100) i;
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
NOTICE: Copying data from local table... NOTICE: Copying data from local table...
DEBUG: Copied 101 rows
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
ERROR: cannot distribute "test_table_2" in sequential mode because it is not empty ERROR: cannot distribute "test_table_2" in sequential mode because it is not empty
HINT: If you have manually set citus.multi_shard_modify_mode to 'sequential', try with 'parallel' option. If that is not the case, try distributing local tables when they are empty. HINT: If you have manually set citus.multi_shard_modify_mode to 'sequential', try with 'parallel' option. If that is not the case, try distributing local tables when they are empty.
@ -1479,28 +1298,14 @@ COMMIT;
BEGIN; BEGIN;
CREATE TABLE test_table_1(id int PRIMARY KEY); CREATE TABLE test_table_1(id int PRIMARY KEY);
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_1_pkey" for table "test_table_1"
DEBUG: building index "test_table_1_pkey" on table "test_table_1"
CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id)); CREATE TABLE test_table_2(id int PRIMARY KEY, value_1 int, FOREIGN KEY(value_1) REFERENCES test_table_1(id));
DEBUG: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_2_pkey" for table "test_table_2"
DEBUG: building index "test_table_2_pkey" on table "test_table_2"
SELECT create_reference_table('test_table_1'); SELECT create_reference_table('test_table_1');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
DEBUG: switching to sequential query execution mode
DETAIL: Reference relation "test_table_1" is modified, which might lead to data inconsistencies or distributed deadlocks via parallel accesses to hash distributed relations due to foreign keys. Any parallel modification to those hash distributed relations in the same transaction can only be executed in sequential query execution mode
create_reference_table create_reference_table
------------------------ ------------------------
(1 row) (1 row)
SELECT create_distributed_table('test_table_2', 'id'); SELECT create_distributed_table('test_table_2', 'id');
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57638
DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping
DETAIL: NOTICE from localhost:57637
create_distributed_table create_distributed_table
-------------------------- --------------------------
@ -1508,9 +1313,7 @@ DETAIL: NOTICE from localhost:57637
-- and maybe some other test -- and maybe some other test
CREATE INDEX i1 ON test_table_1(id); CREATE INDEX i1 ON test_table_1(id);
DEBUG: building index "i1" on table "test_table_1"
ALTER TABLE test_table_2 ADD CONSTRAINT check_val CHECK (id > 0); ALTER TABLE test_table_2 ADD CONSTRAINT check_val CHECK (id > 0);
DEBUG: verifying table "test_table_2"
SELECT count(*) FROM test_table_2; SELECT count(*) FROM test_table_2;
count count
------- -------
@ -1655,11 +1458,8 @@ DEBUG: Plan 184 query after replacing subqueries and CTEs: DELETE FROM test_fke
ROLLBACK; ROLLBACK;
RESET client_min_messages; RESET client_min_messages;
\set VERBOSITY terse
DROP SCHEMA test_fkey_to_ref_in_tx CASCADE; DROP SCHEMA test_fkey_to_ref_in_tx CASCADE;
NOTICE: drop cascades to 5 other objects NOTICE: drop cascades to 5 other objects
DETAIL: drop cascades to table transitive_reference_table \set VERBOSITY default
drop cascades to table on_update_fkey_table
drop cascades to table unrelated_dist_table
drop cascades to table reference_table
drop cascades to table distributed_table
SET search_path TO public; SET search_path TO public;

View File

@ -39,13 +39,9 @@ CREATE TABLE table_to_distribute (
json_data json, json_data json,
test_type_data dummy_type test_type_data dummy_type
); );
-- use the table WITH (OIDS) set
ALTER TABLE table_to_distribute SET WITH OIDS;
SELECT create_distributed_table('table_to_distribute', 'id', 'hash'); SELECT create_distributed_table('table_to_distribute', 'id', 'hash');
ERROR: cannot distribute relation: table_to_distribute ERROR: cannot create constraint on "table_to_distribute"
DETAIL: Distributed relations must not specify the WITH (OIDS) option in their definitions. DETAIL: Distributed relations cannot have UNIQUE, EXCLUDE, or PRIMARY KEY constraints that do not include the partition column (with an equality operator if EXCLUDE).
-- revert WITH (OIDS) from above
ALTER TABLE table_to_distribute SET WITHOUT OIDS;
-- use an index instead of table name -- use an index instead of table name
SELECT create_distributed_table('table_to_distribute_pkey', 'id', 'hash'); SELECT create_distributed_table('table_to_distribute_pkey', 'id', 'hash');
ERROR: table_to_distribute_pkey is not a regular, foreign or partitioned table ERROR: table_to_distribute_pkey is not a regular, foreign or partitioned table

View File

@ -10,13 +10,13 @@ SELECT part_storage_type, part_key, part_replica_count, part_max_size,
t | l_orderkey | 2 | 1536000 | 2 t | l_orderkey | 2 | 1536000 | 2
(1 row) (1 row)
SELECT * FROM master_get_table_ddl_events('lineitem'); SELECT * FROM master_get_table_ddl_events('lineitem') order by 1;
master_get_table_ddl_events master_get_table_ddl_events
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE TABLE public.lineitem (l_orderkey bigint NOT NULL, l_partkey integer NOT NULL, l_suppkey integer NOT NULL, l_linenumber integer NOT NULL, l_quantity numeric(15,2) NOT NULL, l_extendedprice numeric(15,2) NOT NULL, l_discount numeric(15,2) NOT NULL, l_tax numeric(15,2) NOT NULL, l_returnflag character(1) NOT NULL, l_linestatus character(1) NOT NULL, l_shipdate date NOT NULL, l_commitdate date NOT NULL, l_receiptdate date NOT NULL, l_shipinstruct character(25) NOT NULL, l_shipmode character(10) NOT NULL, l_comment character varying(44) NOT NULL) ALTER TABLE public.lineitem ADD CONSTRAINT lineitem_pkey PRIMARY KEY (l_orderkey, l_linenumber)
ALTER TABLE public.lineitem OWNER TO postgres ALTER TABLE public.lineitem OWNER TO postgres
CREATE INDEX lineitem_time_index ON public.lineitem USING btree (l_shipdate) TABLESPACE pg_default CREATE INDEX lineitem_time_index ON public.lineitem USING btree (l_shipdate) TABLESPACE pg_default
ALTER TABLE public.lineitem ADD CONSTRAINT lineitem_pkey PRIMARY KEY (l_orderkey, l_linenumber) CREATE TABLE public.lineitem (l_orderkey bigint NOT NULL, l_partkey integer NOT NULL, l_suppkey integer NOT NULL, l_linenumber integer NOT NULL, l_quantity numeric(15,2) NOT NULL, l_extendedprice numeric(15,2) NOT NULL, l_discount numeric(15,2) NOT NULL, l_tax numeric(15,2) NOT NULL, l_returnflag character(1) NOT NULL, l_linestatus character(1) NOT NULL, l_shipdate date NOT NULL, l_commitdate date NOT NULL, l_receiptdate date NOT NULL, l_shipinstruct character(25) NOT NULL, l_shipmode character(10) NOT NULL, l_comment character varying(44) NOT NULL)
(4 rows) (4 rows)
SELECT * FROM master_get_new_shardid(); SELECT * FROM master_get_new_shardid();

View File

@ -26,12 +26,12 @@ SELECT * FROM pg_dist_partition WHERE partmethod='h' AND repmodel='s';
-- Show that, with no MX tables, metadata snapshot contains only the delete commands, -- Show that, with no MX tables, metadata snapshot contains only the delete commands,
-- pg_dist_node entries and reference tables -- pg_dist_node entries and reference tables
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
unnest unnest
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE TRUNCATE pg_dist_node CASCADE
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
(3 rows) (3 rows)
-- Create a test table with constraints and SERIAL -- Create a test table with constraints and SERIAL
@ -52,43 +52,43 @@ SELECT master_create_worker_shards('mx_test_table', 8, 1);
-- considered as an MX table -- considered as an MX table
UPDATE pg_dist_partition SET repmodel='s' WHERE logicalrelid='mx_test_table'::regclass; UPDATE pg_dist_partition SET repmodel='s' WHERE logicalrelid='mx_test_table'::regclass;
-- Show that the created MX table is included in the metadata snapshot -- Show that the created MX table is included in the metadata snapshot
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
unnest unnest
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
SELECT worker_apply_sequence_command ('CREATE SEQUENCE IF NOT EXISTS mx_test_table_col_3_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE')
ALTER SEQUENCE public.mx_test_table_col_3_seq OWNER TO postgres ALTER SEQUENCE public.mx_test_table_col_3_seq OWNER TO postgres
CREATE TABLE public.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('public.mx_test_table_col_3_seq'::regclass) NOT NULL)
ALTER TABLE public.mx_test_table OWNER TO postgres
ALTER TABLE public.mx_test_table ADD CONSTRAINT mx_test_table_col_1_key UNIQUE (col_1) ALTER TABLE public.mx_test_table ADD CONSTRAINT mx_test_table_col_1_key UNIQUE (col_1)
ALTER TABLE public.mx_test_table OWNER TO postgres ALTER TABLE public.mx_test_table OWNER TO postgres
ALTER TABLE public.mx_test_table OWNER TO postgres
CREATE TABLE public.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('public.mx_test_table_col_3_seq'::regclass) NOT NULL)
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
INSERT INTO pg_dist_partition (logicalrelid, partmethod, partkey, colocationid, repmodel) VALUES ('public.mx_test_table'::regclass, 'h', column_name_to_column('public.mx_test_table','col_1'), 0, 's') INSERT INTO pg_dist_partition (logicalrelid, partmethod, partkey, colocationid, repmodel) VALUES ('public.mx_test_table'::regclass, 'h', column_name_to_column('public.mx_test_table','col_1'), 0, 's')
SELECT worker_create_truncate_trigger('public.mx_test_table')
INSERT INTO pg_dist_placement (shardid, shardstate, shardlength, groupid, placementid) VALUES (1310000, 1, 0, 1, 100000),(1310001, 1, 0, 2, 100001),(1310002, 1, 0, 1, 100002),(1310003, 1, 0, 2, 100003),(1310004, 1, 0, 1, 100004),(1310005, 1, 0, 2, 100005),(1310006, 1, 0, 1, 100006),(1310007, 1, 0, 2, 100007) INSERT INTO pg_dist_placement (shardid, shardstate, shardlength, groupid, placementid) VALUES (1310000, 1, 0, 1, 100000),(1310001, 1, 0, 2, 100001),(1310002, 1, 0, 1, 100002),(1310003, 1, 0, 2, 100003),(1310004, 1, 0, 1, 100004),(1310005, 1, 0, 2, 100005),(1310006, 1, 0, 1, 100006),(1310007, 1, 0, 2, 100007)
INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ('public.mx_test_table'::regclass, 1310000, 't', '-2147483648', '-1610612737'),('public.mx_test_table'::regclass, 1310001, 't', '-1610612736', '-1073741825'),('public.mx_test_table'::regclass, 1310002, 't', '-1073741824', '-536870913'),('public.mx_test_table'::regclass, 1310003, 't', '-536870912', '-1'),('public.mx_test_table'::regclass, 1310004, 't', '0', '536870911'),('public.mx_test_table'::regclass, 1310005, 't', '536870912', '1073741823'),('public.mx_test_table'::regclass, 1310006, 't', '1073741824', '1610612735'),('public.mx_test_table'::regclass, 1310007, 't', '1610612736', '2147483647') INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ('public.mx_test_table'::regclass, 1310000, 't', '-2147483648', '-1610612737'),('public.mx_test_table'::regclass, 1310001, 't', '-1610612736', '-1073741825'),('public.mx_test_table'::regclass, 1310002, 't', '-1073741824', '-536870913'),('public.mx_test_table'::regclass, 1310003, 't', '-536870912', '-1'),('public.mx_test_table'::regclass, 1310004, 't', '0', '536870911'),('public.mx_test_table'::regclass, 1310005, 't', '536870912', '1073741823'),('public.mx_test_table'::regclass, 1310006, 't', '1073741824', '1610612735'),('public.mx_test_table'::regclass, 1310007, 't', '1610612736', '2147483647')
SELECT worker_apply_sequence_command ('CREATE SEQUENCE IF NOT EXISTS mx_test_table_col_3_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE')
SELECT worker_create_truncate_trigger('public.mx_test_table')
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE
(13 rows) (13 rows)
-- Show that CREATE INDEX commands are included in the metadata snapshot -- Show that CREATE INDEX commands are included in the metadata snapshot
CREATE INDEX mx_index ON mx_test_table(col_2); CREATE INDEX mx_index ON mx_test_table(col_2);
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
unnest unnest
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
SELECT worker_apply_sequence_command ('CREATE SEQUENCE IF NOT EXISTS mx_test_table_col_3_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE')
ALTER SEQUENCE public.mx_test_table_col_3_seq OWNER TO postgres ALTER SEQUENCE public.mx_test_table_col_3_seq OWNER TO postgres
CREATE TABLE public.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('public.mx_test_table_col_3_seq'::regclass) NOT NULL)
ALTER TABLE public.mx_test_table OWNER TO postgres
CREATE INDEX mx_index ON public.mx_test_table USING btree (col_2) TABLESPACE pg_default
ALTER TABLE public.mx_test_table ADD CONSTRAINT mx_test_table_col_1_key UNIQUE (col_1) ALTER TABLE public.mx_test_table ADD CONSTRAINT mx_test_table_col_1_key UNIQUE (col_1)
ALTER TABLE public.mx_test_table OWNER TO postgres ALTER TABLE public.mx_test_table OWNER TO postgres
ALTER TABLE public.mx_test_table OWNER TO postgres
CREATE INDEX mx_index ON public.mx_test_table USING btree (col_2) TABLESPACE pg_default
CREATE TABLE public.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('public.mx_test_table_col_3_seq'::regclass) NOT NULL)
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
INSERT INTO pg_dist_partition (logicalrelid, partmethod, partkey, colocationid, repmodel) VALUES ('public.mx_test_table'::regclass, 'h', column_name_to_column('public.mx_test_table','col_1'), 0, 's') INSERT INTO pg_dist_partition (logicalrelid, partmethod, partkey, colocationid, repmodel) VALUES ('public.mx_test_table'::regclass, 'h', column_name_to_column('public.mx_test_table','col_1'), 0, 's')
SELECT worker_create_truncate_trigger('public.mx_test_table')
INSERT INTO pg_dist_placement (shardid, shardstate, shardlength, groupid, placementid) VALUES (1310000, 1, 0, 1, 100000),(1310001, 1, 0, 2, 100001),(1310002, 1, 0, 1, 100002),(1310003, 1, 0, 2, 100003),(1310004, 1, 0, 1, 100004),(1310005, 1, 0, 2, 100005),(1310006, 1, 0, 1, 100006),(1310007, 1, 0, 2, 100007) INSERT INTO pg_dist_placement (shardid, shardstate, shardlength, groupid, placementid) VALUES (1310000, 1, 0, 1, 100000),(1310001, 1, 0, 2, 100001),(1310002, 1, 0, 1, 100002),(1310003, 1, 0, 2, 100003),(1310004, 1, 0, 1, 100004),(1310005, 1, 0, 2, 100005),(1310006, 1, 0, 1, 100006),(1310007, 1, 0, 2, 100007)
INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ('public.mx_test_table'::regclass, 1310000, 't', '-2147483648', '-1610612737'),('public.mx_test_table'::regclass, 1310001, 't', '-1610612736', '-1073741825'),('public.mx_test_table'::regclass, 1310002, 't', '-1073741824', '-536870913'),('public.mx_test_table'::regclass, 1310003, 't', '-536870912', '-1'),('public.mx_test_table'::regclass, 1310004, 't', '0', '536870911'),('public.mx_test_table'::regclass, 1310005, 't', '536870912', '1073741823'),('public.mx_test_table'::regclass, 1310006, 't', '1073741824', '1610612735'),('public.mx_test_table'::regclass, 1310007, 't', '1610612736', '2147483647') INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ('public.mx_test_table'::regclass, 1310000, 't', '-2147483648', '-1610612737'),('public.mx_test_table'::regclass, 1310001, 't', '-1610612736', '-1073741825'),('public.mx_test_table'::regclass, 1310002, 't', '-1073741824', '-536870913'),('public.mx_test_table'::regclass, 1310003, 't', '-536870912', '-1'),('public.mx_test_table'::regclass, 1310004, 't', '0', '536870911'),('public.mx_test_table'::regclass, 1310005, 't', '536870912', '1073741823'),('public.mx_test_table'::regclass, 1310006, 't', '1073741824', '1610612735'),('public.mx_test_table'::regclass, 1310007, 't', '1610612736', '2147483647')
SELECT worker_apply_sequence_command ('CREATE SEQUENCE IF NOT EXISTS mx_test_table_col_3_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE')
SELECT worker_create_truncate_trigger('public.mx_test_table')
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE
(14 rows) (14 rows)
-- Show that schema changes are included in the metadata snapshot -- Show that schema changes are included in the metadata snapshot
@ -96,23 +96,23 @@ CREATE SCHEMA mx_testing_schema;
ALTER TABLE mx_test_table SET SCHEMA mx_testing_schema; ALTER TABLE mx_test_table SET SCHEMA mx_testing_schema;
WARNING: not propagating ALTER ... SET SCHEMA commands to worker nodes WARNING: not propagating ALTER ... SET SCHEMA commands to worker nodes
HINT: Connect to worker nodes directly to manually change schemas of affected objects. HINT: Connect to worker nodes directly to manually change schemas of affected objects.
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
unnest unnest
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
SELECT worker_apply_sequence_command ('CREATE SEQUENCE IF NOT EXISTS mx_testing_schema.mx_test_table_col_3_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE')
ALTER SEQUENCE mx_testing_schema.mx_test_table_col_3_seq OWNER TO postgres ALTER SEQUENCE mx_testing_schema.mx_test_table_col_3_seq OWNER TO postgres
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL)
ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres
CREATE INDEX mx_index ON mx_testing_schema.mx_test_table USING btree (col_2) TABLESPACE pg_default
ALTER TABLE mx_testing_schema.mx_test_table ADD CONSTRAINT mx_test_table_col_1_key UNIQUE (col_1) ALTER TABLE mx_testing_schema.mx_test_table ADD CONSTRAINT mx_test_table_col_1_key UNIQUE (col_1)
ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres
ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres
CREATE INDEX mx_index ON mx_testing_schema.mx_test_table USING btree (col_2) TABLESPACE pg_default
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL)
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
INSERT INTO pg_dist_partition (logicalrelid, partmethod, partkey, colocationid, repmodel) VALUES ('mx_testing_schema.mx_test_table'::regclass, 'h', column_name_to_column('mx_testing_schema.mx_test_table','col_1'), 0, 's') INSERT INTO pg_dist_partition (logicalrelid, partmethod, partkey, colocationid, repmodel) VALUES ('mx_testing_schema.mx_test_table'::regclass, 'h', column_name_to_column('mx_testing_schema.mx_test_table','col_1'), 0, 's')
SELECT worker_create_truncate_trigger('mx_testing_schema.mx_test_table')
INSERT INTO pg_dist_placement (shardid, shardstate, shardlength, groupid, placementid) VALUES (1310000, 1, 0, 1, 100000),(1310001, 1, 0, 2, 100001),(1310002, 1, 0, 1, 100002),(1310003, 1, 0, 2, 100003),(1310004, 1, 0, 1, 100004),(1310005, 1, 0, 2, 100005),(1310006, 1, 0, 1, 100006),(1310007, 1, 0, 2, 100007) INSERT INTO pg_dist_placement (shardid, shardstate, shardlength, groupid, placementid) VALUES (1310000, 1, 0, 1, 100000),(1310001, 1, 0, 2, 100001),(1310002, 1, 0, 1, 100002),(1310003, 1, 0, 2, 100003),(1310004, 1, 0, 1, 100004),(1310005, 1, 0, 2, 100005),(1310006, 1, 0, 1, 100006),(1310007, 1, 0, 2, 100007)
INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't', '-2147483648', '-1610612737'),('mx_testing_schema.mx_test_table'::regclass, 1310001, 't', '-1610612736', '-1073741825'),('mx_testing_schema.mx_test_table'::regclass, 1310002, 't', '-1073741824', '-536870913'),('mx_testing_schema.mx_test_table'::regclass, 1310003, 't', '-536870912', '-1'),('mx_testing_schema.mx_test_table'::regclass, 1310004, 't', '0', '536870911'),('mx_testing_schema.mx_test_table'::regclass, 1310005, 't', '536870912', '1073741823'),('mx_testing_schema.mx_test_table'::regclass, 1310006, 't', '1073741824', '1610612735'),('mx_testing_schema.mx_test_table'::regclass, 1310007, 't', '1610612736', '2147483647') INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't', '-2147483648', '-1610612737'),('mx_testing_schema.mx_test_table'::regclass, 1310001, 't', '-1610612736', '-1073741825'),('mx_testing_schema.mx_test_table'::regclass, 1310002, 't', '-1073741824', '-536870913'),('mx_testing_schema.mx_test_table'::regclass, 1310003, 't', '-536870912', '-1'),('mx_testing_schema.mx_test_table'::regclass, 1310004, 't', '0', '536870911'),('mx_testing_schema.mx_test_table'::regclass, 1310005, 't', '536870912', '1073741823'),('mx_testing_schema.mx_test_table'::regclass, 1310006, 't', '1073741824', '1610612735'),('mx_testing_schema.mx_test_table'::regclass, 1310007, 't', '1610612736', '2147483647')
SELECT worker_apply_sequence_command ('CREATE SEQUENCE IF NOT EXISTS mx_testing_schema.mx_test_table_col_3_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE')
SELECT worker_create_truncate_trigger('mx_testing_schema.mx_test_table')
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE
(14 rows) (14 rows)
-- Show that append distributed tables are not included in the metadata snapshot -- Show that append distributed tables are not included in the metadata snapshot
@ -124,44 +124,44 @@ SELECT master_create_distributed_table('non_mx_test_table', 'col_1', 'append');
(1 row) (1 row)
UPDATE pg_dist_partition SET repmodel='s' WHERE logicalrelid='non_mx_test_table'::regclass; UPDATE pg_dist_partition SET repmodel='s' WHERE logicalrelid='non_mx_test_table'::regclass;
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
unnest unnest
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
SELECT worker_apply_sequence_command ('CREATE SEQUENCE IF NOT EXISTS mx_testing_schema.mx_test_table_col_3_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE')
ALTER SEQUENCE mx_testing_schema.mx_test_table_col_3_seq OWNER TO postgres ALTER SEQUENCE mx_testing_schema.mx_test_table_col_3_seq OWNER TO postgres
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL)
ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres
CREATE INDEX mx_index ON mx_testing_schema.mx_test_table USING btree (col_2) TABLESPACE pg_default
ALTER TABLE mx_testing_schema.mx_test_table ADD CONSTRAINT mx_test_table_col_1_key UNIQUE (col_1) ALTER TABLE mx_testing_schema.mx_test_table ADD CONSTRAINT mx_test_table_col_1_key UNIQUE (col_1)
ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres
ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres
CREATE INDEX mx_index ON mx_testing_schema.mx_test_table USING btree (col_2) TABLESPACE pg_default
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL)
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
INSERT INTO pg_dist_partition (logicalrelid, partmethod, partkey, colocationid, repmodel) VALUES ('mx_testing_schema.mx_test_table'::regclass, 'h', column_name_to_column('mx_testing_schema.mx_test_table','col_1'), 0, 's') INSERT INTO pg_dist_partition (logicalrelid, partmethod, partkey, colocationid, repmodel) VALUES ('mx_testing_schema.mx_test_table'::regclass, 'h', column_name_to_column('mx_testing_schema.mx_test_table','col_1'), 0, 's')
SELECT worker_create_truncate_trigger('mx_testing_schema.mx_test_table')
INSERT INTO pg_dist_placement (shardid, shardstate, shardlength, groupid, placementid) VALUES (1310000, 1, 0, 1, 100000),(1310001, 1, 0, 2, 100001),(1310002, 1, 0, 1, 100002),(1310003, 1, 0, 2, 100003),(1310004, 1, 0, 1, 100004),(1310005, 1, 0, 2, 100005),(1310006, 1, 0, 1, 100006),(1310007, 1, 0, 2, 100007) INSERT INTO pg_dist_placement (shardid, shardstate, shardlength, groupid, placementid) VALUES (1310000, 1, 0, 1, 100000),(1310001, 1, 0, 2, 100001),(1310002, 1, 0, 1, 100002),(1310003, 1, 0, 2, 100003),(1310004, 1, 0, 1, 100004),(1310005, 1, 0, 2, 100005),(1310006, 1, 0, 1, 100006),(1310007, 1, 0, 2, 100007)
INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't', '-2147483648', '-1610612737'),('mx_testing_schema.mx_test_table'::regclass, 1310001, 't', '-1610612736', '-1073741825'),('mx_testing_schema.mx_test_table'::regclass, 1310002, 't', '-1073741824', '-536870913'),('mx_testing_schema.mx_test_table'::regclass, 1310003, 't', '-536870912', '-1'),('mx_testing_schema.mx_test_table'::regclass, 1310004, 't', '0', '536870911'),('mx_testing_schema.mx_test_table'::regclass, 1310005, 't', '536870912', '1073741823'),('mx_testing_schema.mx_test_table'::regclass, 1310006, 't', '1073741824', '1610612735'),('mx_testing_schema.mx_test_table'::regclass, 1310007, 't', '1610612736', '2147483647') INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't', '-2147483648', '-1610612737'),('mx_testing_schema.mx_test_table'::regclass, 1310001, 't', '-1610612736', '-1073741825'),('mx_testing_schema.mx_test_table'::regclass, 1310002, 't', '-1073741824', '-536870913'),('mx_testing_schema.mx_test_table'::regclass, 1310003, 't', '-536870912', '-1'),('mx_testing_schema.mx_test_table'::regclass, 1310004, 't', '0', '536870911'),('mx_testing_schema.mx_test_table'::regclass, 1310005, 't', '536870912', '1073741823'),('mx_testing_schema.mx_test_table'::regclass, 1310006, 't', '1073741824', '1610612735'),('mx_testing_schema.mx_test_table'::regclass, 1310007, 't', '1610612736', '2147483647')
SELECT worker_apply_sequence_command ('CREATE SEQUENCE IF NOT EXISTS mx_testing_schema.mx_test_table_col_3_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE')
SELECT worker_create_truncate_trigger('mx_testing_schema.mx_test_table')
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE
(14 rows) (14 rows)
-- Show that range distributed tables are not included in the metadata snapshot -- Show that range distributed tables are not included in the metadata snapshot
UPDATE pg_dist_partition SET partmethod='r' WHERE logicalrelid='non_mx_test_table'::regclass; UPDATE pg_dist_partition SET partmethod='r' WHERE logicalrelid='non_mx_test_table'::regclass;
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
unnest unnest
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
SELECT worker_apply_sequence_command ('CREATE SEQUENCE IF NOT EXISTS mx_testing_schema.mx_test_table_col_3_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE')
ALTER SEQUENCE mx_testing_schema.mx_test_table_col_3_seq OWNER TO postgres ALTER SEQUENCE mx_testing_schema.mx_test_table_col_3_seq OWNER TO postgres
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL)
ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres
CREATE INDEX mx_index ON mx_testing_schema.mx_test_table USING btree (col_2) TABLESPACE pg_default
ALTER TABLE mx_testing_schema.mx_test_table ADD CONSTRAINT mx_test_table_col_1_key UNIQUE (col_1) ALTER TABLE mx_testing_schema.mx_test_table ADD CONSTRAINT mx_test_table_col_1_key UNIQUE (col_1)
ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres
ALTER TABLE mx_testing_schema.mx_test_table OWNER TO postgres
CREATE INDEX mx_index ON mx_testing_schema.mx_test_table USING btree (col_2) TABLESPACE pg_default
CREATE TABLE mx_testing_schema.mx_test_table (col_1 integer, col_2 text NOT NULL, col_3 bigint DEFAULT nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) NOT NULL)
INSERT INTO pg_dist_node (nodeid, groupid, nodename, nodeport, noderack, hasmetadata, isactive, noderole, nodecluster) VALUES (1, 1, 'localhost', 57637, 'default', FALSE, TRUE, 'primary'::noderole, 'default'),(2, 2, 'localhost', 57638, 'default', FALSE, TRUE, 'primary'::noderole, 'default')
INSERT INTO pg_dist_partition (logicalrelid, partmethod, partkey, colocationid, repmodel) VALUES ('mx_testing_schema.mx_test_table'::regclass, 'h', column_name_to_column('mx_testing_schema.mx_test_table','col_1'), 0, 's') INSERT INTO pg_dist_partition (logicalrelid, partmethod, partkey, colocationid, repmodel) VALUES ('mx_testing_schema.mx_test_table'::regclass, 'h', column_name_to_column('mx_testing_schema.mx_test_table','col_1'), 0, 's')
SELECT worker_create_truncate_trigger('mx_testing_schema.mx_test_table')
INSERT INTO pg_dist_placement (shardid, shardstate, shardlength, groupid, placementid) VALUES (1310000, 1, 0, 1, 100000),(1310001, 1, 0, 2, 100001),(1310002, 1, 0, 1, 100002),(1310003, 1, 0, 2, 100003),(1310004, 1, 0, 1, 100004),(1310005, 1, 0, 2, 100005),(1310006, 1, 0, 1, 100006),(1310007, 1, 0, 2, 100007) INSERT INTO pg_dist_placement (shardid, shardstate, shardlength, groupid, placementid) VALUES (1310000, 1, 0, 1, 100000),(1310001, 1, 0, 2, 100001),(1310002, 1, 0, 1, 100002),(1310003, 1, 0, 2, 100003),(1310004, 1, 0, 1, 100004),(1310005, 1, 0, 2, 100005),(1310006, 1, 0, 1, 100006),(1310007, 1, 0, 2, 100007)
INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't', '-2147483648', '-1610612737'),('mx_testing_schema.mx_test_table'::regclass, 1310001, 't', '-1610612736', '-1073741825'),('mx_testing_schema.mx_test_table'::regclass, 1310002, 't', '-1073741824', '-536870913'),('mx_testing_schema.mx_test_table'::regclass, 1310003, 't', '-536870912', '-1'),('mx_testing_schema.mx_test_table'::regclass, 1310004, 't', '0', '536870911'),('mx_testing_schema.mx_test_table'::regclass, 1310005, 't', '536870912', '1073741823'),('mx_testing_schema.mx_test_table'::regclass, 1310006, 't', '1073741824', '1610612735'),('mx_testing_schema.mx_test_table'::regclass, 1310007, 't', '1610612736', '2147483647') INSERT INTO pg_dist_shard (logicalrelid, shardid, shardstorage, shardminvalue, shardmaxvalue) VALUES ('mx_testing_schema.mx_test_table'::regclass, 1310000, 't', '-2147483648', '-1610612737'),('mx_testing_schema.mx_test_table'::regclass, 1310001, 't', '-1610612736', '-1073741825'),('mx_testing_schema.mx_test_table'::regclass, 1310002, 't', '-1073741824', '-536870913'),('mx_testing_schema.mx_test_table'::regclass, 1310003, 't', '-536870912', '-1'),('mx_testing_schema.mx_test_table'::regclass, 1310004, 't', '0', '536870911'),('mx_testing_schema.mx_test_table'::regclass, 1310005, 't', '536870912', '1073741823'),('mx_testing_schema.mx_test_table'::regclass, 1310006, 't', '1073741824', '1610612735'),('mx_testing_schema.mx_test_table'::regclass, 1310007, 't', '1610612736', '2147483647')
SELECT worker_apply_sequence_command ('CREATE SEQUENCE IF NOT EXISTS mx_testing_schema.mx_test_table_col_3_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 NO CYCLE')
SELECT worker_create_truncate_trigger('mx_testing_schema.mx_test_table')
SELECT worker_drop_distributed_table(logicalrelid::regclass::text) FROM pg_dist_partition
TRUNCATE pg_dist_node CASCADE
(14 rows) (14 rows)
-- Test start_metadata_sync_to_node UDF -- Test start_metadata_sync_to_node UDF

View File

@ -4,12 +4,11 @@
SET citus.next_shard_id TO 1660000; SET citus.next_shard_id TO 1660000;
SET citus.shard_count TO 4; SET citus.shard_count TO 4;
SET citus.shard_replication_factor TO 1; SET citus.shard_replication_factor TO 1;
-- print major version number for version-specific tests
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS server_version; SELECT substring(:'server_version', '\d+')::int > 10 AS server_version_above_ten;
server_version server_version_above_ten
---------------- --------------------------
11 t
(1 row) (1 row)
-- --
@ -540,7 +539,7 @@ CREATE INDEX partitioning_2009_index ON partitioning_test_2009(id);
-- CREATE INDEX CONCURRENTLY on partition -- CREATE INDEX CONCURRENTLY on partition
CREATE INDEX CONCURRENTLY partitioned_2010_index ON partitioning_test_2010(id); CREATE INDEX CONCURRENTLY partitioned_2010_index ON partitioning_test_2010(id);
-- see index is created -- see index is created
SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'partitioning_test%' ORDER BY indexname; SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'partitioning_test_%' ORDER BY indexname;
tablename | indexname tablename | indexname
---------------------------+---------------------------------- ---------------------------+----------------------------------
partitioning_test_2010 | partitioned_2010_index partitioning_test_2010 | partitioned_2010_index
@ -571,7 +570,7 @@ CREATE TABLE non_distributed_partitioned_table_1 PARTITION OF non_distributed_pa
FOR VALUES FROM (0) TO (10); FOR VALUES FROM (0) TO (10);
CREATE INDEX non_distributed_partitioned_table_index ON non_distributed_partitioned_table(a); CREATE INDEX non_distributed_partitioned_table_index ON non_distributed_partitioned_table(a);
-- see index is created -- see index is created
SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'non_distributed%' ORDER BY indexname; SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'non_distributed_partitioned_table_%' ORDER BY indexname;
tablename | indexname tablename | indexname
-------------------------------------+------------------------------------------- -------------------------------------+-------------------------------------------
non_distributed_partitioned_table_1 | non_distributed_partitioned_table_1_a_idx non_distributed_partitioned_table_1 | non_distributed_partitioned_table_1_a_idx

View File

@ -4,12 +4,11 @@
SET citus.next_shard_id TO 1660000; SET citus.next_shard_id TO 1660000;
SET citus.shard_count TO 4; SET citus.shard_count TO 4;
SET citus.shard_replication_factor TO 1; SET citus.shard_replication_factor TO 1;
-- print major version number for version-specific tests
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS server_version; SELECT substring(:'server_version', '\d+')::int > 10 AS server_version_above_ten;
server_version server_version_above_ten
---------------- --------------------------
10 f
(1 row) (1 row)
-- --
@ -543,7 +542,7 @@ CREATE INDEX partitioning_2009_index ON partitioning_test_2009(id);
-- CREATE INDEX CONCURRENTLY on partition -- CREATE INDEX CONCURRENTLY on partition
CREATE INDEX CONCURRENTLY partitioned_2010_index ON partitioning_test_2010(id); CREATE INDEX CONCURRENTLY partitioned_2010_index ON partitioning_test_2010(id);
-- see index is created -- see index is created
SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'partitioning_test%' ORDER BY indexname; SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'partitioning_test_%' ORDER BY indexname;
tablename | indexname tablename | indexname
------------------------+------------------------- ------------------------+-------------------------
partitioning_test_2010 | partitioned_2010_index partitioning_test_2010 | partitioned_2010_index
@ -568,7 +567,7 @@ FOR VALUES FROM (0) TO (10);
CREATE INDEX non_distributed_partitioned_table_index ON non_distributed_partitioned_table(a); CREATE INDEX non_distributed_partitioned_table_index ON non_distributed_partitioned_table(a);
ERROR: cannot create index on partitioned table "non_distributed_partitioned_table" ERROR: cannot create index on partitioned table "non_distributed_partitioned_table"
-- see index is created -- see index is created
SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'non_distributed%' ORDER BY indexname; SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'non_distributed_partitioned_table_%' ORDER BY indexname;
tablename | indexname tablename | indexname
-----------+----------- -----------+-----------
(0 rows) (0 rows)

View File

@ -4,12 +4,11 @@
SET citus.next_shard_id TO 1660000; SET citus.next_shard_id TO 1660000;
SET citus.shard_count TO 4; SET citus.shard_count TO 4;
SET citus.shard_replication_factor TO 1; SET citus.shard_replication_factor TO 1;
-- print major version number for version-specific tests
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS server_version; SELECT substring(:'server_version', '\d+')::int > 10 AS server_version_above_ten;
server_version server_version_above_ten
---------------- --------------------------
11 t
(1 row) (1 row)
-- --
@ -420,7 +419,7 @@ SELECT * FROM partitioning_test WHERE id = 9 OR id = 10 ORDER BY 1;
-- create default partition -- create default partition
CREATE TABLE partitioning_test_default PARTITION OF partitioning_test DEFAULT; CREATE TABLE partitioning_test_default PARTITION OF partitioning_test DEFAULT;
\d+ partitioning_test \d+ partitioning_test
Table "public.partitioning_test" Partitioned table "public.partitioning_test"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+--------------+------------- --------+---------+-----------+----------+---------+---------+--------------+-------------
id | integer | | | | plain | | id | integer | | | | plain | |
@ -540,7 +539,7 @@ CREATE INDEX partitioning_2009_index ON partitioning_test_2009(id);
-- CREATE INDEX CONCURRENTLY on partition -- CREATE INDEX CONCURRENTLY on partition
CREATE INDEX CONCURRENTLY partitioned_2010_index ON partitioning_test_2010(id); CREATE INDEX CONCURRENTLY partitioned_2010_index ON partitioning_test_2010(id);
-- see index is created -- see index is created
SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'partitioning_test%' ORDER BY indexname; SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'partitioning_test_%' ORDER BY indexname;
tablename | indexname tablename | indexname
---------------------------+---------------------------------- ---------------------------+----------------------------------
partitioning_test_2010 | partitioned_2010_index partitioning_test_2010 | partitioned_2010_index
@ -571,7 +570,7 @@ CREATE TABLE non_distributed_partitioned_table_1 PARTITION OF non_distributed_pa
FOR VALUES FROM (0) TO (10); FOR VALUES FROM (0) TO (10);
CREATE INDEX non_distributed_partitioned_table_index ON non_distributed_partitioned_table(a); CREATE INDEX non_distributed_partitioned_table_index ON non_distributed_partitioned_table(a);
-- see index is created -- see index is created
SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'non_distributed%' ORDER BY indexname; SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'non_distributed_partitioned_table_%' ORDER BY indexname;
tablename | indexname tablename | indexname
-------------------------------------+------------------------------------------- -------------------------------------+-------------------------------------------
non_distributed_partitioned_table_1 | non_distributed_partitioned_table_1_a_idx non_distributed_partitioned_table_1 | non_distributed_partitioned_table_1_a_idx

View File

@ -1382,10 +1382,6 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='reference_sche
(0 rows) (0 rows)
\c - - - :master_port \c - - - :master_port
-- as we expect, setting WITH OIDS does not work for reference tables
ALTER TABLE reference_schema.reference_table_ddl SET WITH OIDS;
ERROR: alter table command is currently unsupported
DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT, ADD|DROP|VALIDATE CONSTRAINT, SET (), RESET (), ATTACH|DETACH PARTITION and TYPE subcommands are supported.
-- now test the renaming of the table, and back to the expected name -- now test the renaming of the table, and back to the expected name
ALTER TABLE reference_schema.reference_table_ddl RENAME TO reference_table_ddl_test; ALTER TABLE reference_schema.reference_table_ddl RENAME TO reference_table_ddl_test;
ALTER TABLE reference_schema.reference_table_ddl_test RENAME TO reference_table_ddl; ALTER TABLE reference_schema.reference_table_ddl_test RENAME TO reference_table_ddl;

View File

@ -87,7 +87,7 @@ DETAIL: Functions are not allowed in FROM clause when the query has subqueries
SELECT SELECT
user_id user_id
FROM FROM
(SELECT 5 AS user_id) users_reference_table (SELECT 5 AS user_id UNION ALL SELECT 6) users_reference_table
WHERE WHERE
NOT EXISTS NOT EXISTS
(SELECT (SELECT
@ -99,7 +99,7 @@ WHERE
) )
LIMIT 3; LIMIT 3;
ERROR: cannot pushdown the subquery ERROR: cannot pushdown the subquery
DETAIL: Subqueries without FROM are not allowed in FROM clause when the outer query has subqueries in WHERE clause and it references a column from another query DETAIL: Complex subqueries and CTEs are not allowed in the FROM clause when the query has subqueries in the WHERE clause and it references a column from another query
-- join with distributed table prevents FROM from recurring -- join with distributed table prevents FROM from recurring
SELECT SELECT
DISTINCT user_id DISTINCT user_id

View File

@ -188,10 +188,9 @@ VIETNAM
RUSSIA RUSSIA
UNITED KINGDOM UNITED KINGDOM
UNITED STATES UNITED STATES
-- Test that we can create on-commit drop tables, and also test creating with -- Test that we can create on-commit drop tables, along with changing column names
-- oids, along with changing column names
BEGIN; BEGIN;
CREATE TEMP TABLE customer_few (customer_key) WITH (OIDS) ON COMMIT DROP AS CREATE TEMP TABLE customer_few (customer_key) ON COMMIT DROP AS
(SELECT * FROM customer WHERE c_nationkey = 1 ORDER BY c_custkey LIMIT 10); (SELECT * FROM customer WHERE c_nationkey = 1 ORDER BY c_custkey LIMIT 10);
SELECT customer_key, c_name, c_address SELECT customer_key, c_name, c_address
FROM customer_few ORDER BY customer_key LIMIT 5; FROM customer_few ORDER BY customer_key LIMIT 5;

View File

@ -98,7 +98,7 @@ $$;
CALL test_procedure_modify_insert(2,12); CALL test_procedure_modify_insert(2,12);
ERROR: duplicate key value violates unique constraint "idx_table_100503" ERROR: duplicate key value violates unique constraint "idx_table_100503"
DETAIL: Key (id, org_id)=(2, 12) already exists. DETAIL: Key (id, org_id)=(2, 12) already exists.
CONTEXT: while executing command on localhost:57637 CONTEXT: while executing command on localhost:57638
SQL statement "INSERT INTO test_table VALUES (tt_id, tt_org_id)" SQL statement "INSERT INTO test_table VALUES (tt_id, tt_org_id)"
PL/pgSQL function test_procedure_modify_insert(integer,integer) line 5 at SQL statement PL/pgSQL function test_procedure_modify_insert(integer,integer) line 5 at SQL statement
SELECT * FROM test_table ORDER BY 1, 2; SELECT * FROM test_table ORDER BY 1, 2;
@ -118,7 +118,7 @@ $$;
CALL test_procedure_modify_insert_commit(2,30); CALL test_procedure_modify_insert_commit(2,30);
ERROR: duplicate key value violates unique constraint "idx_table_100503" ERROR: duplicate key value violates unique constraint "idx_table_100503"
DETAIL: Key (id, org_id)=(2, 30) already exists. DETAIL: Key (id, org_id)=(2, 30) already exists.
CONTEXT: while executing command on localhost:57637 CONTEXT: while executing command on localhost:57638
SQL statement "INSERT INTO test_table VALUES (tt_id, tt_org_id)" SQL statement "INSERT INTO test_table VALUES (tt_id, tt_org_id)"
PL/pgSQL function test_procedure_modify_insert_commit(integer,integer) line 5 at SQL statement PL/pgSQL function test_procedure_modify_insert_commit(integer,integer) line 5 at SQL statement
SELECT * FROM test_table ORDER BY 1, 2; SELECT * FROM test_table ORDER BY 1, 2;
@ -209,14 +209,8 @@ SELECT * from test_table;
----+-------- ----+--------
(0 rows) (0 rows)
\set VERBOSITY terse
DROP SCHEMA procedure_schema CASCADE; DROP SCHEMA procedure_schema CASCADE;
NOTICE: drop cascades to 8 other objects NOTICE: drop cascades to 8 other objects
DETAIL: drop cascades to table test_table \set VERBOSITY default
drop cascades to function test_procedure_delete_insert(integer,integer)
drop cascades to function test_procedure_modify_insert(integer,integer)
drop cascades to function test_procedure_modify_insert_commit(integer,integer)
drop cascades to function test_procedure_rollback_3(integer,integer)
drop cascades to function test_procedure_rollback(integer,integer)
drop cascades to function test_procedure_rollback_2(integer,integer)
drop cascades to function test_procedure(integer,integer)
RESET SEARCH_PATH; RESET SEARCH_PATH;

View File

@ -277,6 +277,8 @@ SELECT * from test_table;
----+-------- ----+--------
(0 rows) (0 rows)
\set VERBOSITY terse
DROP SCHEMA procedure_schema CASCADE; DROP SCHEMA procedure_schema CASCADE;
NOTICE: drop cascades to table test_table NOTICE: drop cascades to table test_table
\set VERBOSITY default
RESET SEARCH_PATH; RESET SEARCH_PATH;

View File

@ -39,17 +39,18 @@ ERROR: cannot pushdown the subquery
DETAIL: Complex subqueries and CTEs are not allowed in the FROM clause when the query has subqueries in the WHERE clause and it references a column from another query DETAIL: Complex subqueries and CTEs are not allowed in the FROM clause when the query has subqueries in the WHERE clause and it references a column from another query
-- Recurring tuples as empty join tree -- Recurring tuples as empty join tree
SELECT * SELECT *
FROM (SELECT 1 AS id, FROM (SELECT 1 AS id, 2 AS value_1, 3 AS value_3
2 AS value_1, UNION ALL SELECT 2 as id, 3 as value_1, 4 as value_3) AS tt1
3 AS value_3) AS tt1
WHERE id IN (SELECT user_id WHERE id IN (SELECT user_id
FROM events_table); FROM events_table);
DEBUG: generating subplan 6_1 for subquery SELECT user_id FROM public.events_table DEBUG: generating subplan 6_1 for subquery SELECT 1 AS id, 2 AS value_1, 3 AS value_3 UNION ALL SELECT 2 AS id, 3 AS value_1, 4 AS value_3
DEBUG: Plan 6 query after replacing subqueries and CTEs: SELECT id, value_1, value_3 FROM (SELECT 1 AS id, 2 AS value_1, 3 AS value_3) tt1 WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.user_id FROM read_intermediate_result('6_1'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer))) DEBUG: generating subplan 6_2 for subquery SELECT user_id FROM public.events_table
DEBUG: Plan 6 query after replacing subqueries and CTEs: SELECT id, value_1, value_3 FROM (SELECT intermediate_result.id, intermediate_result.value_1, intermediate_result.value_3 FROM read_intermediate_result('6_1'::text, 'binary'::citus_copy_format) intermediate_result(id integer, value_1 integer, value_3 integer)) tt1 WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.user_id FROM read_intermediate_result('6_2'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer)))
id | value_1 | value_3 id | value_1 | value_3
----+---------+--------- ----+---------+---------
1 | 2 | 3 1 | 2 | 3
(1 row) 2 | 3 | 4
(2 rows)
-- Recurring tuples in from clause as CTE and SET operation in WHERE clause -- Recurring tuples in from clause as CTE and SET operation in WHERE clause
SELECT Count(*) SELECT Count(*)

View File

@ -157,7 +157,7 @@ SELECT citus.mitmproxy('conn.onQuery(query="^COMMIT").kill()');
-- hide the error message (it has the PID)... -- hide the error message (it has the PID)...
-- we'll test for the txn side-effects to ensure it didn't run -- we'll test for the txn side-effects to ensure it didn't run
SET client_min_messages TO FATAL; SET client_min_messages TO ERROR;
BEGIN; BEGIN;
DELETE FROM dml_test WHERE id = 1; DELETE FROM dml_test WHERE id = 1;

View File

@ -467,6 +467,9 @@ BEGIN;
ROLLBACK; ROLLBACK;
-- case 4.5: SELECT to a dist table is follwed by a TRUNCATE -- case 4.5: SELECT to a dist table is follwed by a TRUNCATE
\set VERBOSITY terse
SET client_min_messages to LOG;
BEGIN; BEGIN;
SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99;
TRUNCATE reference_table CASCADE; TRUNCATE reference_table CASCADE;
@ -488,6 +491,9 @@ BEGIN;
TRUNCATE transitive_reference_table CASCADE; TRUNCATE transitive_reference_table CASCADE;
ROLLBACK; ROLLBACK;
RESET client_min_messages;
\set VERBOSITY default
-- case 5.1: Parallel UPDATE on distributed table follow by a SELECT -- case 5.1: Parallel UPDATE on distributed table follow by a SELECT
BEGIN; BEGIN;
UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15;
@ -899,6 +905,8 @@ ROLLBACK;
RESET client_min_messages; RESET client_min_messages;
\set VERBOSITY terse
DROP SCHEMA test_fkey_to_ref_in_tx CASCADE; DROP SCHEMA test_fkey_to_ref_in_tx CASCADE;
\set VERBOSITY default
SET search_path TO public; SET search_path TO public;

View File

@ -51,13 +51,8 @@ CREATE TABLE table_to_distribute (
test_type_data dummy_type test_type_data dummy_type
); );
-- use the table WITH (OIDS) set
ALTER TABLE table_to_distribute SET WITH OIDS;
SELECT create_distributed_table('table_to_distribute', 'id', 'hash'); SELECT create_distributed_table('table_to_distribute', 'id', 'hash');
-- revert WITH (OIDS) from above
ALTER TABLE table_to_distribute SET WITHOUT OIDS;
-- use an index instead of table name -- use an index instead of table name
SELECT create_distributed_table('table_to_distribute_pkey', 'id', 'hash'); SELECT create_distributed_table('table_to_distribute_pkey', 'id', 'hash');

View File

@ -10,7 +10,7 @@ SET citus.next_shard_id TO 740000;
SELECT part_storage_type, part_key, part_replica_count, part_max_size, SELECT part_storage_type, part_key, part_replica_count, part_max_size,
part_placement_policy FROM master_get_table_metadata('lineitem'); part_placement_policy FROM master_get_table_metadata('lineitem');
SELECT * FROM master_get_table_ddl_events('lineitem'); SELECT * FROM master_get_table_ddl_events('lineitem') order by 1;
SELECT * FROM master_get_new_shardid(); SELECT * FROM master_get_new_shardid();

View File

@ -29,7 +29,7 @@ SELECT * FROM pg_dist_partition WHERE partmethod='h' AND repmodel='s';
-- Show that, with no MX tables, metadata snapshot contains only the delete commands, -- Show that, with no MX tables, metadata snapshot contains only the delete commands,
-- pg_dist_node entries and reference tables -- pg_dist_node entries and reference tables
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
-- Create a test table with constraints and SERIAL -- Create a test table with constraints and SERIAL
CREATE TABLE mx_test_table (col_1 int UNIQUE, col_2 text NOT NULL, col_3 BIGSERIAL); CREATE TABLE mx_test_table (col_1 int UNIQUE, col_2 text NOT NULL, col_3 BIGSERIAL);
@ -41,26 +41,26 @@ SELECT master_create_worker_shards('mx_test_table', 8, 1);
UPDATE pg_dist_partition SET repmodel='s' WHERE logicalrelid='mx_test_table'::regclass; UPDATE pg_dist_partition SET repmodel='s' WHERE logicalrelid='mx_test_table'::regclass;
-- Show that the created MX table is included in the metadata snapshot -- Show that the created MX table is included in the metadata snapshot
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
-- Show that CREATE INDEX commands are included in the metadata snapshot -- Show that CREATE INDEX commands are included in the metadata snapshot
CREATE INDEX mx_index ON mx_test_table(col_2); CREATE INDEX mx_index ON mx_test_table(col_2);
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
-- Show that schema changes are included in the metadata snapshot -- Show that schema changes are included in the metadata snapshot
CREATE SCHEMA mx_testing_schema; CREATE SCHEMA mx_testing_schema;
ALTER TABLE mx_test_table SET SCHEMA mx_testing_schema; ALTER TABLE mx_test_table SET SCHEMA mx_testing_schema;
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
-- Show that append distributed tables are not included in the metadata snapshot -- Show that append distributed tables are not included in the metadata snapshot
CREATE TABLE non_mx_test_table (col_1 int, col_2 text); CREATE TABLE non_mx_test_table (col_1 int, col_2 text);
SELECT master_create_distributed_table('non_mx_test_table', 'col_1', 'append'); SELECT master_create_distributed_table('non_mx_test_table', 'col_1', 'append');
UPDATE pg_dist_partition SET repmodel='s' WHERE logicalrelid='non_mx_test_table'::regclass; UPDATE pg_dist_partition SET repmodel='s' WHERE logicalrelid='non_mx_test_table'::regclass;
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
-- Show that range distributed tables are not included in the metadata snapshot -- Show that range distributed tables are not included in the metadata snapshot
UPDATE pg_dist_partition SET partmethod='r' WHERE logicalrelid='non_mx_test_table'::regclass; UPDATE pg_dist_partition SET partmethod='r' WHERE logicalrelid='non_mx_test_table'::regclass;
SELECT unnest(master_metadata_snapshot()); SELECT unnest(master_metadata_snapshot()) order by 1;
-- Test start_metadata_sync_to_node UDF -- Test start_metadata_sync_to_node UDF

View File

@ -6,9 +6,8 @@ SET citus.next_shard_id TO 1660000;
SET citus.shard_count TO 4; SET citus.shard_count TO 4;
SET citus.shard_replication_factor TO 1; SET citus.shard_replication_factor TO 1;
-- print major version number for version-specific tests
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS server_version; SELECT substring(:'server_version', '\d+')::int > 10 AS server_version_above_ten;
-- --
-- Distributed Partitioned Table Creation Tests -- Distributed Partitioned Table Creation Tests
@ -339,7 +338,7 @@ CREATE INDEX partitioning_2009_index ON partitioning_test_2009(id);
CREATE INDEX CONCURRENTLY partitioned_2010_index ON partitioning_test_2010(id); CREATE INDEX CONCURRENTLY partitioned_2010_index ON partitioning_test_2010(id);
-- see index is created -- see index is created
SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'partitioning_test%' ORDER BY indexname; SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'partitioning_test_%' ORDER BY indexname;
-- test drop -- test drop
-- indexes created on parent table can only be dropped on parent table -- indexes created on parent table can only be dropped on parent table
@ -360,7 +359,7 @@ FOR VALUES FROM (0) TO (10);
CREATE INDEX non_distributed_partitioned_table_index ON non_distributed_partitioned_table(a); CREATE INDEX non_distributed_partitioned_table_index ON non_distributed_partitioned_table(a);
-- see index is created -- see index is created
SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'non_distributed%' ORDER BY indexname; SELECT tablename, indexname FROM pg_indexes WHERE tablename LIKE 'non_distributed_partitioned_table_%' ORDER BY indexname;
-- drop the index and see it is dropped -- drop the index and see it is dropped
DROP INDEX non_distributed_partitioned_table_index; DROP INDEX non_distributed_partitioned_table_index;

View File

@ -874,9 +874,6 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='reference_sche
\di reference_schema.reference_index_2* \di reference_schema.reference_index_2*
\c - - - :master_port \c - - - :master_port
-- as we expect, setting WITH OIDS does not work for reference tables
ALTER TABLE reference_schema.reference_table_ddl SET WITH OIDS;
-- now test the renaming of the table, and back to the expected name -- now test the renaming of the table, and back to the expected name
ALTER TABLE reference_schema.reference_table_ddl RENAME TO reference_table_ddl_test; ALTER TABLE reference_schema.reference_table_ddl RENAME TO reference_table_ddl_test;
ALTER TABLE reference_schema.reference_table_ddl_test RENAME TO reference_table_ddl; ALTER TABLE reference_schema.reference_table_ddl_test RENAME TO reference_table_ddl;

View File

@ -77,7 +77,7 @@ LIMIT 3;
SELECT SELECT
user_id user_id
FROM FROM
(SELECT 5 AS user_id) users_reference_table (SELECT 5 AS user_id UNION ALL SELECT 6) users_reference_table
WHERE WHERE
NOT EXISTS NOT EXISTS
(SELECT (SELECT

View File

@ -106,12 +106,11 @@ COPY nation TO STDOUT;
-- ensure individual cols can be copied out, too -- ensure individual cols can be copied out, too
COPY nation(n_name) TO STDOUT; COPY nation(n_name) TO STDOUT;
-- Test that we can create on-commit drop tables, and also test creating with -- Test that we can create on-commit drop tables, along with changing column names
-- oids, along with changing column names
BEGIN; BEGIN;
CREATE TEMP TABLE customer_few (customer_key) WITH (OIDS) ON COMMIT DROP AS CREATE TEMP TABLE customer_few (customer_key) ON COMMIT DROP AS
(SELECT * FROM customer WHERE c_nationkey = 1 ORDER BY c_custkey LIMIT 10); (SELECT * FROM customer WHERE c_nationkey = 1 ORDER BY c_custkey LIMIT 10);
SELECT customer_key, c_name, c_address SELECT customer_key, c_name, c_address

View File

@ -166,6 +166,8 @@ call test_procedure(1,1);
call test_procedure(20, 20); call test_procedure(20, 20);
SELECT * from test_table; SELECT * from test_table;
\set VERBOSITY terse
DROP SCHEMA procedure_schema CASCADE; DROP SCHEMA procedure_schema CASCADE;
\set VERBOSITY default
RESET SEARCH_PATH; RESET SEARCH_PATH;

View File

@ -6,46 +6,45 @@ SET search_path TO subquery_in_where, public;
SET client_min_messages TO DEBUG1; SET client_min_messages TO DEBUG1;
--CTEs can be used as a recurring tuple with subqueries in WHERE --CTEs can be used as a recurring tuple with subqueries in WHERE
WITH event_id WITH event_id
AS (SELECT user_id AS events_user_id, AS (SELECT user_id AS events_user_id,
time AS events_time, time AS events_time,
event_type event_type
FROM events_table) FROM events_table)
SELECT Count(*) SELECT Count(*)
FROM event_id FROM event_id
WHERE events_user_id IN (SELECT user_id WHERE events_user_id IN (SELECT user_id
FROM users_table); FROM users_table);
--Correlated subqueries can not be used in WHERE clause --Correlated subqueries can not be used in WHERE clause
WITH event_id WITH event_id
AS (SELECT user_id AS events_user_id, AS (SELECT user_id AS events_user_id,
time AS events_time, time AS events_time,
event_type event_type
FROM events_table) FROM events_table)
SELECT Count(*) SELECT Count(*)
FROM event_id FROM event_id
WHERE events_user_id IN (SELECT user_id WHERE events_user_id IN (SELECT user_id
FROM users_table FROM users_table
WHERE users_table.time = events_time); WHERE users_table.time = events_time);
-- Recurring tuples as empty join tree -- Recurring tuples as empty join tree
SELECT * SELECT *
FROM (SELECT 1 AS id, FROM (SELECT 1 AS id, 2 AS value_1, 3 AS value_3
2 AS value_1, UNION ALL SELECT 2 as id, 3 as value_1, 4 as value_3) AS tt1
3 AS value_3) AS tt1 WHERE id IN (SELECT user_id
WHERE id IN (SELECT user_id FROM events_table);
FROM events_table);
-- Recurring tuples in from clause as CTE and SET operation in WHERE clause -- Recurring tuples in from clause as CTE and SET operation in WHERE clause
SELECT Count(*) SELECT Count(*)
FROM (WITH event_id AS FROM (WITH event_id AS
(SELECT user_id AS events_user_id, time AS events_time, event_type (SELECT user_id AS events_user_id, time AS events_time, event_type
FROM events_table) FROM events_table)
SELECT events_user_id, events_time, event_type SELECT events_user_id, events_time, event_type
FROM event_id FROM event_id
ORDER BY 1,2,3 ORDER BY 1,2,3
LIMIT 10) AS sub_table LIMIT 10) AS sub_table
WHERE events_user_id IN ( WHERE events_user_id IN (
(SELECT user_id (SELECT user_id
FROM users_table FROM users_table
@ -157,7 +156,7 @@ FROM
user_id as events_user_id, time as events_time, event_type user_id as events_user_id, time as events_time, event_type
FROM FROM
events_table events_table
ORDER BY ORDER BY
1,2,3 1,2,3
LIMIT LIMIT
10 10
@ -499,7 +498,7 @@ FROM
users_table users_table
ORDER BY ORDER BY
user_id user_id
LIMIT LIMIT
10) as sub_table 10) as sub_table
WHERE WHERE
user_id user_id