diff --git a/src/backend/distributed/executor/multi_utility.c b/src/backend/distributed/executor/multi_utility.c index 03f5e1349..b87809859 100644 --- a/src/backend/distributed/executor/multi_utility.c +++ b/src/backend/distributed/executor/multi_utility.c @@ -168,6 +168,7 @@ multi_ProcessUtility(Node *parsetree, bool commandMustRunAsOwner = false; Oid savedUserId = InvalidOid; int savedSecurityContext = 0; + DDLJob *ddlJob = NULL; if (IsA(parsetree, TransactionStmt)) { @@ -252,8 +253,6 @@ multi_ProcessUtility(Node *parsetree, */ if (EnableDDLPropagation) { - DDLJob *ddlJob = NULL; - if (IsA(parsetree, IndexStmt)) { ddlJob = PlanIndexStmt((IndexStmt *) parsetree, queryString); @@ -312,11 +311,6 @@ multi_ProcessUtility(Node *parsetree, errhint("Connect to worker nodes directly to manually " "move all tables."))); } - - if (ddlJob != NULL) - { - ExecuteDistributedDDLJob(ddlJob); - } } else { @@ -381,6 +375,11 @@ multi_ProcessUtility(Node *parsetree, SetUserIdAndSecContext(savedUserId, savedSecurityContext); } + if (ddlJob != NULL) + { + ExecuteDistributedDDLJob(ddlJob); + } + /* we run VacuumStmt after standard hook to benefit from its checks and locking */ if (IsA(parsetree, VacuumStmt)) { diff --git a/src/test/regress/expected/multi_index_statements.out b/src/test/regress/expected/multi_index_statements.out index 100ce2d05..d8c1f58ed 100644 --- a/src/test/regress/expected/multi_index_statements.out +++ b/src/test/regress/expected/multi_index_statements.out @@ -163,14 +163,10 @@ ERROR: creating unique indexes on append-partitioned tables is currently unsupp CREATE INDEX lineitem_orderkey_index ON lineitem (l_orderkey); ERROR: relation "lineitem_orderkey_index" already exists CREATE INDEX try_index ON lineitem USING gist (l_orderkey); -NOTICE: using one-phase commit for distributed DDL commands -HINT: You can enable two-phase commit for extra safety with: SET citus.multi_shard_commit_protocol TO '2pc' ERROR: data type bigint has no default operator class for access method "gist" HINT: You must specify an operator class for the index or define a default operator class for the data type. -CONTEXT: while executing command on localhost:57638 CREATE INDEX try_index ON lineitem (non_existent_column); ERROR: column "non_existent_column" does not exist -CONTEXT: while executing command on localhost:57638 CREATE INDEX ON lineitem (l_orderkey); ERROR: creating index without a name on a distributed table is currently unsupported -- Verify that none of failed indexes got created on the master node @@ -205,6 +201,8 @@ DROP INDEX CONCURRENTLY lineitem_orderkey_index; ERROR: dropping indexes concurrently on distributed tables is currently unsupported -- Verify that we can succesfully drop indexes DROP INDEX lineitem_orderkey_index; +NOTICE: using one-phase commit for distributed DDL commands +HINT: You can enable two-phase commit for extra safety with: SET citus.multi_shard_commit_protocol TO '2pc' DROP INDEX lineitem_orderkey_index_new; DROP INDEX lineitem_partkey_desc_index; DROP INDEX lineitem_partial_index; diff --git a/src/test/regress/expected/multi_join_order_additional.out b/src/test/regress/expected/multi_join_order_additional.out index da8ddd2f5..1d96eb681 100644 --- a/src/test/regress/expected/multi_join_order_additional.out +++ b/src/test/regress/expected/multi_join_order_additional.out @@ -43,9 +43,9 @@ SELECT master_create_worker_shards('lineitem_hash', 2, 1); (1 row) CREATE INDEX lineitem_hash_time_index ON lineitem_hash (l_shipdate); +DEBUG: building index "lineitem_hash_time_index" on table "lineitem_hash" NOTICE: using one-phase commit for distributed DDL commands HINT: You can enable two-phase commit for extra safety with: SET citus.multi_shard_commit_protocol TO '2pc' -DEBUG: building index "lineitem_hash_time_index" on table "lineitem_hash" CREATE TABLE orders_hash ( o_orderkey bigint not null, o_custkey integer not null, diff --git a/src/test/regress/expected/multi_schema_support.out b/src/test/regress/expected/multi_schema_support.out index b476242b3..1cdc897ab 100644 --- a/src/test/regress/expected/multi_schema_support.out +++ b/src/test/regress/expected/multi_schema_support.out @@ -610,9 +610,9 @@ HINT: You can enable two-phase commit for extra safety with: SET citus.multi_sh \c - - - :master_port ALTER TABLE test_schema_support.nation_hash DROP COLUMN IF EXISTS non_existent_column; +NOTICE: column "non_existent_column" of relation "nation_hash" does not exist, skipping NOTICE: using one-phase commit for distributed DDL commands HINT: You can enable two-phase commit for extra safety with: SET citus.multi_shard_commit_protocol TO '2pc' -NOTICE: column "non_existent_column" of relation "nation_hash" does not exist, skipping ALTER TABLE test_schema_support.nation_hash DROP COLUMN IF EXISTS new_col; -- verify column is dropped \d test_schema_support.nation_hash; @@ -665,9 +665,9 @@ HINT: You can enable two-phase commit for extra safety with: SET citus.multi_sh \c - - - :master_port SET search_path TO test_schema_support; ALTER TABLE nation_hash DROP COLUMN IF EXISTS non_existent_column; +NOTICE: column "non_existent_column" of relation "nation_hash" does not exist, skipping NOTICE: using one-phase commit for distributed DDL commands HINT: You can enable two-phase commit for extra safety with: SET citus.multi_shard_commit_protocol TO '2pc' -NOTICE: column "non_existent_column" of relation "nation_hash" does not exist, skipping ALTER TABLE nation_hash DROP COLUMN IF EXISTS new_col; -- verify column is dropped \d test_schema_support.nation_hash; diff --git a/src/test/regress/expected/multi_unsupported_worker_operations.out b/src/test/regress/expected/multi_unsupported_worker_operations.out index a5165c40a..41a1474ee 100644 --- a/src/test/regress/expected/multi_unsupported_worker_operations.out +++ b/src/test/regress/expected/multi_unsupported_worker_operations.out @@ -140,6 +140,9 @@ SELECT * FROM mx_ref_table ORDER BY col_1; \c - - - :master_port DROP TABLE mx_ref_table; +CREATE UNIQUE INDEX mx_test_uniq_index ON mx_table(col_1); +NOTICE: using one-phase commit for distributed DDL commands +HINT: You can enable two-phase commit for extra safety with: SET citus.multi_shard_commit_protocol TO '2pc' \c - - - :worker_1_port -- DDL commands \d mx_table @@ -149,8 +152,10 @@ DROP TABLE mx_ref_table; col_1 | integer | col_2 | text | col_3 | bigint | not null default nextval('mx_table_col_3_seq'::regclass) +Indexes: + "mx_test_uniq_index" UNIQUE, btree (col_1) -CREATE INDEX mx_test_index ON mx_table(col_1); +CREATE INDEX mx_test_index ON mx_table(col_2); ERROR: operation is not allowed on this node HINT: Connect to the coordinator and run it again. ALTER TABLE mx_table ADD COLUMN col_4 int; @@ -166,6 +171,8 @@ HINT: Connect to the coordinator and run it again. col_1 | integer | col_2 | text | col_3 | bigint | not null default nextval('mx_table_col_3_seq'::regclass) +Indexes: + "mx_test_uniq_index" UNIQUE, btree (col_1) -- master_modify_multiple_shards SELECT master_modify_multiple_shards('UPDATE mx_table SET col_2=''none'''); @@ -223,6 +230,9 @@ SELECT * FROM pg_dist_node WHERE nodename='localhost' AND nodeport=5432; -- master_remove_node \c - - - :master_port +DROP INDEX mx_test_uniq_index; +NOTICE: using one-phase commit for distributed DDL commands +HINT: You can enable two-phase commit for extra safety with: SET citus.multi_shard_commit_protocol TO '2pc' SELECT master_add_node('localhost', 5432); master_add_node -------------------------------------------- diff --git a/src/test/regress/output/multi_alter_table_statements.source b/src/test/regress/output/multi_alter_table_statements.source index b16ab3310..4f9395709 100644 --- a/src/test/regress/output/multi_alter_table_statements.source +++ b/src/test/regress/output/multi_alter_table_statements.source @@ -261,8 +261,7 @@ ALTER TABLE IF EXISTS non_existent_table ADD COLUMN new_column INTEGER; NOTICE: relation "non_existent_table" does not exist, skipping ALTER TABLE IF EXISTS lineitem_alter ALTER COLUMN int_column2 SET DATA TYPE INTEGER; ALTER TABLE lineitem_alter DROP COLUMN non_existent_column; -ERROR: column "non_existent_column" of relation "lineitem_alter_220000" does not exist -CONTEXT: while executing command on localhost:57638 +ERROR: column "non_existent_column" of relation "lineitem_alter" does not exist ALTER TABLE lineitem_alter DROP COLUMN IF EXISTS non_existent_column; NOTICE: column "non_existent_column" of relation "lineitem_alter" does not exist, skipping ALTER TABLE lineitem_alter DROP COLUMN IF EXISTS int_column2; @@ -360,13 +359,13 @@ DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT, ADD|DROP CON -- types ALTER TABLE lineitem_alter ADD COLUMN new_column non_existent_type; ERROR: type "non_existent_type" does not exist -CONTEXT: while executing command on localhost:57638 +LINE 1: ALTER TABLE lineitem_alter ADD COLUMN new_column non_existen... + ^ ALTER TABLE lineitem_alter ALTER COLUMN null_column SET NOT NULL; ERROR: column "null_column" contains null values CONTEXT: while executing command on localhost:57638 ALTER TABLE lineitem_alter ALTER COLUMN l_partkey SET DEFAULT 'a'; ERROR: invalid input syntax for integer: "a" -CONTEXT: while executing command on localhost:57638 -- Verify that we error out on statements involving RENAME ALTER TABLE lineitem_alter RENAME TO lineitem_renamed; ERROR: renaming distributed tables or their objects is currently unsupported diff --git a/src/test/regress/sql/multi_unsupported_worker_operations.sql b/src/test/regress/sql/multi_unsupported_worker_operations.sql index e890354b1..3860e80e0 100644 --- a/src/test/regress/sql/multi_unsupported_worker_operations.sql +++ b/src/test/regress/sql/multi_unsupported_worker_operations.sql @@ -91,11 +91,12 @@ SELECT * FROM mx_ref_table ORDER BY col_1; \c - - - :master_port DROP TABLE mx_ref_table; +CREATE UNIQUE INDEX mx_test_uniq_index ON mx_table(col_1); \c - - - :worker_1_port -- DDL commands \d mx_table -CREATE INDEX mx_test_index ON mx_table(col_1); +CREATE INDEX mx_test_index ON mx_table(col_2); ALTER TABLE mx_table ADD COLUMN col_4 int; ALTER TABLE mx_table_2 ADD CONSTRAINT mx_fk_constraint FOREIGN KEY(col_1) REFERENCES mx_table(col_1); \d mx_table @@ -122,6 +123,7 @@ SELECT * FROM pg_dist_node WHERE nodename='localhost' AND nodeport=5432; -- master_remove_node \c - - - :master_port +DROP INDEX mx_test_uniq_index; SELECT master_add_node('localhost', 5432); \c - - - :worker_1_port