mirror of https://github.com/citusdata/citus.git
ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY - PG14 #71f4c8c (#5223)
parent
c431bb2e45
commit
6fbdeb38a8
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue