From b33b28203071e39b7910c04c0493651b8e5003dc Mon Sep 17 00:00:00 2001 From: Burak Yucesoy Date: Mon, 9 Apr 2018 09:56:46 +0300 Subject: [PATCH] Fix bug while DROPping partitioned table from worker We recently added partitionin support to Citus MX. We should not execute DROP table commands from MX workers but at the moment we try to execute such commands for partitioned tables. This PR fixes that problem by adding check. --- src/backend/distributed/executor/multi_utility.c | 2 ++ src/test/regress/expected/multi_mx_partitioning.out | 4 ++++ src/test/regress/expected/multi_mx_partitioning_0.out | 3 +++ src/test/regress/sql/multi_mx_partitioning.sql | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/backend/distributed/executor/multi_utility.c b/src/backend/distributed/executor/multi_utility.c index 459483604..a9a50f6cd 100644 --- a/src/backend/distributed/executor/multi_utility.c +++ b/src/backend/distributed/executor/multi_utility.c @@ -3813,6 +3813,8 @@ ProcessDropTableStmt(DropStmt *dropTableStatement) continue; } + EnsureCoordinator(); + partitionList = PartitionList(relationId); if (list_length(partitionList) == 0) { diff --git a/src/test/regress/expected/multi_mx_partitioning.out b/src/test/regress/expected/multi_mx_partitioning.out index 0eb727585..3e91311fb 100644 --- a/src/test/regress/expected/multi_mx_partitioning.out +++ b/src/test/regress/expected/multi_mx_partitioning.out @@ -241,6 +241,10 @@ SELECT inhrelid::regclass FROM pg_inherits WHERE inhparent = 'partitioning_test' partitioning_test_2013 (4 rows) +-- make sure DROPping from worker node is not allowed +DROP TABLE partitioning_test; +ERROR: operation is not allowed on this node +HINT: Connect to the coordinator and run it again. \c - - - :master_port -- make sure we can repeatedly call start_metadata_sync_to_node SELECT start_metadata_sync_to_node('localhost', :worker_1_port); diff --git a/src/test/regress/expected/multi_mx_partitioning_0.out b/src/test/regress/expected/multi_mx_partitioning_0.out index d92f53d89..f39462ead 100644 --- a/src/test/regress/expected/multi_mx_partitioning_0.out +++ b/src/test/regress/expected/multi_mx_partitioning_0.out @@ -205,6 +205,9 @@ SELECT inhrelid::regclass FROM pg_inherits WHERE inhparent = 'partitioning_test' ERROR: relation "partitioning_test" does not exist LINE 1: ...elid::regclass FROM pg_inherits WHERE inhparent = 'partition... ^ +-- make sure DROPping from worker node is not allowed +DROP TABLE partitioning_test; +ERROR: table "partitioning_test" does not exist \c - - - :master_port -- make sure we can repeatedly call start_metadata_sync_to_node SELECT start_metadata_sync_to_node('localhost', :worker_1_port); diff --git a/src/test/regress/sql/multi_mx_partitioning.sql b/src/test/regress/sql/multi_mx_partitioning.sql index b05fbf309..ba3dd3a32 100644 --- a/src/test/regress/sql/multi_mx_partitioning.sql +++ b/src/test/regress/sql/multi_mx_partitioning.sql @@ -156,6 +156,9 @@ ALTER TABLE partitioning_test DETACH PARTITION partitioning_test_2009; SELECT inhrelid::regclass FROM pg_inherits WHERE inhparent = 'partitioning_test'::regclass; +-- make sure DROPping from worker node is not allowed +DROP TABLE partitioning_test; + \c - - - :master_port -- make sure we can repeatedly call start_metadata_sync_to_node