Fixes review notes

pull/7253/head
gindibay 2023-10-13 18:43:06 +03:00
parent ef920b0252
commit ba3123455e
1 changed files with 20 additions and 3 deletions

View File

@ -159,6 +159,20 @@ PreprocessGrantOnDatabaseStmt(Node *node, const char *queryString,
return NodeDDLTaskList(NON_COORDINATOR_NODES, commands); return NodeDDLTaskList(NON_COORDINATOR_NODES, commands);
} }
static bool isSetTablespaceStatement(AlterDatabaseStmt *stmt)
{
ListCell *lc = NULL;
foreach(lc, stmt->options)
{
DefElem *def = (DefElem *) lfirst(lc);
if (strcmp(def->defname, "tablespace") == 0)
{
return true;
}
}
return false;
}
/* /*
* PreprocessAlterDatabaseStmt is executed before the statement is applied to the local * PreprocessAlterDatabaseStmt is executed before the statement is applied to the local
@ -178,11 +192,14 @@ PreprocessAlterDatabaseStmt(Node *node, const char *queryString,
AlterDatabaseStmt *stmt = castNode(AlterDatabaseStmt, node); AlterDatabaseStmt *stmt = castNode(AlterDatabaseStmt, node);
char *sql = DeparseTreeNode((Node *) stmt); char *sql = DeparseTreeNode((Node *) stmt);
List *commands = NULL; List *commands = NULL;
if (strstr(sql, "SET TABLESPACE") != NULL) if (isSetTablespaceStatement(stmt))
{ {
/*Set tablespace does not work inside a transaction.Therefore, we close the transaction before set tablespace /*Set tablespace does not work inside a transaction.Therefore, we close the transaction before set tablespace
* and open it again after set tablespace. * and open it again after set tablespace.
@ -248,10 +265,10 @@ PreprocessAlterDatabaseRenameStmt(Node *node, const char *queryString,
return NIL; return NIL;
} }
RenameStmt *stmt = castNode(RenameStmt, node);
EnsureCoordinator(); EnsureCoordinator();
RenameStmt *stmt = castNode(RenameStmt, node);
char *sql = DeparseTreeNode((Node *) stmt); char *sql = DeparseTreeNode((Node *) stmt);
List *commands = list_make3(DISABLE_DDL_PROPAGATION, List *commands = list_make3(DISABLE_DDL_PROPAGATION,