diff --git a/src/backend/distributed/commands/table.c b/src/backend/distributed/commands/table.c index 1442c6c4c..f15017f4e 100644 --- a/src/backend/distributed/commands/table.c +++ b/src/backend/distributed/commands/table.c @@ -2380,6 +2380,15 @@ ErrorIfUnsupportedAlterTableStmt(AlterTableStmt *alterTableStatement) break; } +#if PG_VERSION_NUM >= PG_VERSION_14 + case AT_DetachPartitionFinalize: + { + ereport(ERROR, (errmsg("ALTER TABLE .. DETACH PARTITION .. FINALIZE " + "commands are currently unsupported."))); + break; + } + +#endif case AT_DetachPartition: { /* we only allow partitioning commands if they are only subcommand */ @@ -2391,7 +2400,16 @@ ErrorIfUnsupportedAlterTableStmt(AlterTableStmt *alterTableStatement) errhint("You can issue each subcommand " "separately."))); } + #if PG_VERSION_NUM >= PG_VERSION_14 + PartitionCmd *partitionCommand = (PartitionCmd *) command->def; + if (partitionCommand->concurrent) + { + ereport(ERROR, (errmsg("ALTER TABLE .. DETACH PARTITION .. " + "CONCURRENTLY commands are currently " + "unsupported."))); + } + #endif ErrorIfCitusLocalTablePartitionCommand(command, relationId); break; diff --git a/src/test/regress/expected/pg14.out b/src/test/regress/expected/pg14.out index 954680ccd..2c67f0c13 100644 --- a/src/test/regress/expected/pg14.out +++ b/src/test/regress/expected/pg14.out @@ -143,5 +143,23 @@ DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx reindex(TABLESPACE test_tablespace1) index idx; ERROR: tablespace "test_tablespace1" does not exist set citus.log_remote_commands to off; +-- error out in case of ALTER TABLE .. DETACH PARTITION .. CONCURRENTLY/FINALIZE +-- only if it's a distributed partitioned table +CREATE TABLE par (a INT UNIQUE) PARTITION BY RANGE(a); +CREATE TABLE par_1 PARTITION OF par FOR VALUES FROM (1) TO (4); +CREATE TABLE par_2 PARTITION OF par FOR VALUES FROM (5) TO (8); +-- works as it's not distributed +ALTER TABLE par DETACH PARTITION par_1 CONCURRENTLY; +-- errors out +SELECT create_distributed_table('par','a'); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +ALTER TABLE par DETACH PARTITION par_2 CONCURRENTLY; +ERROR: ALTER TABLE .. DETACH PARTITION .. CONCURRENTLY commands are currently unsupported. +ALTER TABLE par DETACH PARTITION par_2 FINALIZE; +ERROR: ALTER TABLE .. DETACH PARTITION .. FINALIZE commands are currently unsupported. 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 24a2dac66..141d931e7 100644 --- a/src/test/regress/sql/pg14.sql +++ b/src/test/regress/sql/pg14.sql @@ -39,6 +39,18 @@ reindex(verbose, TABLESPACE test_tablespace) index idx ; reindex(TABLESPACE test_tablespace1) index idx; set citus.log_remote_commands to off; +-- error out in case of ALTER TABLE .. DETACH PARTITION .. CONCURRENTLY/FINALIZE +-- only if it's a distributed partitioned table +CREATE TABLE par (a INT UNIQUE) PARTITION BY RANGE(a); +CREATE TABLE par_1 PARTITION OF par FOR VALUES FROM (1) TO (4); +CREATE TABLE par_2 PARTITION OF par FOR VALUES FROM (5) TO (8); +-- works as it's not distributed +ALTER TABLE par DETACH PARTITION par_1 CONCURRENTLY; +-- errors out +SELECT create_distributed_table('par','a'); +ALTER TABLE par DETACH PARTITION par_2 CONCURRENTLY; +ALTER TABLE par DETACH PARTITION par_2 FINALIZE; + set client_min_messages to error; drop schema pg14 cascade;