From 7fadfb74bb5994890a4227d8e30e7e61fe2efd9d Mon Sep 17 00:00:00 2001 From: Halil Ozan Akgul Date: Wed, 1 Sep 2021 18:25:12 +0300 Subject: [PATCH] Adds error message for REINDEX TABLE queries on distributed partitioned tables --- src/backend/distributed/commands/index.c | 7 +++++++ src/test/regress/expected/pg14.out | 15 +++++++++++++++ src/test/regress/sql/pg14.sql | 12 ++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/backend/distributed/commands/index.c b/src/backend/distributed/commands/index.c index 6a7431528..5a196db91 100644 --- a/src/backend/distributed/commands/index.c +++ b/src/backend/distributed/commands/index.c @@ -589,6 +589,13 @@ PreprocessReindexStmt(Node *node, const char *reindexCommand, if (isCitusRelation) { + if (PartitionedTable(relationId)) + { + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("REINDEX TABLE queries on distributed partitioned " + "tables are not supported"))); + } + DDLJob *ddlJob = palloc0(sizeof(DDLJob)); ddlJob->targetRelationId = relationId; ddlJob->concurrentIndexCmd = IsReindexWithParam_compat(reindexStatement, diff --git a/src/test/regress/expected/pg14.out b/src/test/regress/expected/pg14.out index a59179991..7291550b7 100644 --- a/src/test/regress/expected/pg14.out +++ b/src/test/regress/expected/pg14.out @@ -629,5 +629,20 @@ SELECT row_to_json(x.*) FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = {"f1":1} (1 row) +-- we don't support REINDEX TABLE queries on distributed partitioned tables +CREATE TABLE dist_part_table (a int) PARTITION BY RANGE (a); +CREATE TABLE dist_part_table_1 PARTITION OF dist_part_table FOR VALUES FROM (1) TO (5); +CREATE TABLE dist_part_table_2 PARTITION OF dist_part_table FOR VALUES FROM (5) TO (10); +SELECT create_distributed_table('dist_part_table', 'a'); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +CREATE INDEX dist_part_idx ON dist_part_table(a); +REINDEX TABLE dist_part_table; +ERROR: REINDEX TABLE queries on distributed partitioned tables are not supported +-- but we support REINDEXing partitions +REINDEX TABLE dist_part_table_1; set client_min_messages to error; drop schema pg14 cascade; diff --git a/src/test/regress/sql/pg14.sql b/src/test/regress/sql/pg14.sql index 967314206..d60b5416f 100644 --- a/src/test/regress/sql/pg14.sql +++ b/src/test/regress/sql/pg14.sql @@ -260,5 +260,17 @@ SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.i > 1 ORDER BY 1,2,3,4; -- ORDER BY is not supported for json and this returns 1 row, so it is okay. SELECT row_to_json(x.*) FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; +-- we don't support REINDEX TABLE queries on distributed partitioned tables +CREATE TABLE dist_part_table (a int) PARTITION BY RANGE (a); +CREATE TABLE dist_part_table_1 PARTITION OF dist_part_table FOR VALUES FROM (1) TO (5); +CREATE TABLE dist_part_table_2 PARTITION OF dist_part_table FOR VALUES FROM (5) TO (10); +SELECT create_distributed_table('dist_part_table', 'a'); +CREATE INDEX dist_part_idx ON dist_part_table(a); + +REINDEX TABLE dist_part_table; + +-- but we support REINDEXing partitions +REINDEX TABLE dist_part_table_1; + set client_min_messages to error; drop schema pg14 cascade;