diff --git a/src/backend/distributed/deparser/citus_ruleutils.c b/src/backend/distributed/deparser/citus_ruleutils.c index ebdb78cc9ed..af4ab476837 100644 --- a/src/backend/distributed/deparser/citus_ruleutils.c +++ b/src/backend/distributed/deparser/citus_ruleutils.c @@ -997,11 +997,12 @@ AddVacuumParams(ReindexStmt *reindexStmt, StringInfo buffer) { if (temp->len > 0) { - appendStringInfo(temp, ", TABLESPACE %s", tableSpaceName); + appendStringInfo(temp, ", TABLESPACE %s", + quote_identifier(tableSpaceName)); } else { - appendStringInfo(temp, "TABLESPACE %s", tableSpaceName); + appendStringInfo(temp, "TABLESPACE %s", quote_identifier(tableSpaceName)); } } diff --git a/src/test/regress/expected/pg14.out b/src/test/regress/expected/pg14.out index 13a6a5f71b8..c2159b514dc 100644 --- a/src/test/regress/expected/pg14.out +++ b/src/test/regress/expected/pg14.out @@ -208,6 +208,24 @@ DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx reindex(TABLESPACE test_tablespace1) index idx; ERROR: tablespace "test_tablespace1" does not exist reset citus.log_remote_commands; +-- a tablespace name that needs quoting must stay quoted on the shards +ALTER TABLESPACE test_tablespace RENAME TO "Test Tablespace"; +SELECT result FROM run_command_on_workers('ALTER TABLESPACE test_tablespace RENAME TO "Test Tablespace"'); + result +--------------------------------------------------------------------- + ALTER TABLESPACE + ALTER TABLESPACE +(2 rows) + +reindex(TABLESPACE "Test Tablespace") index idx; +ALTER TABLESPACE "Test Tablespace" RENAME TO test_tablespace; +SELECT result FROM run_command_on_workers('ALTER TABLESPACE "Test Tablespace" RENAME TO test_tablespace'); + result +--------------------------------------------------------------------- + ALTER TABLESPACE + ALTER TABLESPACE +(2 rows) + -- CREATE STATISTICS allows table references too CREATE TABLE tbl1(a timestamp, b int); SELECT create_distributed_table('tbl1','a'); diff --git a/src/test/regress/sql/pg14.sql b/src/test/regress/sql/pg14.sql index aa9a30fa257..03279c12eb3 100644 --- a/src/test/regress/sql/pg14.sql +++ b/src/test/regress/sql/pg14.sql @@ -42,6 +42,12 @@ reindex(verbose, TABLESPACE test_tablespace) index idx ; -- should error saying table space doesn't exist reindex(TABLESPACE test_tablespace1) index idx; reset citus.log_remote_commands; +-- a tablespace name that needs quoting must stay quoted on the shards +ALTER TABLESPACE test_tablespace RENAME TO "Test Tablespace"; +SELECT result FROM run_command_on_workers('ALTER TABLESPACE test_tablespace RENAME TO "Test Tablespace"'); +reindex(TABLESPACE "Test Tablespace") index idx; +ALTER TABLESPACE "Test Tablespace" RENAME TO test_tablespace; +SELECT result FROM run_command_on_workers('ALTER TABLESPACE "Test Tablespace" RENAME TO test_tablespace'); -- CREATE STATISTICS allows table references too CREATE TABLE tbl1(a timestamp, b int); SELECT create_distributed_table('tbl1','a');