diff --git a/.travis.yml b/.travis.yml index 2f240a20d..120b33f1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ matrix: allow_failures: - env: PGVERSION=11 before_install: - - git clone -b v0.7.8 --depth 1 https://github.com/citusdata/tools.git + - git clone -b v0.7.9 --depth 1 https://github.com/citusdata/tools.git - sudo make -C tools install - setup_apt - curl https://install.citusdata.com/community/deb.sh | sudo bash diff --git a/src/backend/distributed/ddl/foreign_constraint.c b/src/backend/distributed/ddl/foreign_constraint.c index e6398b47d..bf7b11760 100644 --- a/src/backend/distributed/ddl/foreign_constraint.c +++ b/src/backend/distributed/ddl/foreign_constraint.c @@ -15,12 +15,15 @@ #include "access/htup_details.h" #include "catalog/namespace.h" #include "catalog/pg_constraint.h" +#if (PG_VERSION_NUM < 110000) #include "catalog/pg_constraint_fn.h" +#endif #include "catalog/pg_type.h" #include "distributed/colocation_utils.h" #include "distributed/foreign_constraint.h" #include "distributed/master_protocol.h" #include "distributed/multi_join_order.h" +#include "distributed/version_compat.h" #include "utils/fmgroids.h" #include "utils/lsyscache.h" #include "utils/rel.h" @@ -640,7 +643,7 @@ HeapTupleOfForeignConstraintIncludesColumn(HeapTuple heapTuple, Oid relationId, { AttrNumber attrNo = DatumGetInt16(columnArray[attrIdx]); - char *colName = get_relid_attribute_name(relationId, attrNo); + char *colName = get_attname_internal(relationId, attrNo, false); if (strncmp(colName, columnName, NAMEDATALEN) == 0) { return true; diff --git a/src/backend/distributed/transaction/transaction_management.c b/src/backend/distributed/transaction/transaction_management.c index df269cf39..944e9f043 100644 --- a/src/backend/distributed/transaction/transaction_management.c +++ b/src/backend/distributed/transaction/transaction_management.c @@ -141,11 +141,11 @@ InitializeTransactionManagement(void) AdjustMaxPreparedTransactions(); /* set aside 8kb of memory for use in CoordinatedTransactionCallback */ - CommitContext = AllocSetContextCreate(TopMemoryContext, - "CommitContext", - 8 * 1024, - 8 * 1024, - 8 * 1024); + CommitContext = AllocSetContextCreateExtended(TopMemoryContext, + "CommitContext", + 8 * 1024, + 8 * 1024, + 8 * 1024); } diff --git a/src/test/regress/expected/foreign_key_restriction_enforcement.out b/src/test/regress/expected/foreign_key_restriction_enforcement.out index f1f4a40f6..aed66861d 100644 --- a/src/test/regress/expected/foreign_key_restriction_enforcement.out +++ b/src/test/regress/expected/foreign_key_restriction_enforcement.out @@ -3,6 +3,13 @@ -- there is foreign key relation between reference -- tables and distributed tables -- +SHOW server_version \gset +SELECT substring(:'server_version', '\d+')::int > 10 AS version_above_ten; + version_above_ten +------------------- + f +(1 row) + CREATE SCHEMA test_fkey_to_ref_in_tx; SET search_path TO 'test_fkey_to_ref_in_tx'; SET citus.next_shard_id TO 2380000; diff --git a/src/test/regress/expected/foreign_key_restriction_enforcement_0.out b/src/test/regress/expected/foreign_key_restriction_enforcement_0.out new file mode 100644 index 000000000..c94685b6f --- /dev/null +++ b/src/test/regress/expected/foreign_key_restriction_enforcement_0.out @@ -0,0 +1,1152 @@ +-- +-- Tests multiple commands in transactions where +-- there is foreign key relation between reference +-- tables and distributed tables +-- +SHOW server_version \gset +SELECT substring(:'server_version', '\d+')::int > 10 AS version_above_ten; + version_above_ten +------------------- + t +(1 row) + +CREATE SCHEMA test_fkey_to_ref_in_tx; +SET search_path TO 'test_fkey_to_ref_in_tx'; +SET citus.next_shard_id TO 2380000; +SET citus.next_placement_id TO 2380000; +SET citus.shard_replication_factor TO 1; +CREATE TABLE referece_table(id int PRIMARY KEY); +SELECT create_reference_table('referece_table'); + create_reference_table +------------------------ + +(1 row) + +CREATE TABLE on_update_fkey_table(id int PRIMARY KEY, value_1 int); +SELECT create_distributed_table('on_update_fkey_table', 'id'); + create_distributed_table +-------------------------- + +(1 row) + +CREATE TABLE unrelated_dist_table(id int PRIMARY KEY, value_1 int); +SELECT create_distributed_table('unrelated_dist_table', 'id'); + create_distributed_table +-------------------------- + +(1 row) + +ALTER TABLE on_update_fkey_table ADD CONSTRAINT fkey FOREIGN KEY(value_1) REFERENCES referece_table(id) ON UPDATE CASCADE; +INSERT INTO referece_table SELECT i FROM generate_series(0, 100) i; +INSERT INTO on_update_fkey_table SELECT i, i % 100 FROM generate_series(0, 1000) i; +INSERT INTO unrelated_dist_table SELECT i, i % 100 FROM generate_series(0, 1000) i; +-- in order to see when the mode automatically swithces to sequential execution +SET client_min_messages TO DEBUG1; +-- case 1.1: SELECT to a reference table is followed by a parallel SELECT to a distributed table +BEGIN; + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + + SELECT count(*) FROM on_update_fkey_table; + count +------- + 1001 +(1 row) + +ROLLBACK; +-- case 1.2: SELECT to a reference table is followed by a multiple router SELECTs to a distributed table +BEGIN; + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + + SELECT count(*) FROM on_update_fkey_table WHERE id = 15; + count +------- + 1 +(1 row) + + SELECT count(*) FROM on_update_fkey_table WHERE id = 16; + count +------- + 1 +(1 row) + + SELECT count(*) FROM on_update_fkey_table WHERE id = 17; + count +------- + 1 +(1 row) + + SELECT count(*) FROM on_update_fkey_table WHERE id = 18; + count +------- + 1 +(1 row) + + +ROLLBACK; +-- case 1.3: SELECT to a reference table is followed by a multi-shard UPDATE to a distributed table +BEGIN; + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + + UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; +ROLLBACK; +-- case 1.4: SELECT to a reference table is followed by a multiple sing-shard UPDATE to a distributed table +BEGIN; + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + + UPDATE on_update_fkey_table SET value_1 = 16 WHERE id = 15; + UPDATE on_update_fkey_table SET value_1 = 16 WHERE id = 16; + UPDATE on_update_fkey_table SET value_1 = 16 WHERE id = 17; + UPDATE on_update_fkey_table SET value_1 = 16 WHERE id = 18; +ROLLBACK; +-- case 1.5: SELECT to a reference table is followed by a DDL that touches fkey column +BEGIN; + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + + ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE bigint; +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" +ROLLBACK; +-- case 1.6: SELECT to a reference table is followed by an unrelated DDL +BEGIN; + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + + ALTER TABLE on_update_fkey_table ADD COLUMN X INT; +DEBUG: switching to sequential query execution mode +DETAIL: cannot execute parallel DDL on relation "on_update_fkey_table" after SELECT command on reference relation "referece_table" because there is a foreign key between them and "referece_table" has been accessed in this transaction +ROLLBACK; +-- case 1.7.1: SELECT to a reference table is followed by a DDL that is on +-- the foreign key column +BEGIN; + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + + -- make sure that the output isn't too verbose + SET LOCAL client_min_messages TO ERROR; + ALTER TABLE on_update_fkey_table DROP COLUMN value_1 CASCADE; +ROLLBACK; +-- case 1.7.2: SELECT to a reference table is followed by a DDL that is on +-- the foreign key column after a parallel query has been executed +BEGIN; + SELECT count(*) FROM unrelated_dist_table; + count +------- + 1001 +(1 row) + + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + + ALTER TABLE on_update_fkey_table DROP COLUMN value_1 CASCADE; +ERROR: cannot modify table "on_update_fkey_table" because there was a parallel operation on a distributed table in the transaction +DETAIL: When there is a foreign key to a reference table, Citus needs to perform all operations over a single connection per node to ensure consistency. +HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" +ROLLBACK; +-- case 1.7.3: SELECT to a reference table is followed by a DDL that is not on +-- the foreign key column, and a parallel query has already been executed +BEGIN; + SELECT count(*) FROM unrelated_dist_table; + count +------- + 1001 +(1 row) + + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + + ALTER TABLE on_update_fkey_table ADD COLUMN X INT; +ERROR: cannot execute parallel DDL on relation "on_update_fkey_table" after SELECT command on reference relation "referece_table" because there is a foreign key between them and "referece_table" has been accessed in this transaction +DETAIL: When there is a foreign key to a reference table, Citus needs to perform all operations over a single connection per node to ensure consistency. +HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" +ROLLBACK; +-- case 1.8: SELECT to a reference table is followed by a COPY +BEGIN; + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + + COPY on_update_fkey_table FROM STDIN WITH CSV; +ROLLBACK; +-- case 2.1: UPDATE to a reference table is followed by a multi-shard SELECT +BEGIN; + UPDATE referece_table SET id = 101 WHERE id = 99; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; + count +------- + 0 +(1 row) + + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 101; + count +------- + 10 +(1 row) + +ROLLBACK; +-- case 2.2: UPDATE to a reference table is followed by multiple router SELECT +BEGIN; + UPDATE referece_table SET id = 101 WHERE id = 99; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 101 AND id = 99; + count +------- + 1 +(1 row) + + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 101 AND id = 199; + count +------- + 1 +(1 row) + + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 101 AND id = 299; + count +------- + 1 +(1 row) + + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 101 AND id = 399; + count +------- + 1 +(1 row) + +ROLLBACK; +-- case 2.3: UPDATE to a reference table is followed by a multi-shard UPDATE +BEGIN; + UPDATE referece_table SET id = 101 WHERE id = 99; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + UPDATE on_update_fkey_table SET value_1 = 15; +ROLLBACK; +-- case 2.4: UPDATE to a reference table is followed by multiple router UPDATEs +BEGIN; + UPDATE referece_table SET id = 101 WHERE id = 99; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + UPDATE on_update_fkey_table SET value_1 = 101 WHERE id = 1; + UPDATE on_update_fkey_table SET value_1 = 101 WHERE id = 2; + UPDATE on_update_fkey_table SET value_1 = 101 WHERE id = 3; + UPDATE on_update_fkey_table SET value_1 = 101 WHERE id = 4; +ROLLBACK; +-- case 2.5: UPDATE to a reference table is followed by a DDL that touches fkey column +BEGIN; + UPDATE referece_table SET id = 101 WHERE id = 99; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE bigint; +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" +ROLLBACK; +-- case 2.6: UPDATE to a reference table is followed by an unrelated DDL +BEGIN; + UPDATE referece_table SET id = 101 WHERE id = 99; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + ALTER TABLE on_update_fkey_table ADD COLUMN value_1_X INT; +ROLLBACK; +-- case 2.7: UPDATE to a reference table is followed by COPY +BEGIN; + UPDATE referece_table SET id = 101 WHERE id = 99; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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; +ERROR: cannot execute parallel COPY on relation "on_update_fkey_table" after DML command on reference relation "referece_table" because there is a foreign key between them and "referece_table" has been modified in this transaction +DETAIL: COPY to a distributed table uses a separate set of connections which will not be able to see the uncommitted changes to the reference table. +HINT: Perform the COPY in a separate transaction. +CONTEXT: COPY on_update_fkey_table, line 2: "1002,99" +ROLLBACK; +-- case 2.8: UPDATE to a reference table is followed by TRUNCATE +BEGIN; + UPDATE referece_table SET id = 101 WHERE id = 99; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + TRUNCATE on_update_fkey_table; +DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table" serially +ROLLBACK; +-- case 3.1: an unrelated DDL to a reference table is followed by a real-time SELECT +BEGIN; + ALTER TABLE referece_table ALTER COLUMN id SET DEFAULT 1001; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + SELECT count(*) FROM on_update_fkey_table; + count +------- + 1001 +(1 row) + +ROLLBACK; +-- case 3.2: DDL that touches fkey column to a reference table is followed by a real-time SELECT +BEGIN; + ALTER TABLE referece_table ALTER COLUMN id SET DATA TYPE int; + SELECT count(*) FROM on_update_fkey_table; + count +------- + 1001 +(1 row) + +ROLLBACK; +-- case 3.3: DDL to a reference table followed by a multi shard UPDATE +BEGIN; + ALTER TABLE referece_table ALTER COLUMN id SET DEFAULT 1001; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + UPDATE on_update_fkey_table SET value_1 = 5 WHERE id != 11; +ROLLBACK; +-- case 3.4: DDL to a reference table followed by multiple router UPDATEs +BEGIN; + ALTER TABLE referece_table ALTER COLUMN id SET DEFAULT 1001; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + UPDATE on_update_fkey_table SET value_1 = 98 WHERE id = 1; + UPDATE on_update_fkey_table SET value_1 = 98 WHERE id = 2; + UPDATE on_update_fkey_table SET value_1 = 98 WHERE id = 3; + UPDATE on_update_fkey_table SET value_1 = 98 WHERE id = 4; +ROLLBACK; +-- case 3.5: DDL to reference table followed by a DDL to dist table +BEGIN; + ALTER TABLE referece_table ALTER COLUMN id SET DATA TYPE smallint; +DEBUG: rewriting table "referece_table" +DEBUG: building index "referece_table_pkey" on table "referece_table" serially +DEBUG: validating foreign key constraint "fkey" + CREATE INDEX fkey_test_index_1 ON on_update_fkey_table(value_1); +DEBUG: building index "fkey_test_index_1" on table "on_update_fkey_table" serially +ROLLBACK; +-- case 4.6: DDL to reference table followed by a DDL to dist table, both touching fkey columns +BEGIN; + ALTER TABLE referece_table ALTER COLUMN id SET DATA TYPE smallint; +DEBUG: rewriting table "referece_table" +DEBUG: building index "referece_table_pkey" on table "referece_table" serially +DEBUG: validating foreign key constraint "fkey" + 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" +ROLLBACK; +-- case 3.7: DDL to a reference table is followed by COPY +BEGIN; + ALTER TABLE referece_table ADD COLUMN X int; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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; +ERROR: cannot execute parallel COPY on relation "on_update_fkey_table" after DDL command on reference relation "referece_table" because there is a foreign key between them and "referece_table" has been modified in this transaction +DETAIL: COPY to a distributed table uses a separate set of connections which will not be able to see the uncommitted changes to the reference table. +HINT: Perform the COPY in a separate transaction. +CONTEXT: COPY on_update_fkey_table, line 2: "1002,99" +ROLLBACK; +-- case 3.8: DDL to a reference table is followed by TRUNCATE +BEGIN; + ALTER TABLE referece_table ADD COLUMN X int; +DEBUG: switching to sequential query execution mode +DETAIL: Reference relation "referece_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 + TRUNCATE on_update_fkey_table; +DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table" serially +ROLLBACK; +-- case 3.9: DDL to a reference table is followed by TRUNCATE +BEGIN; + ALTER TABLE referece_table ALTER COLUMN id SET DATA TYPE smallint; +DEBUG: rewriting table "referece_table" +DEBUG: building index "referece_table_pkey" on table "referece_table" serially +DEBUG: validating foreign key constraint "fkey" + TRUNCATE on_update_fkey_table; +DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table" serially +ROLLBACK; +----- +--- Now, start testing the other way araound +----- +-- case 4.1: SELECT to a dist table is follwed by a SELECT to a reference table +BEGIN; + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; + count +------- + 10 +(1 row) + + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + +ROLLBACK; +-- case 4.2: SELECT to a dist table is follwed by a DML to a reference table +BEGIN; + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; + count +------- + 10 +(1 row) + + UPDATE referece_table SET id = 101 WHERE id = 99; +ERROR: cannot modify reference table "referece_table" because there was a parallel operation on a distributed table +DETAIL: When there is a foreign key to a reference table, Citus needs to perform all operations over a single connection per node to ensure consistency. +HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" +ROLLBACK; +-- case 4.3: SELECT to a dist table is follwed by an unrelated DDL to a reference table +BEGIN; + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; + count +------- + 10 +(1 row) + + ALTER TABLE referece_table ADD COLUMN X INT; +ERROR: cannot execute DDL on reference relation "referece_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; +-- case 4.4: SELECT to a dist table is follwed by a DDL to a reference table +BEGIN; + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; + count +------- + 10 +(1 row) + + ALTER TABLE referece_table ALTER COLUMN id SET DATA TYPE smallint; +DEBUG: rewriting table "referece_table" +DEBUG: building index "referece_table_pkey" on table "referece_table" serially +DEBUG: validating foreign key constraint "fkey" +ERROR: cannot execute DDL on reference relation "referece_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; +-- case 4.5: SELECT to a dist table is follwed by a TRUNCATE +BEGIN; + SELECT count(*) FROM on_update_fkey_table WHERE value_1 = 99; + count +------- + 10 +(1 row) + + TRUNCATE referece_table CASCADE; +NOTICE: truncate cascades to table "on_update_fkey_table" +ERROR: cannot execute DDL on reference relation "referece_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; +-- case 4.6: Router SELECT to a dist table is followed by a TRUNCATE +BEGIN; + SELECT count(*) FROM on_update_fkey_table WHERE id = 9; + count +------- + 1 +(1 row) + + TRUNCATE referece_table CASCADE; +NOTICE: truncate cascades to table "on_update_fkey_table" +DEBUG: truncate cascades to table "on_update_fkey_table_2380002" +DETAIL: NOTICE from localhost:57638 +DEBUG: truncate cascades to table "on_update_fkey_table_2380004" +DETAIL: NOTICE from localhost:57638 +DEBUG: truncate cascades to table "on_update_fkey_table_2380001" +DETAIL: NOTICE from localhost:57637 +DEBUG: truncate cascades to table "on_update_fkey_table_2380003" +DETAIL: NOTICE from localhost:57637 +DEBUG: building index "referece_table_pkey" on table "referece_table" serially +DEBUG: building index "on_update_fkey_table_pkey" on table "on_update_fkey_table" serially +ROLLBACK; +-- case 5.1: Parallel UPDATE on distributed table follow by a SELECT +BEGIN; + UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; + SELECT count(*) FROM referece_table; + count +------- + 101 +(1 row) + +ROLLBACK; +-- case 5.2: Parallel UPDATE on distributed table follow by a UPDATE +BEGIN; + UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; + UPDATE referece_table SET id = 160 WHERE id = 15; +ERROR: cannot execute DML on reference relation "referece_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';" +ROLLBACK; +-- case 5.3: Parallel UPDATE on distributed table follow by an unrelated DDL on reference table +BEGIN; + UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; + ALTER TABLE referece_table ADD COLUMN X INT; +ERROR: cannot execute DDL on reference relation "referece_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';" +ROLLBACK; +-- case 5.4: Parallel UPDATE on distributed table follow by a related DDL on reference table +-- FIXME: Can we do better? +BEGIN; + UPDATE on_update_fkey_table SET value_1 = 16 WHERE value_1 = 15; + ALTER TABLE referece_table ALTER COLUMN id SET DATA TYPE smallint; +DEBUG: rewriting table "referece_table" +DEBUG: building index "referece_table_pkey" on table "referece_table" serially +DEBUG: validating foreign key constraint "fkey" +ERROR: cannot perform DDL on placement 2380001, which has been read over multiple connections +ROLLBACK; +-- case 6:1: Unrelated parallel DDL on distributed table followed by SELECT on ref. table +BEGIN; + ALTER TABLE on_update_fkey_table ADD COLUMN X int; + SELECT count(*) FROM referece_table; +ERROR: cannot execute SELECT on reference relation "referece_table" because there was a parallel DDL 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; +-- case 6:2: Related parallel DDL on distributed table followed by SELECT on ref. table +BEGIN; + 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 referece_table SET id = 160 WHERE id = 15; +ROLLBACK; +-- case 6:3: Unrelated parallel DDL on distributed table followed by UPDATE on ref. table +BEGIN; + ALTER TABLE on_update_fkey_table ADD COLUMN X int; + SELECT count(*) FROM referece_table; +ERROR: cannot execute SELECT on reference relation "referece_table" because there was a parallel DDL 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; +-- case 6:4: Related parallel DDL on distributed table followed by SELECT on ref. table +BEGIN; + ALTER TABLE on_update_fkey_table ADD COLUMN X int; + UPDATE referece_table SET id = 160 WHERE id = 15; +ERROR: cannot execute SELECT on reference relation "referece_table" because there was a parallel DDL 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; +-- case 6:5: Unrelated parallel DDL on distributed table followed by unrelated DDL on ref. table +BEGIN; + ALTER TABLE on_update_fkey_table ADD COLUMN X int; + ALTER TABLE referece_table ADD COLUMN X int; +ERROR: cannot execute DDL on reference relation "referece_table" because there was a parallel DDL 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; +-- case 6:6: Unrelated parallel DDL on distributed table followed by related DDL on ref. table +BEGIN; + ALTER TABLE on_update_fkey_table ADD COLUMN X int; + ALTER TABLE on_update_fkey_table ALTER COLUMN value_1 SET DATA TYPE smallint; +ERROR: cannot modify table "on_update_fkey_table" because there was a parallel operation on a distributed table in the transaction +DETAIL: When there is a foreign key to a reference table, Citus needs to perform all operations over a single connection per node to ensure consistency. +HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" +ROLLBACK; +-- some more extensive tests +-- UPDATE on dist table is followed by DELETE to reference table +BEGIN; + UPDATE on_update_fkey_table SET value_1 = 5 WHERE id != 11; + DELETE FROM referece_table WHERE id = 99; +ERROR: cannot execute DML on reference relation "referece_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';" +ROLLBACK; +-- an unrelated update followed by update on dist table and update +-- on reference table +BEGIN; + UPDATE unrelated_dist_table SET value_1 = 15; + UPDATE on_update_fkey_table SET value_1 = 5 WHERE id != 11; + UPDATE referece_table SET id = 101 WHERE id = 99; +ERROR: cannot execute DML on reference relation "referece_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';" +ROLLBACK; +-- an unrelated update followed by update on the reference table and update +-- on the cascading distributed table +-- note that the UPDATE on the reference table will try to set the execution +-- mode to sequential, which will fail since there is an already opened +-- parallel connections +BEGIN; + UPDATE unrelated_dist_table SET value_1 = 15; + UPDATE referece_table SET id = 101 WHERE id = 99; +ERROR: cannot modify reference table "referece_table" because there was a parallel operation on a distributed table +DETAIL: When there is a foreign key to a reference table, Citus needs to perform all operations over a single connection per node to ensure consistency. +HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" + UPDATE on_update_fkey_table SET value_1 = 5 WHERE id != 11; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK; +BEGIN; + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_reference_table +------------------------ + +(1 row) + + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_distributed_table +-------------------------- + +(1 row) + + -- make sure that the output isn't too verbose + SET LOCAL client_min_messages TO ERROR; + DROP TABLE test_table_1 CASCADE; +ROLLBACK; +-- the fails since we're trying to switch sequential mode after +-- already executed a parallel query +BEGIN; + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_reference_table +------------------------ + +(1 row) + + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_distributed_table +-------------------------- + +(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)); +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'); +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 +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';" + -- make sure that the output isn't too verbose + SET LOCAL client_min_messages TO ERROR; +ERROR: current transaction is aborted, commands ignored until end of transaction block + DROP TABLE test_table_1 CASCADE; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK; +-- same test with the above, but this time using +-- sequential mode, succeeds +BEGIN; + SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_reference_table +------------------------ + +(1 row) + + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_distributed_table +-------------------------- + +(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)); +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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_distributed_table +-------------------------- + +(1 row) + + -- make sure that the output isn't too verbose + SET LOCAL client_min_messages TO ERROR; + DROP TABLE test_table_1 CASCADE; +ROLLBACK; +-- another test with ALTER TABLE fails since we're already opened +-- parallel connection via create_distributed_table(), later +-- adding foreign key to reference table fails +BEGIN; + + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_reference_table +------------------------ + +(1 row) + + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_distributed_table +-------------------------- + +(1 row) + + ALTER TABLE test_table_2 ADD CONSTRAINT c_check FOREIGN KEY (value_1) REFERENCES test_table_1(id); +ERROR: cannot modify table "test_table_2" because there was a parallel operation on a distributed table in the transaction +DETAIL: When there is a foreign key to a reference table, Citus needs to perform all operations over a single connection per node to ensure consistency. +HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" + -- make sure that the output isn't too verbose + SET LOCAL client_min_messages TO ERROR; +ERROR: current transaction is aborted, commands ignored until end of transaction block + DROP TABLE test_table_1, test_table_2; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +-- same test with the above on sequential mode should work fine +BEGIN; + + SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_reference_table +------------------------ + +(1 row) + + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_distributed_table +-------------------------- + +(1 row) + + ALTER TABLE test_table_2 ADD CONSTRAINT c_check FOREIGN KEY (value_1) REFERENCES test_table_1(id); + -- make sure that the output isn't too verbose + SET LOCAL client_min_messages TO ERROR; + DROP TABLE test_table_1, test_table_2; +COMMIT; +-- similar test with the above, but this time the order of +-- create_distributed_table and create_reference_table is +-- changed +BEGIN; + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_distributed_table +-------------------------- + +(1 row) + + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_reference_table +------------------------ + +(1 row) + + ALTER TABLE test_table_2 ADD CONSTRAINT c_check FOREIGN KEY (value_1) REFERENCES test_table_1(id); +ERROR: cannot modify table "test_table_2" because there was a parallel operation on a distributed table in the transaction +DETAIL: When there is a foreign key to a reference table, Citus needs to perform all operations over a single connection per node to ensure consistency. +HINT: Try re-running the transaction with "SET LOCAL citus.multi_shard_modify_mode TO 'sequential';" + -- make sure that the output isn't too verbose + SET LOCAL client_min_messages TO ERROR; +ERROR: current transaction is aborted, commands ignored until end of transaction block + DROP TABLE test_table_1 CASCADE; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK; +-- same test in sequential mode should succeed +BEGIN; + SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_distributed_table +-------------------------- + +(1 row) + + 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'); +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_reference_table +------------------------ + +(1 row) + + ALTER TABLE test_table_2 ADD CONSTRAINT c_check FOREIGN KEY (value_1) REFERENCES test_table_1(id); + -- make sure that the output isn't too verbose + SET LOCAL client_min_messages TO ERROR; + DROP TABLE test_table_1 CASCADE; +ROLLBACK; +-- again a very similar test, but this time +-- a parallel SELECT is already executed before +-- setting the mode to sequential should fail +BEGIN; + SELECT count(*) FROM on_update_fkey_table; + count +------- + 1001 +(1 row) + + SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; + 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'); +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 +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';" + CREATE TABLE test_table_1(id int PRIMARY KEY); +ERROR: current transaction is aborted, commands ignored until end of transaction block + SELECT create_reference_table('test_table_1'); +ERROR: current transaction is aborted, commands ignored until end of transaction block + ALTER TABLE test_table_2 ADD CONSTRAINT c_check FOREIGN KEY (value_1) REFERENCES test_table_1(id); +ERROR: current transaction is aborted, commands ignored until end of transaction block + -- make sure that the output isn't too verbose + SET LOCAL client_min_messages TO ERROR; +ERROR: current transaction is aborted, commands ignored until end of transaction block + DROP TABLE test_table_1 CASCADE; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK; +-- make sure that we cannot create hash distributed tables with +-- foreign keys to reference tables when they have data in it +BEGIN; + + 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; + 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; + 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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 +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... +DEBUG: Copied 101 rows + create_reference_table +------------------------ + +(1 row) + + 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 +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 + SET LOCAL client_min_messages TO ERROR; +ERROR: current transaction is aborted, commands ignored until end of transaction block + DROP TABLE test_table_2, test_table_1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +-- the same test with above in sequential mode would still not work +-- since COPY cannot be executed in sequential mode +BEGIN; + + SET LOCAL citus.multi_shard_modify_mode TO 'sequential'; + 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; + 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; + 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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 +NOTICE: Copying data from local table... +DEBUG: Copied 101 rows + create_reference_table +------------------------ + +(1 row) + + 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 +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 + SET LOCAL client_min_messages TO ERROR; +ERROR: current transaction is aborted, commands ignored until end of transaction block + DROP TABLE test_table_2, test_table_1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +COMMIT; +-- we should be able to execute and DML/DDL/SELECT after we've +-- switched to sequential via create_distributed_table +BEGIN; + + 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)); +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'); +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 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_reference_table +------------------------ + +(1 row) + + 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 +DEBUG: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57637 +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: schema "test_fkey_to_ref_in_tx" already exists, skipping +DETAIL: NOTICE from localhost:57638 + create_distributed_table +-------------------------- + +(1 row) + + -- and maybe some other test + 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); +DEBUG: verifying table "test_table_2" + SELECT count(*) FROM test_table_2; + count +------- + 0 +(1 row) + + SELECT count(*) FROM test_table_1; + count +------- + 0 +(1 row) + + UPDATE test_table_2 SET value_1 = 15; + -- make sure that the output isn't too verbose + SET LOCAL client_min_messages TO ERROR; + DROP TABLE test_table_2, test_table_1; +COMMIT; +RESET client_min_messages; +DROP SCHEMA test_fkey_to_ref_in_tx CASCADE; +NOTICE: drop cascades to 3 other objects +DETAIL: drop cascades to table referece_table +drop cascades to table on_update_fkey_table +drop cascades to table unrelated_dist_table +SET search_path TO public; diff --git a/src/test/regress/expected/multi_create_table_constraints.out b/src/test/regress/expected/multi_create_table_constraints.out index 364be789c..878b79085 100644 --- a/src/test/regress/expected/multi_create_table_constraints.out +++ b/src/test/regress/expected/multi_create_table_constraints.out @@ -335,12 +335,12 @@ SELECT create_distributed_table('check_example', 'partition_col', 'hash'); (1 row) \c - - - :worker_1_port -\d check_example_partition_col_key_365056 -Index "public.check_example_partition_col_key_365056" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'check_example_partition_col_key_365056'::regclass; Column | Type | Definition ---------------+---------+--------------- partition_col | integer | partition_col -unique, btree, for table "public.check_example_365056" +(1 row) SELECT "Constraint", "Definition" FROM table_checks WHERE relid='public.check_example_365056'::regclass; Constraint | Definition diff --git a/src/test/regress/expected/multi_metadata_sync.out b/src/test/regress/expected/multi_metadata_sync.out index f965f0a1f..a007a9e7e 100644 --- a/src/test/regress/expected/multi_metadata_sync.out +++ b/src/test/regress/expected/multi_metadata_sync.out @@ -282,19 +282,19 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_testing_sch col_3 | bigint | not null default nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) (3 rows) -\d mx_testing_schema.mx_test_table_col_1_key -Index "mx_testing_schema.mx_test_table_col_1_key" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_testing_schema.mx_test_table_col_1_key'::regclass; Column | Type | Definition --------+---------+------------ col_1 | integer | col_1 -unique, btree, for table "mx_testing_schema.mx_test_table" +(1 row) -\d mx_testing_schema.mx_index -Index "mx_testing_schema.mx_index" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_testing_schema.mx_index'::regclass; Column | Type | Definition --------+------+------------ col_2 | text | col_2 -btree, for table "mx_testing_schema.mx_test_table" +(1 row) -- Check that pg_dist_colocation is not synced SELECT * FROM pg_dist_colocation ORDER BY colocationid; @@ -421,19 +421,19 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_testing_sch col_3 | bigint | not null default nextval('mx_testing_schema.mx_test_table_col_3_seq'::regclass) (3 rows) -\d mx_testing_schema.mx_test_table_col_1_key -Index "mx_testing_schema.mx_test_table_col_1_key" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_testing_schema.mx_test_table_col_1_key'::regclass; Column | Type | Definition --------+---------+------------ col_1 | integer | col_1 -unique, btree, for table "mx_testing_schema.mx_test_table" +(1 row) -\d mx_testing_schema.mx_index -Index "mx_testing_schema.mx_index" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_testing_schema.mx_index'::regclass; Column | Type | Definition --------+------+------------ col_2 | text | col_2 -btree, for table "mx_testing_schema.mx_test_table" +(1 row) SELECT count(*) FROM pg_trigger WHERE tgrelid='mx_testing_schema.mx_test_table'::regclass; count @@ -560,19 +560,19 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_test_schema col2 | text | (2 rows) -\d mx_test_schema_1.mx_table_1_col1_key -Index "mx_test_schema_1.mx_table_1_col1_key" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_1.mx_table_1_col1_key'::regclass; Column | Type | Definition --------+---------+------------ col1 | integer | col1 -unique, btree, for table "mx_test_schema_1.mx_table_1" +(1 row) -\d mx_test_schema_1.mx_index_1 -Index "mx_test_schema_1.mx_index_1" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_1.mx_index_1'::regclass; Column | Type | Definition --------+---------+------------ col1 | integer | col1 -btree, for table "mx_test_schema_1.mx_table_1" +(1 row) SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_test_schema_2.mx_table_2'::regclass; Column | Type | Modifiers @@ -581,12 +581,12 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_test_schema col2 | text | (2 rows) -\d mx_test_schema_2.mx_index_2 -Index "mx_test_schema_2.mx_index_2" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_2.mx_index_2'::regclass; Column | Type | Definition --------+------+------------ col2 | text | col2 -btree, for table "mx_test_schema_2.mx_table_2" +(1 row) SELECT "Constraint", "Definition" FROM table_fkeys WHERE relid='mx_test_schema_2.mx_table_2'::regclass; Constraint | Definition @@ -722,26 +722,30 @@ SET client_min_messages TO 'ERROR'; CREATE INDEX mx_index_3 ON mx_test_schema_2.mx_table_2 USING hash (col1); ALTER TABLE mx_test_schema_2.mx_table_2 ADD CONSTRAINT mx_table_2_col1_key UNIQUE (col1); \c - - - :worker_1_port -\d mx_test_schema_2.mx_index_3 -Index "mx_test_schema_2.mx_index_3" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_2.mx_index_3'::regclass; Column | Type | Definition --------+---------+------------ col1 | integer | col1 -hash, for table "mx_test_schema_2.mx_table_2" +(1 row) -\d mx_test_schema_2.mx_table_2_col1_key -Index "mx_test_schema_2.mx_table_2_col1_key" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_2.mx_table_2_col1_key'::regclass; Column | Type | Definition --------+---------+------------ col1 | integer | col1 -unique, btree, for table "mx_test_schema_2.mx_table_2" +(1 row) -- Check that DROP INDEX statement is propagated \c - - - :master_port SET citus.multi_shard_commit_protocol TO '2pc'; DROP INDEX mx_test_schema_2.mx_index_3; \c - - - :worker_1_port -\d mx_test_schema_2.mx_index_3 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_2.mx_index_3'::regclass; +ERROR: relation "mx_test_schema_2.mx_index_3" does not exist +LINE 2: relid = 'mx_test_schema_2.mx_index_3'::regclass; + ^ -- Check that ALTER TABLE statements are propagated \c - - - :master_port SET citus.multi_shard_commit_protocol TO '2pc'; @@ -1293,12 +1297,12 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ref'::regcl col_3 | numeric | default 0 (3 rows) -\d mx_ref_index - Index "public.mx_ref_index" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_ref_index'::regclass; Column | Type | Definition --------+---------+------------ col_1 | integer | col_1 -btree, for table "public.mx_ref" +(1 row) \c - - - :worker_1_port SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ref'::regclass; @@ -1309,20 +1313,28 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ref'::regcl col_3 | numeric | default 0 (3 rows) -\d mx_ref_index - Index "public.mx_ref_index" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_ref_index'::regclass; Column | Type | Definition --------+---------+------------ col_1 | integer | col_1 -btree, for table "public.mx_ref" +(1 row) -- Check that metada is cleaned successfully upon drop table \c - - - :master_port DROP TABLE mx_ref; -\d mx_ref +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_ref_index'::regclass; +ERROR: relation "mx_ref_index" does not exist +LINE 2: relid = 'mx_ref_index'::regclass; + ^ \c - - - :worker_1_port -\d mx_ref +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_ref_index'::regclass; +ERROR: relation "mx_ref_index" does not exist +LINE 2: relid = 'mx_ref_index'::regclass; + ^ SELECT * FROM pg_dist_shard WHERE shardid=:ref_table_shardid; logicalrelid | shardid | shardstorage | shardminvalue | shardmaxvalue --------------+---------+--------------+---------------+--------------- diff --git a/src/test/regress/expected/multi_multiuser.out b/src/test/regress/expected/multi_multiuser.out index 50d968271..d040f3e3a 100644 --- a/src/test/regress/expected/multi_multiuser.out +++ b/src/test/regress/expected/multi_multiuser.out @@ -212,7 +212,24 @@ ERROR: permission denied for table test ABORT; SELECT * FROM citus_stat_statements_reset(); ERROR: permission denied for function citus_stat_statements_reset +-- table owner should be the same on the shards, even when distributing the table as superuser +SET ROLE full_access; +CREATE TABLE my_table (id integer, val integer); RESET ROLE; +SELECT create_distributed_table('my_table', 'id'); + create_distributed_table +-------------------------- + +(1 row) + +SELECT result FROM run_command_on_workers($$SELECT tableowner FROM pg_tables WHERE tablename LIKE 'my_table_%' LIMIT 1$$); + result +------------- + full_access + full_access +(2 rows) + +DROP TABLE my_table; DROP TABLE test; DROP USER full_access; DROP USER read_access; diff --git a/src/test/regress/expected/multi_mx_ddl.out b/src/test/regress/expected/multi_mx_ddl.out index cd82a5d38..d423d0290 100644 --- a/src/test/regress/expected/multi_mx_ddl.out +++ b/src/test/regress/expected/multi_mx_ddl.out @@ -36,18 +36,13 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table': version | integer | not null default 1 (3 rows) -\d ddl_test*_index -Index "public.ddl_test_concurrent_index" - Column | Type | Definition ---------+---------+------------ - value | integer | value -btree, for table "public.mx_ddl_table" - - Index "public.ddl_test_index" - Column | Type | Definition ---------+---------+------------ - value | integer | value -btree, for table "public.mx_ddl_table" +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'ddl_test%_index'; + relname | Column | Type | Definition +---------------------------+--------+---------+------------ + ddl_test_index | value | integer | value + ddl_test_concurrent_index | value | integer | value +(2 rows) \c - - - :worker_1_port -- make sure we don't break the following tests by hiding the shard names @@ -60,18 +55,13 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table': version | integer | not null default 1 (3 rows) -\d ddl_test*_index -Index "public.ddl_test_concurrent_index" - Column | Type | Definition ---------+---------+------------ - value | integer | value -btree, for table "public.mx_ddl_table" - - Index "public.ddl_test_index" - Column | Type | Definition ---------+---------+------------ - value | integer | value -btree, for table "public.mx_ddl_table" +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'ddl_test%_index'; + relname | Column | Type | Definition +---------------------------+--------+---------+------------ + ddl_test_index | value | integer | value + ddl_test_concurrent_index | value | integer | value +(2 rows) SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table_1220088'::regclass; Column | Type | Modifiers @@ -81,18 +71,13 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table_1 version | integer | not null default 1 (3 rows) -\d ddl_test*_index_1220088 -Index "public.ddl_test_concurrent_index_1220088" - Column | Type | Definition ---------+---------+------------ - value | integer | value -btree, for table "public.mx_ddl_table_1220088" - -Index "public.ddl_test_index_1220088" - Column | Type | Definition ---------+---------+------------ - value | integer | value -btree, for table "public.mx_ddl_table_1220088" +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'ddl_test%_index_1220088'; + relname | Column | Type | Definition +-----------------------------------+--------+---------+------------ + ddl_test_index_1220088 | value | integer | value + ddl_test_concurrent_index_1220088 | value | integer | value +(2 rows) \c - - - :worker_2_port -- make sure we don't break the following tests by hiding the shard names @@ -105,18 +90,13 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table': version | integer | not null default 1 (3 rows) -\d ddl_test*_index -Index "public.ddl_test_concurrent_index" - Column | Type | Definition ---------+---------+------------ - value | integer | value -btree, for table "public.mx_ddl_table" - - Index "public.ddl_test_index" - Column | Type | Definition ---------+---------+------------ - value | integer | value -btree, for table "public.mx_ddl_table" +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'ddl_test%_index'; + relname | Column | Type | Definition +---------------------------+--------+---------+------------ + ddl_test_index | value | integer | value + ddl_test_concurrent_index | value | integer | value +(2 rows) SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table_1220089'::regclass; Column | Type | Modifiers @@ -126,18 +106,13 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table_1 version | integer | not null default 1 (3 rows) -\d ddl_test*_index_1220089 -Index "public.ddl_test_concurrent_index_1220089" - Column | Type | Definition ---------+---------+------------ - value | integer | value -btree, for table "public.mx_ddl_table_1220089" - -Index "public.ddl_test_index_1220089" - Column | Type | Definition ---------+---------+------------ - value | integer | value -btree, for table "public.mx_ddl_table_1220089" +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'ddl_test%_index_1220089'; + relname | Column | Type | Definition +-----------------------------------+--------+---------+------------ + ddl_test_index_1220089 | value | integer | value + ddl_test_concurrent_index_1220089 | value | integer | value +(2 rows) INSERT INTO mx_ddl_table VALUES (37, 78, 2); INSERT INTO mx_ddl_table VALUES (38, 78); diff --git a/src/test/regress/expected/multi_mx_metadata.out b/src/test/regress/expected/multi_mx_metadata.out index 83ad59c42..6ad40ebc8 100644 --- a/src/test/regress/expected/multi_mx_metadata.out +++ b/src/test/regress/expected/multi_mx_metadata.out @@ -53,19 +53,19 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='distributed_mx value | jsonb | (2 rows) -\d distributed_mx_table_pkey -Index "public.distributed_mx_table_pkey" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'distributed_mx_table_pkey'::regclass; Column | Type | Definition --------+------+------------ key | text | key -primary key, btree, for table "public.distributed_mx_table" +(1 row) -\d distributed_mx_table_value_idx -Index "public.distributed_mx_table_value_idx" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'distributed_mx_table_value_idx'::regclass; Column | Type | Definition --------+------+------------ value | text | value -gin, for table "public.distributed_mx_table" +(1 row) SELECT repmodel FROM pg_dist_partition WHERE logicalrelid = 'distributed_mx_table'::regclass; @@ -89,19 +89,19 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='distributed_mx value | jsonb | (2 rows) -\d distributed_mx_table_pkey -Index "public.distributed_mx_table_pkey" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'distributed_mx_table_pkey'::regclass; Column | Type | Definition --------+------+------------ key | text | key -primary key, btree, for table "public.distributed_mx_table" +(1 row) -\d distributed_mx_table_value_idx -Index "public.distributed_mx_table_value_idx" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'distributed_mx_table_value_idx'::regclass; Column | Type | Definition --------+------+------------ value | text | value -gin, for table "public.distributed_mx_table" +(1 row) SELECT repmodel FROM pg_dist_partition WHERE logicalrelid = 'distributed_mx_table'::regclass; diff --git a/src/test/regress/expected/multi_name_lengths.out b/src/test/regress/expected/multi_name_lengths.out index 1e20b564a..08949516f 100644 --- a/src/test/regress/expected/multi_name_lengths.out +++ b/src/test/regress/expected/multi_name_lengths.out @@ -117,18 +117,13 @@ ERROR: renaming constraints belonging to distributed tables is currently unsupp -- Verify that CREATE INDEX on already distributed table has proper shard names. CREATE INDEX tmp_idx_12345678901234567890123456789012345678901234567890 ON name_lengths(col2); \c - - - :worker_1_port -\d tmp_idx_* -Index "public.tmp_idx_123456789012345678901234567890123456789_5e470afa_225002" - Column | Type | Definition ---------+---------+------------ - col2 | integer | col2 -btree, for table "public.name_lengths_225002" - -Index "public.tmp_idx_123456789012345678901234567890123456789_5e470afa_225003" - Column | Type | Definition ---------+---------+------------ - col2 | integer | col2 -btree, for table "public.name_lengths_225003" +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'tmp_idx_%'; + relname | Column | Type | Definition +-----------------------------------------------------------------+--------+---------+------------ + tmp_idx_123456789012345678901234567890123456789_5e470afa_225003 | col2 | integer | col2 + tmp_idx_123456789012345678901234567890123456789_5e470afa_225002 | col2 | integer | col2 +(2 rows) \c - - - :master_port -- Verify that a new index name > 63 characters is auto-truncated @@ -136,30 +131,15 @@ btree, for table "public.name_lengths_225003" CREATE INDEX tmp_idx_123456789012345678901234567890123456789012345678901234567890 ON name_lengths(col2); NOTICE: identifier "tmp_idx_123456789012345678901234567890123456789012345678901234567890" will be truncated to "tmp_idx_1234567890123456789012345678901234567890123456789012345" \c - - - :worker_1_port -\d tmp_idx_* -Index "public.tmp_idx_123456789012345678901234567890123456789_599636aa_225002" - Column | Type | Definition ---------+---------+------------ - col2 | integer | col2 -btree, for table "public.name_lengths_225002" - -Index "public.tmp_idx_123456789012345678901234567890123456789_599636aa_225003" - Column | Type | Definition ---------+---------+------------ - col2 | integer | col2 -btree, for table "public.name_lengths_225003" - -Index "public.tmp_idx_123456789012345678901234567890123456789_5e470afa_225002" - Column | Type | Definition ---------+---------+------------ - col2 | integer | col2 -btree, for table "public.name_lengths_225002" - -Index "public.tmp_idx_123456789012345678901234567890123456789_5e470afa_225003" - Column | Type | Definition ---------+---------+------------ - col2 | integer | col2 -btree, for table "public.name_lengths_225003" +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'tmp_idx_%'; + relname | Column | Type | Definition +-----------------------------------------------------------------+--------+---------+------------ + tmp_idx_123456789012345678901234567890123456789_5e470afa_225003 | col2 | integer | col2 + tmp_idx_123456789012345678901234567890123456789_5e470afa_225002 | col2 | integer | col2 + tmp_idx_123456789012345678901234567890123456789_599636aa_225003 | col2 | integer | col2 + tmp_idx_123456789012345678901234567890123456789_599636aa_225002 | col2 | integer | col2 +(4 rows) \c - - - :master_port SET citus.shard_count TO 2; diff --git a/src/test/regress/expected/multi_partitioning.out b/src/test/regress/expected/multi_partitioning.out index 173755136..c0bb19567 100644 --- a/src/test/regress/expected/multi_partitioning.out +++ b/src/test/regress/expected/multi_partitioning.out @@ -1123,13 +1123,11 @@ SELECT relation::regclass, locktype, mode FROM pg_locks WHERE relation::regclass partitioning_locks | relation | AccessShareLock partitioning_locks_2009 | relation | AccessExclusiveLock partitioning_locks_2009 | relation | AccessShareLock - partitioning_locks_2009 | relation | RowExclusiveLock partitioning_locks_2009 | relation | ShareLock partitioning_locks_2010 | relation | AccessExclusiveLock partitioning_locks_2010 | relation | AccessShareLock - partitioning_locks_2010 | relation | RowExclusiveLock partitioning_locks_2010 | relation | ShareLock -(10 rows) +(8 rows) COMMIT; -- test shard resource locks with master_modify_multiple_shards diff --git a/src/test/regress/expected/multi_prepare_sql.out b/src/test/regress/expected/multi_prepare_sql.out index 53d9d49f5..5224d6ab4 100644 --- a/src/test/regress/expected/multi_prepare_sql.out +++ b/src/test/regress/expected/multi_prepare_sql.out @@ -332,8 +332,10 @@ EXECUTE prepared_partition_column_insert(3); EXECUTE prepared_partition_column_insert(4); EXECUTE prepared_partition_column_insert(5); EXECUTE prepared_partition_column_insert(6); +-- suppress notice message caused by DROP ... CASCADE to prevent pg version difference +SET client_min_messages TO 'WARNING'; DROP TYPE test_composite_type CASCADE; -NOTICE: drop cascades to table router_executor_table column stats +RESET client_min_messages; -- test router executor with prepare statements CREATE TABLE prepare_table ( key int, diff --git a/src/test/regress/expected/multi_reference_table.out b/src/test/regress/expected/multi_reference_table.out index e744feb7d..471268235 100644 --- a/src/test/regress/expected/multi_reference_table.out +++ b/src/test/regress/expected/multi_reference_table.out @@ -1336,13 +1336,13 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='reference_sche value_5 | double precision | (4 rows) -\d reference_schema.reference_index_2 -Index "reference_schema.reference_index_2" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'reference_schema.reference_index_2'::regclass; Column | Type | Definition ---------+------------------+------------ value_2 | double precision | value_2 value_3 | text | value_3 -btree, for table "reference_schema.reference_table_ddl" +(2 rows) -- also to the shard placements \c - - - :worker_1_port @@ -1355,13 +1355,13 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='reference_sche value_5 | double precision | (4 rows) -\d reference_schema.reference_index_2_1250019 -Index "reference_schema.reference_index_2_1250019" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'reference_schema.reference_index_2_1250019'::regclass; Column | Type | Definition ---------+------------------+------------ value_2 | double precision | value_2 value_3 | text | value_3 -btree, for table "reference_schema.reference_table_ddl_1250019" +(2 rows) \c - - - :master_port DROP INDEX reference_schema.reference_index_2; diff --git a/src/test/regress/expected/multi_schema_support.out b/src/test/regress/expected/multi_schema_support.out index a7d692c1d..6ac73508b 100644 --- a/src/test/regress/expected/multi_schema_support.out +++ b/src/test/regress/expected/multi_schema_support.out @@ -687,20 +687,20 @@ SET search_path TO public; -- CREATE index CREATE INDEX index1 ON test_schema_support.nation_hash(n_name); --verify INDEX is created -\d test_schema_support.index1 - Index "test_schema_support.index1" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'test_schema_support.index1'::regclass; Column | Type | Definition --------+---------------+------------ n_name | character(25) | n_name -btree, for table "test_schema_support.nation_hash" +(1 row) \c - - - :worker_1_port -\d test_schema_support.index1_1190003 -Index "test_schema_support.index1_1190003" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'test_schema_support.index1_1190003'::regclass; Column | Type | Definition --------+---------------+------------ n_name | character(25) | n_name -btree, for table "test_schema_support.nation_hash_1190003" +(1 row) \c - - - :master_port -- DROP index @@ -715,20 +715,20 @@ SET search_path TO test_schema_support; -- CREATE index CREATE INDEX index1 ON nation_hash(n_name); --verify INDEX is created -\d test_schema_support.index1 - Index "test_schema_support.index1" +SELECT "Column", "Type", "Definition" FROM public.index_attrs WHERE + relid = 'test_schema_support.index1'::regclass; Column | Type | Definition --------+---------------+------------ n_name | character(25) | n_name -btree, for table "test_schema_support.nation_hash" +(1 row) \c - - - :worker_1_port -\d test_schema_support.index1_1190003 -Index "test_schema_support.index1_1190003" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'test_schema_support.index1_1190003'::regclass; Column | Type | Definition --------+---------------+------------ n_name | character(25) | n_name -btree, for table "test_schema_support.nation_hash_1190003" +(1 row) \c - - - :master_port -- DROP index diff --git a/src/test/regress/expected/multi_test_helpers.out b/src/test/regress/expected/multi_test_helpers.out index 7f8b92503..6ffe7eae8 100644 --- a/src/test/regress/expected/multi_test_helpers.out +++ b/src/test/regress/expected/multi_test_helpers.out @@ -77,6 +77,31 @@ FROM information_schema.check_constraints cc, WHERE cc.constraint_schema = ccu.constraint_schema AND cc.constraint_name = ccu.constraint_name ORDER BY cc.constraint_name ASC; + +CREATE VIEW index_attrs AS +WITH indexoid AS ( + SELECT c.oid, + n.nspname, + c.relname + FROM pg_catalog.pg_class c + LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace + WHERE pg_catalog.pg_table_is_visible(c.oid) + ORDER BY 2, 3 +) +SELECT + indexoid.nspname AS "nspname", + indexoid.relname AS "relname", + a.attrelid AS "relid", + a.attname AS "Column", + pg_catalog.format_type(a.atttypid, a.atttypmod) AS "Type", + pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS "Definition" +FROM pg_catalog.pg_attribute a +LEFT JOIN indexoid ON (a.attrelid = indexoid.oid) +WHERE true + AND a.attnum > 0 + AND NOT a.attisdropped +ORDER BY a.attrelid, a.attnum; + $desc_views$ ); run_command_on_master_and_workers diff --git a/src/test/regress/expected/multi_unsupported_worker_operations.out b/src/test/regress/expected/multi_unsupported_worker_operations.out index 3c7c547a6..5a0b86c46 100644 --- a/src/test/regress/expected/multi_unsupported_worker_operations.out +++ b/src/test/regress/expected/multi_unsupported_worker_operations.out @@ -392,8 +392,10 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.mx_tabl col_3 | bigint | not null default nextval('mx_table_col_3_seq'::regclass) (3 rows) +-- suppress notice message caused by DROP ... CASCADE to prevent pg version difference +SET client_min_messages TO 'WARNING'; DROP SEQUENCE mx_table_col_3_seq CASCADE; -NOTICE: drop cascades to default for table mx_table column col_3 +RESET client_min_messages; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.mx_table'::regclass; Column | Type | Modifiers --------+---------+----------- diff --git a/src/test/regress/expected/multi_utilities.out b/src/test/regress/expected/multi_utilities.out index c6f8e645d..76ba8970b 100644 --- a/src/test/regress/expected/multi_utilities.out +++ b/src/test/regress/expected/multi_utilities.out @@ -10,16 +10,12 @@ SELECT substring(:'server_version', '\d+')::int > 10 as version_above_ten; -- =================================================================== -- test utility statement functionality -- =================================================================== +SET citus.shard_count TO 2; +SET citus.shard_replication_factor TO 1; CREATE TABLE sharded_table ( name text, id bigint ); -SELECT master_create_distributed_table('sharded_table', 'id', 'hash'); - master_create_distributed_table ---------------------------------- - -(1 row) - -SELECT master_create_worker_shards('sharded_table', 2, 1); - master_create_worker_shards ------------------------------ +SELECT create_distributed_table('sharded_table', 'id', 'hash'); + create_distributed_table +-------------------------- (1 row) @@ -167,16 +163,12 @@ ERROR: no locks specified DROP TABLE sharded_table; -- VACUUM tests -- create a table with a single shard (for convenience) +SET citus.shard_count TO 1; +SET citus.shard_replication_factor TO 2; CREATE TABLE dustbunnies (id integer, name text, age integer); -SELECT master_create_distributed_table('dustbunnies', 'id', 'hash'); - master_create_distributed_table ---------------------------------- - -(1 row) - -SELECT master_create_worker_shards('dustbunnies', 1, 2); - master_create_worker_shards ------------------------------ +SELECT create_distributed_table('dustbunnies', 'id', 'hash'); + create_distributed_table +-------------------------- (1 row) diff --git a/src/test/regress/expected/multi_view.out b/src/test/regress/expected/multi_view.out index 9fab86fd7..e467a8900 100644 --- a/src/test/regress/expected/multi_view.out +++ b/src/test/regress/expected/multi_view.out @@ -182,8 +182,8 @@ SELECT o_orderkey, l_linenumber FROM priority_orders left join air_shipped_linei -- it passes planning, fails at execution stage SET client_min_messages TO DEBUG1; SELECT * FROM priority_orders JOIN air_shipped_lineitems ON (o_custkey = l_suppkey) ORDER BY o_orderkey DESC, o_custkey DESC, o_orderpriority DESC LIMIT 5; -DEBUG: generating subplan 22_1 for subquery SELECT lineitem_hash_part.l_orderkey, lineitem_hash_part.l_partkey, lineitem_hash_part.l_suppkey, lineitem_hash_part.l_linenumber, lineitem_hash_part.l_quantity, lineitem_hash_part.l_extendedprice, lineitem_hash_part.l_discount, lineitem_hash_part.l_tax, lineitem_hash_part.l_returnflag, lineitem_hash_part.l_linestatus, lineitem_hash_part.l_shipdate, lineitem_hash_part.l_commitdate, lineitem_hash_part.l_receiptdate, lineitem_hash_part.l_shipinstruct, lineitem_hash_part.l_shipmode, lineitem_hash_part.l_comment FROM public.lineitem_hash_part WHERE (lineitem_hash_part.l_shipmode = 'AIR'::bpchar) -DEBUG: Plan 22 query after replacing subqueries and CTEs: SELECT priority_orders.o_orderkey, priority_orders.o_custkey, priority_orders.o_orderstatus, priority_orders.o_totalprice, priority_orders.o_orderdate, priority_orders.o_orderpriority, priority_orders.o_clerk, priority_orders.o_shippriority, priority_orders.o_comment, air_shipped_lineitems.l_orderkey, air_shipped_lineitems.l_partkey, air_shipped_lineitems.l_suppkey, air_shipped_lineitems.l_linenumber, air_shipped_lineitems.l_quantity, air_shipped_lineitems.l_extendedprice, air_shipped_lineitems.l_discount, air_shipped_lineitems.l_tax, air_shipped_lineitems.l_returnflag, air_shipped_lineitems.l_linestatus, air_shipped_lineitems.l_shipdate, air_shipped_lineitems.l_commitdate, air_shipped_lineitems.l_receiptdate, air_shipped_lineitems.l_shipinstruct, air_shipped_lineitems.l_shipmode, air_shipped_lineitems.l_comment FROM ((SELECT orders_hash_part.o_orderkey, orders_hash_part.o_custkey, orders_hash_part.o_orderstatus, orders_hash_part.o_totalprice, orders_hash_part.o_orderdate, orders_hash_part.o_orderpriority, orders_hash_part.o_clerk, orders_hash_part.o_shippriority, orders_hash_part.o_comment FROM public.orders_hash_part WHERE (orders_hash_part.o_orderpriority < '3-MEDIUM'::bpchar)) priority_orders JOIN (SELECT intermediate_result.l_orderkey, intermediate_result.l_partkey, intermediate_result.l_suppkey, intermediate_result.l_linenumber, intermediate_result.l_quantity, intermediate_result.l_extendedprice, intermediate_result.l_discount, intermediate_result.l_tax, intermediate_result.l_returnflag, intermediate_result.l_linestatus, intermediate_result.l_shipdate, intermediate_result.l_commitdate, intermediate_result.l_receiptdate, intermediate_result.l_shipinstruct, intermediate_result.l_shipmode, intermediate_result.l_comment FROM read_intermediate_result('22_1'::text, 'binary'::citus_copy_format) intermediate_result(l_orderkey bigint, l_partkey integer, l_suppkey integer, l_linenumber integer, l_quantity numeric(15,2), l_extendedprice numeric(15,2), l_discount numeric(15,2), l_tax numeric(15,2), l_returnflag character(1), l_linestatus character(1), l_shipdate date, l_commitdate date, l_receiptdate date, l_shipinstruct character(25), l_shipmode character(10), l_comment character varying(44))) air_shipped_lineitems ON ((priority_orders.o_custkey = air_shipped_lineitems.l_suppkey))) ORDER BY priority_orders.o_orderkey DESC, priority_orders.o_custkey DESC, priority_orders.o_orderpriority DESC LIMIT 5 +DEBUG: generating subplan 22_1 for subquery SELECT lineitem_hash_part.l_orderkey, lineitem_hash_part.l_partkey, lineitem_hash_part.l_suppkey, lineitem_hash_part.l_linenumber, lineitem_hash_part.l_quantity, lineitem_hash_part.l_extendedprice, lineitem_hash_part.l_discount, lineitem_hash_part.l_tax, lineitem_hash_part.l_returnflag, lineitem_hash_part.l_linestatus, lineitem_hash_part.l_shipdate, lineitem_hash_part.l_commitdate, lineitem_hash_part.l_receiptdate, lineitem_hash_part.l_shipinstruct, lineitem_hash_part.l_shipmode, lineitem_hash_part.l_comment FROM public.lineitem_hash_part WHERE (lineitem_hash_part.l_shipmode OPERATOR(pg_catalog.=) 'AIR'::bpchar) +DEBUG: Plan 22 query after replacing subqueries and CTEs: SELECT priority_orders.o_orderkey, priority_orders.o_custkey, priority_orders.o_orderstatus, priority_orders.o_totalprice, priority_orders.o_orderdate, priority_orders.o_orderpriority, priority_orders.o_clerk, priority_orders.o_shippriority, priority_orders.o_comment, air_shipped_lineitems.l_orderkey, air_shipped_lineitems.l_partkey, air_shipped_lineitems.l_suppkey, air_shipped_lineitems.l_linenumber, air_shipped_lineitems.l_quantity, air_shipped_lineitems.l_extendedprice, air_shipped_lineitems.l_discount, air_shipped_lineitems.l_tax, air_shipped_lineitems.l_returnflag, air_shipped_lineitems.l_linestatus, air_shipped_lineitems.l_shipdate, air_shipped_lineitems.l_commitdate, air_shipped_lineitems.l_receiptdate, air_shipped_lineitems.l_shipinstruct, air_shipped_lineitems.l_shipmode, air_shipped_lineitems.l_comment FROM ((SELECT orders_hash_part.o_orderkey, orders_hash_part.o_custkey, orders_hash_part.o_orderstatus, orders_hash_part.o_totalprice, orders_hash_part.o_orderdate, orders_hash_part.o_orderpriority, orders_hash_part.o_clerk, orders_hash_part.o_shippriority, orders_hash_part.o_comment FROM public.orders_hash_part WHERE (orders_hash_part.o_orderpriority OPERATOR(pg_catalog.<) '3-MEDIUM'::bpchar)) priority_orders JOIN (SELECT intermediate_result.l_orderkey, intermediate_result.l_partkey, intermediate_result.l_suppkey, intermediate_result.l_linenumber, intermediate_result.l_quantity, intermediate_result.l_extendedprice, intermediate_result.l_discount, intermediate_result.l_tax, intermediate_result.l_returnflag, intermediate_result.l_linestatus, intermediate_result.l_shipdate, intermediate_result.l_commitdate, intermediate_result.l_receiptdate, intermediate_result.l_shipinstruct, intermediate_result.l_shipmode, intermediate_result.l_comment FROM read_intermediate_result('22_1'::text, 'binary'::citus_copy_format) intermediate_result(l_orderkey bigint, l_partkey integer, l_suppkey integer, l_linenumber integer, l_quantity numeric(15,2), l_extendedprice numeric(15,2), l_discount numeric(15,2), l_tax numeric(15,2), l_returnflag character(1), l_linestatus character(1), l_shipdate date, l_commitdate date, l_receiptdate date, l_shipinstruct character(25), l_shipmode character(10), l_comment character varying(44))) air_shipped_lineitems ON ((priority_orders.o_custkey OPERATOR(pg_catalog.=) air_shipped_lineitems.l_suppkey))) ORDER BY priority_orders.o_orderkey DESC, priority_orders.o_custkey DESC, priority_orders.o_orderpriority DESC LIMIT 5 DEBUG: push down of limit count: 5 o_orderkey | o_custkey | o_orderstatus | o_totalprice | o_orderdate | o_orderpriority | o_clerk | o_shippriority | o_comment | l_orderkey | l_partkey | l_suppkey | l_linenumber | l_quantity | l_extendedprice | l_discount | l_tax | l_returnflag | l_linestatus | l_shipdate | l_commitdate | l_receiptdate | l_shipinstruct | l_shipmode | l_comment ------------+-----------+---------------+--------------+-------------+-----------------+-----------------+----------------+-------------------------------------------------------+------------+-----------+-----------+--------------+------------+-----------------+------------+-------+--------------+--------------+------------+--------------+---------------+---------------------------+------------+------------------------------------------- diff --git a/src/test/regress/expected/relation_access_tracking.out b/src/test/regress/expected/relation_access_tracking.out index d9a05ac04..76c94b192 100644 --- a/src/test/regress/expected/relation_access_tracking.out +++ b/src/test/regress/expected/relation_access_tracking.out @@ -2,10 +2,10 @@ --- tests around access tracking within transaction blocks --- SHOW server_version \gset -SELECT substring(:'server_version', '\d+')::int AS server_version; - server_version ----------------- - 10 +SELECT substring(:'server_version', '\d+')::int >= 10 AS version_ten_or_above; + version_ten_or_above +---------------------- + t (1 row) CREATE SCHEMA access_tracking; diff --git a/src/test/regress/expected/relation_access_tracking_0.out b/src/test/regress/expected/relation_access_tracking_0.out index 1d5f5e6af..b9cc53355 100644 --- a/src/test/regress/expected/relation_access_tracking_0.out +++ b/src/test/regress/expected/relation_access_tracking_0.out @@ -2,10 +2,10 @@ --- tests around access tracking within transaction blocks --- SHOW server_version \gset -SELECT substring(:'server_version', '\d+')::int AS server_version; - server_version ----------------- - 9 +SELECT substring(:'server_version', '\d+')::int >= 10 AS version_ten_or_above; + version_ten_or_above +---------------------- + f (1 row) CREATE SCHEMA access_tracking; diff --git a/src/test/regress/input/multi_alter_table_statements.source b/src/test/regress/input/multi_alter_table_statements.source index 6387f700d..0189ba966 100644 --- a/src/test/regress/input/multi_alter_table_statements.source +++ b/src/test/regress/input/multi_alter_table_statements.source @@ -193,7 +193,8 @@ ALTER TABLE lineitem_alter ADD COLUMN first integer; COMMIT; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass; -\d temp_index_2 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'temp_index_2'::regclass; ALTER TABLE lineitem_alter DROP COLUMN first; DROP INDEX temp_index_2; @@ -470,7 +471,10 @@ SELECT create_distributed_table('sequence_deadlock_test', 'a'); BEGIN; ALTER TABLE sequence_deadlock_test ADD COLUMN c int; +-- suppress notice message caused by DROP ... CASCADE to prevent pg version difference +SET client_min_messages TO 'WARNING'; DROP SEQUENCE sequence_deadlock_test_b_seq CASCADE; +RESET client_min_messages; END; DROP TABLE sequence_deadlock_test; diff --git a/src/test/regress/output/multi_alter_table_statements.source b/src/test/regress/output/multi_alter_table_statements.source index 702805e68..1975ddf87 100644 --- a/src/test/regress/output/multi_alter_table_statements.source +++ b/src/test/regress/output/multi_alter_table_statements.source @@ -479,12 +479,12 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineite first | integer | (18 rows) -\d temp_index_2 - Index "public.temp_index_2" +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'temp_index_2'::regclass; Column | Type | Definition ------------+--------+------------ l_orderkey | bigint | l_orderkey -btree, for table "public.lineitem_alter" +(1 row) ALTER TABLE lineitem_alter DROP COLUMN first; DROP INDEX temp_index_2; @@ -960,8 +960,10 @@ SELECT create_distributed_table('sequence_deadlock_test', 'a'); BEGIN; ALTER TABLE sequence_deadlock_test ADD COLUMN c int; +-- suppress notice message caused by DROP ... CASCADE to prevent pg version difference +SET client_min_messages TO 'WARNING'; DROP SEQUENCE sequence_deadlock_test_b_seq CASCADE; -NOTICE: drop cascades to default for table sequence_deadlock_test column b +RESET client_min_messages; END; DROP TABLE sequence_deadlock_test; -- verify enable/disable trigger all works diff --git a/src/test/regress/sql/foreign_key_restriction_enforcement.sql b/src/test/regress/sql/foreign_key_restriction_enforcement.sql index 20d13b282..fb0f9030c 100644 --- a/src/test/regress/sql/foreign_key_restriction_enforcement.sql +++ b/src/test/regress/sql/foreign_key_restriction_enforcement.sql @@ -3,6 +3,8 @@ -- there is foreign key relation between reference -- tables and distributed tables -- +SHOW server_version \gset +SELECT substring(:'server_version', '\d+')::int > 10 AS version_above_ten; CREATE SCHEMA test_fkey_to_ref_in_tx; SET search_path TO 'test_fkey_to_ref_in_tx'; diff --git a/src/test/regress/sql/multi_create_table_constraints.sql b/src/test/regress/sql/multi_create_table_constraints.sql index 4ab5f850c..e04024348 100644 --- a/src/test/regress/sql/multi_create_table_constraints.sql +++ b/src/test/regress/sql/multi_create_table_constraints.sql @@ -225,7 +225,8 @@ CREATE TABLE check_example ); SELECT create_distributed_table('check_example', 'partition_col', 'hash'); \c - - - :worker_1_port -\d check_example_partition_col_key_365056 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'check_example_partition_col_key_365056'::regclass; SELECT "Constraint", "Definition" FROM table_checks WHERE relid='public.check_example_365056'::regclass; \c - - - :master_port diff --git a/src/test/regress/sql/multi_metadata_sync.sql b/src/test/regress/sql/multi_metadata_sync.sql index 091c7d916..25ec2f101 100644 --- a/src/test/regress/sql/multi_metadata_sync.sql +++ b/src/test/regress/sql/multi_metadata_sync.sql @@ -90,8 +90,10 @@ SELECT * FROM pg_dist_partition ORDER BY logicalrelid; SELECT * FROM pg_dist_shard ORDER BY shardid; SELECT * FROM pg_dist_shard_placement ORDER BY shardid, nodename, nodeport; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_testing_schema.mx_test_table'::regclass; -\d mx_testing_schema.mx_test_table_col_1_key -\d mx_testing_schema.mx_index +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_testing_schema.mx_test_table_col_1_key'::regclass; +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_testing_schema.mx_index'::regclass; -- Check that pg_dist_colocation is not synced SELECT * FROM pg_dist_colocation ORDER BY colocationid; @@ -140,8 +142,10 @@ SELECT * FROM pg_dist_partition ORDER BY logicalrelid; SELECT * FROM pg_dist_shard ORDER BY shardid; SELECT * FROM pg_dist_shard_placement ORDER BY shardid, nodename, nodeport; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_testing_schema.mx_test_table'::regclass; -\d mx_testing_schema.mx_test_table_col_1_key -\d mx_testing_schema.mx_index +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_testing_schema.mx_test_table_col_1_key'::regclass; +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_testing_schema.mx_index'::regclass; SELECT count(*) FROM pg_trigger WHERE tgrelid='mx_testing_schema.mx_test_table'::regclass; -- Make sure that start_metadata_sync_to_node cannot be called inside a transaction @@ -206,11 +210,14 @@ CREATE INDEX mx_index_2 ON mx_test_schema_2.mx_table_2 (col2); ALTER TABLE mx_test_schema_2.mx_table_2 ADD CONSTRAINT mx_fk_constraint FOREIGN KEY(col1) REFERENCES mx_test_schema_1.mx_table_1(col1); SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_test_schema_1.mx_table_1'::regclass; -\d mx_test_schema_1.mx_table_1_col1_key -\d mx_test_schema_1.mx_index_1 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_1.mx_table_1_col1_key'::regclass; +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_1.mx_index_1'::regclass; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_test_schema_2.mx_table_2'::regclass; -\d mx_test_schema_2.mx_index_2 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_2.mx_index_2'::regclass; SELECT "Constraint", "Definition" FROM table_fkeys WHERE relid='mx_test_schema_2.mx_table_2'::regclass; SELECT create_distributed_table('mx_test_schema_1.mx_table_1', 'col1'); @@ -281,15 +288,18 @@ SET client_min_messages TO 'ERROR'; CREATE INDEX mx_index_3 ON mx_test_schema_2.mx_table_2 USING hash (col1); ALTER TABLE mx_test_schema_2.mx_table_2 ADD CONSTRAINT mx_table_2_col1_key UNIQUE (col1); \c - - - :worker_1_port -\d mx_test_schema_2.mx_index_3 -\d mx_test_schema_2.mx_table_2_col1_key +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_2.mx_index_3'::regclass; +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_2.mx_table_2_col1_key'::regclass; -- Check that DROP INDEX statement is propagated \c - - - :master_port SET citus.multi_shard_commit_protocol TO '2pc'; DROP INDEX mx_test_schema_2.mx_index_3; \c - - - :worker_1_port -\d mx_test_schema_2.mx_index_3 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_test_schema_2.mx_index_3'::regclass; -- Check that ALTER TABLE statements are propagated \c - - - :master_port @@ -581,19 +591,24 @@ SELECT shardid AS ref_table_shardid FROM pg_dist_shard WHERE logicalrelid='mx_re ALTER TABLE mx_ref ADD COLUMN col_3 NUMERIC DEFAULT 0; CREATE INDEX mx_ref_index ON mx_ref(col_1); SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ref'::regclass; -\d mx_ref_index +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_ref_index'::regclass; + \c - - - :worker_1_port SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ref'::regclass; -\d mx_ref_index +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_ref_index'::regclass; -- Check that metada is cleaned successfully upon drop table \c - - - :master_port DROP TABLE mx_ref; -\d mx_ref +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_ref_index'::regclass; \c - - - :worker_1_port -\d mx_ref +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'mx_ref_index'::regclass; SELECT * FROM pg_dist_shard WHERE shardid=:ref_table_shardid; SELECT * FROM pg_dist_shard_placement WHERE shardid=:ref_table_shardid; diff --git a/src/test/regress/sql/multi_mx_ddl.sql b/src/test/regress/sql/multi_mx_ddl.sql index fe2eda1a3..f5ccf6779 100644 --- a/src/test/regress/sql/multi_mx_ddl.sql +++ b/src/test/regress/sql/multi_mx_ddl.sql @@ -21,7 +21,8 @@ ALTER TABLE mx_ddl_table ALTER COLUMN version SET NOT NULL; -- See that the changes are applied on coordinator, worker tables and shards SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table'::regclass; -\d ddl_test*_index +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'ddl_test%_index'; \c - - - :worker_1_port @@ -29,9 +30,11 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table': SET citus.override_table_visibility TO FALSE; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table'::regclass; -\d ddl_test*_index +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'ddl_test%_index'; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table_1220088'::regclass; -\d ddl_test*_index_1220088 +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'ddl_test%_index_1220088'; \c - - - :worker_2_port @@ -39,9 +42,11 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table_1 SET citus.override_table_visibility TO FALSE; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table'::regclass; -\d ddl_test*_index +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'ddl_test%_index'; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='mx_ddl_table_1220089'::regclass; -\d ddl_test*_index_1220089 +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'ddl_test%_index_1220089'; INSERT INTO mx_ddl_table VALUES (37, 78, 2); INSERT INTO mx_ddl_table VALUES (38, 78); diff --git a/src/test/regress/sql/multi_mx_metadata.sql b/src/test/regress/sql/multi_mx_metadata.sql index 73ae78695..822f220f7 100644 --- a/src/test/regress/sql/multi_mx_metadata.sql +++ b/src/test/regress/sql/multi_mx_metadata.sql @@ -33,8 +33,10 @@ SELECT count(*) FROM pg_dist_transaction; \c - - - :worker_1_port SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='distributed_mx_table'::regclass; -\d distributed_mx_table_pkey -\d distributed_mx_table_value_idx +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'distributed_mx_table_pkey'::regclass; +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'distributed_mx_table_value_idx'::regclass; SELECT repmodel FROM pg_dist_partition WHERE logicalrelid = 'distributed_mx_table'::regclass; @@ -45,8 +47,10 @@ WHERE logicalrelid = 'distributed_mx_table'::regclass; \c - - - :worker_2_port SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='distributed_mx_table'::regclass; -\d distributed_mx_table_pkey -\d distributed_mx_table_value_idx +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'distributed_mx_table_pkey'::regclass; +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'distributed_mx_table_value_idx'::regclass; SELECT repmodel FROM pg_dist_partition WHERE logicalrelid = 'distributed_mx_table'::regclass; diff --git a/src/test/regress/sql/multi_name_lengths.sql b/src/test/regress/sql/multi_name_lengths.sql index a68433eab..c485cded1 100644 --- a/src/test/regress/sql/multi_name_lengths.sql +++ b/src/test/regress/sql/multi_name_lengths.sql @@ -74,7 +74,8 @@ ALTER TABLE name_lengths RENAME CONSTRAINT unique_123456789012345678901234567890 CREATE INDEX tmp_idx_12345678901234567890123456789012345678901234567890 ON name_lengths(col2); \c - - - :worker_1_port -\d tmp_idx_* +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'tmp_idx_%'; \c - - - :master_port -- Verify that a new index name > 63 characters is auto-truncated @@ -82,7 +83,8 @@ CREATE INDEX tmp_idx_12345678901234567890123456789012345678901234567890 ON name_ CREATE INDEX tmp_idx_123456789012345678901234567890123456789012345678901234567890 ON name_lengths(col2); \c - - - :worker_1_port -\d tmp_idx_* +SELECT "relname", "Column", "Type", "Definition" FROM index_attrs WHERE + relname LIKE 'tmp_idx_%'; \c - - - :master_port SET citus.shard_count TO 2; diff --git a/src/test/regress/sql/multi_prepare_sql.sql b/src/test/regress/sql/multi_prepare_sql.sql index 7cf6df783..bda1ac5b7 100644 --- a/src/test/regress/sql/multi_prepare_sql.sql +++ b/src/test/regress/sql/multi_prepare_sql.sql @@ -201,7 +201,10 @@ EXECUTE prepared_partition_column_insert(4); EXECUTE prepared_partition_column_insert(5); EXECUTE prepared_partition_column_insert(6); +-- suppress notice message caused by DROP ... CASCADE to prevent pg version difference +SET client_min_messages TO 'WARNING'; DROP TYPE test_composite_type CASCADE; +RESET client_min_messages; -- test router executor with prepare statements CREATE TABLE prepare_table ( diff --git a/src/test/regress/sql/multi_reference_table.sql b/src/test/regress/sql/multi_reference_table.sql index 88f1c04b1..56768421a 100644 --- a/src/test/regress/sql/multi_reference_table.sql +++ b/src/test/regress/sql/multi_reference_table.sql @@ -859,12 +859,14 @@ ALTER TABLE reference_schema.reference_table_ddl ALTER COLUMN value_3 SET NOT NU -- see that Citus applied all DDLs to the table SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='reference_schema.reference_table_ddl'::regclass; -\d reference_schema.reference_index_2 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'reference_schema.reference_index_2'::regclass; -- also to the shard placements \c - - - :worker_1_port SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='reference_schema.reference_table_ddl_1250019'::regclass; -\d reference_schema.reference_index_2_1250019 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'reference_schema.reference_index_2_1250019'::regclass; \c - - - :master_port DROP INDEX reference_schema.reference_index_2; \c - - - :worker_1_port diff --git a/src/test/regress/sql/multi_schema_support.sql b/src/test/regress/sql/multi_schema_support.sql index d28e42b7f..2abfdd8cd 100644 --- a/src/test/regress/sql/multi_schema_support.sql +++ b/src/test/regress/sql/multi_schema_support.sql @@ -463,9 +463,11 @@ SET search_path TO public; CREATE INDEX index1 ON test_schema_support.nation_hash(n_name); --verify INDEX is created -\d test_schema_support.index1 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'test_schema_support.index1'::regclass; \c - - - :worker_1_port -\d test_schema_support.index1_1190003 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'test_schema_support.index1_1190003'::regclass; \c - - - :master_port -- DROP index @@ -484,9 +486,11 @@ SET search_path TO test_schema_support; CREATE INDEX index1 ON nation_hash(n_name); --verify INDEX is created -\d test_schema_support.index1 +SELECT "Column", "Type", "Definition" FROM public.index_attrs WHERE + relid = 'test_schema_support.index1'::regclass; \c - - - :worker_1_port -\d test_schema_support.index1_1190003 +SELECT "Column", "Type", "Definition" FROM index_attrs WHERE + relid = 'test_schema_support.index1_1190003'::regclass; \c - - - :master_port -- DROP index diff --git a/src/test/regress/sql/multi_test_helpers.sql b/src/test/regress/sql/multi_test_helpers.sql index d63ab6529..23bbd97f4 100644 --- a/src/test/regress/sql/multi_test_helpers.sql +++ b/src/test/regress/sql/multi_test_helpers.sql @@ -79,5 +79,30 @@ FROM information_schema.check_constraints cc, WHERE cc.constraint_schema = ccu.constraint_schema AND cc.constraint_name = ccu.constraint_name ORDER BY cc.constraint_name ASC; + +CREATE VIEW index_attrs AS +WITH indexoid AS ( + SELECT c.oid, + n.nspname, + c.relname + FROM pg_catalog.pg_class c + LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace + WHERE pg_catalog.pg_table_is_visible(c.oid) + ORDER BY 2, 3 +) +SELECT + indexoid.nspname AS "nspname", + indexoid.relname AS "relname", + a.attrelid AS "relid", + a.attname AS "Column", + pg_catalog.format_type(a.atttypid, a.atttypmod) AS "Type", + pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS "Definition" +FROM pg_catalog.pg_attribute a +LEFT JOIN indexoid ON (a.attrelid = indexoid.oid) +WHERE true + AND a.attnum > 0 + AND NOT a.attisdropped +ORDER BY a.attrelid, a.attnum; + $desc_views$ ); diff --git a/src/test/regress/sql/multi_unsupported_worker_operations.sql b/src/test/regress/sql/multi_unsupported_worker_operations.sql index f647e4492..3b604ac0a 100644 --- a/src/test/regress/sql/multi_unsupported_worker_operations.sql +++ b/src/test/regress/sql/multi_unsupported_worker_operations.sql @@ -212,7 +212,10 @@ DROP SEQUENCE some_sequence; -- Show that dropping the sequence of an MX table with cascade harms the table and shards BEGIN; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.mx_table'::regclass; +-- suppress notice message caused by DROP ... CASCADE to prevent pg version difference +SET client_min_messages TO 'WARNING'; DROP SEQUENCE mx_table_col_3_seq CASCADE; +RESET client_min_messages; SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.mx_table'::regclass; ROLLBACK; diff --git a/src/test/regress/sql/relation_access_tracking.sql b/src/test/regress/sql/relation_access_tracking.sql index 914e16a9a..5196cf523 100644 --- a/src/test/regress/sql/relation_access_tracking.sql +++ b/src/test/regress/sql/relation_access_tracking.sql @@ -3,7 +3,7 @@ --- tests around access tracking within transaction blocks --- SHOW server_version \gset -SELECT substring(:'server_version', '\d+')::int AS server_version; +SELECT substring(:'server_version', '\d+')::int >= 10 AS version_ten_or_above; CREATE SCHEMA access_tracking; SET search_path TO 'access_tracking';