Skip to content

Commit

Permalink
Adds expected test result
Browse files Browse the repository at this point in the history
  • Loading branch information
gurkanindibay committed Oct 12, 2023
1 parent 8d6d27a commit f896238
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/backend/distributed/commands/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ PreprocessAlterDatabaseStmt(Node *node, const char *queryString,

if (strstr(sql, "SET TABLESPACE") != NULL)
{
/*Set tablespace does not work inside a transaction.Therefore, we close the transaction before set tablespace
* and open it again after set tablespace.
*/
commands = list_make5(DISABLE_DDL_PROPAGATION,
COMMIT_TRANSACTION,
sql,
Expand Down
29 changes: 23 additions & 6 deletions src/test/regress/expected/alter_database_propagation.out
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,34 @@ NOTICE: issuing ALTER DATABASE regression2 WITH IS_TEMPLATE false;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
NOTICE: issuing ALTER DATABASE regression2 WITH IS_TEMPLATE false;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
alter database regression2 set TABLESPACE pg_default;
NOTICE: Citus partially supports ALTER DATABASE SET TABLESPACE for distributed databases
DETAIL: Citus does not propagate ALTER DATABASE SET TABLESPACE command to workers
HINT: You can manually alter a tablespace for a database and its extensions on workers.
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts3'
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
\c - - - :worker_1_port
alter database regression2 set TABLESPACE pg_default;
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts4'
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
\c - - - :worker_2_port
alter database regression2 set TABLESPACE pg_default;
\set alter_db_tablespace :abs_srcdir '/tmp_check/ts5'
CREATE TABLESPACE alter_db_tablespace LOCATION :'alter_db_tablespace';
\c - - - :master_port
set citus.log_remote_commands = true;
set citus.grep_remote_commands = '%ALTER DATABASE%';
alter database regression2 set TABLESPACE alter_db_tablespace;
NOTICE: issuing ALTER DATABASE regression2 SET TABLESPACE alter_db_tablespace;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
NOTICE: issuing ALTER DATABASE regression2 SET TABLESPACE alter_db_tablespace;
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
set citus.enable_create_database_propagation=on;
alter database regression2 rename to regression3;
NOTICE: issuing ALTER DATABASE regression2 RENAME TO regression3
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
NOTICE: issuing ALTER DATABASE regression2 RENAME TO regression3
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
drop database regression3;
set citus.log_remote_commands = false;
set citus.enable_create_database_propagation=off;
drop tablespace alter_db_tablespace;
\c - - - :worker_1_port
drop tablespace alter_db_tablespace;
\c - - - :worker_2_port
drop tablespace alter_db_tablespace;
\c - - - :master_port

0 comments on commit f896238

Please sign in to comment.