From 3ab91c91a319d26f78a4229c713e7b83a3471103 Mon Sep 17 00:00:00 2001 From: gindibay Date: Fri, 10 Nov 2023 04:59:50 +0300 Subject: [PATCH] Fixes review comments --- src/backend/distributed/commands/database.c | 23 +++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/backend/distributed/commands/database.c b/src/backend/distributed/commands/database.c index 175858464..364b94e12 100644 --- a/src/backend/distributed/commands/database.c +++ b/src/backend/distributed/commands/database.c @@ -207,27 +207,24 @@ PreprocessAlterDatabaseStmt(Node *node, const char *queryString, char *sql = DeparseTreeNode((Node *) stmt); - List *commands = NULL; + List *commands = list_make3(DISABLE_DDL_PROPAGATION, + sql, + ENABLE_DDL_PROPAGATION); if (isSetTablespaceStatement(stmt)) { - /*Set tablespace does not work inside a transaction.Therefore, we close the transaction before set tablespace - * and open it again after set tablespace. + /* Set tablespace does not work inside a transaction.Therefore, we need to use + * NontransactionalNodeDDLTask to run the command on the workers outside + * the transaction block. */ - commands = list_make3(DISABLE_DDL_PROPAGATION, - sql, - ENABLE_DDL_PROPAGATION); + return NontransactionalNodeDDLTask(NON_COORDINATOR_NODES, commands); } else { - commands = list_make3(DISABLE_DDL_PROPAGATION, - (void *) sql, - ENABLE_DDL_PROPAGATION); return NodeDDLTaskList(NON_COORDINATOR_NODES, commands); } - return NIL; } @@ -265,7 +262,11 @@ PreprocessAlterDatabaseRefreshCollStmt(Node *node, const char *queryString, #endif - +/* + * PreprocessAlterDatabaseRenameStmt is executed before the statement is applied to the local + * postgres instance. In this stage we prepare ALTER DATABASE RENAME statement to be run on + * all workers. +*/ List * PreprocessAlterDatabaseRenameStmt(Node *node, const char *queryString, ProcessUtilityContext processUtilityContext)