Fixes review comments

pull/7563/head
gurkanindibay 2024-03-27 13:51:23 +03:00
parent 082e35687c
commit 24e7389d3e
1 changed files with 29 additions and 26 deletions

View File

@ -74,68 +74,68 @@ static bool DropDbStmtCheckSupportedObjectType(Node *node);
static bool GrantStmtCheckSupportedObjectType(Node *node); static bool GrantStmtCheckSupportedObjectType(Node *node);
static bool SecLabelStmtCheckSupportedObjectType(Node *node); static bool SecLabelStmtCheckSupportedObjectType(Node *node);
static bool AlterDbStmtCheckSupportedObjectType(Node *node); static bool AlterDbStmtCheckSupportedObjectType(Node *node);
static bool AlterDbCanNotBeExecutedInTransaction(Node *node);
static bool CanNotBeExecutedInTransaction_True(Node *node);
static bool CanNotBeExecutedInTransaction_False(Node *node);
static bool AlterDbRenameCheckSupportedObjectType(Node *node); static bool AlterDbRenameCheckSupportedObjectType(Node *node);
static bool AlterDbOwnerCheckSupportedObjectType(Node *node); static bool AlterDbOwnerCheckSupportedObjectType(Node *node);
static bool CannotBeExecutedInTransaction_True(Node *node);
static bool CannotBeExecutedInTransaction_False(Node *node);
static bool AlterDbCannotBeExecutedInTransaction(Node *node);
/* /*
* OperationArray that holds NonMainDbDistributeObjectOps for different command types. * OperationArray that holds NonMainDbDistributeObjectOps for different command types.
*/ */
static const NonMainDbDistributeObjectOps *const OperationArray[] = { static const NonMainDbDistributeObjectOps *const OperationArray[] = {
[T_CreateRoleStmt] = &(NonMainDbDistributeObjectOps) { [T_CreateRoleStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_False, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_False,
.checkSupportedObjectType = NULL .checkSupportedObjectType = NULL
}, },
[T_DropRoleStmt] = &(NonMainDbDistributeObjectOps) { [T_DropRoleStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_False, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_False,
.checkSupportedObjectType = NULL .checkSupportedObjectType = NULL
}, },
[T_AlterRoleStmt] = &(NonMainDbDistributeObjectOps) { [T_AlterRoleStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_False, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_False,
.checkSupportedObjectType = NULL .checkSupportedObjectType = NULL
}, },
[T_GrantRoleStmt] = &(NonMainDbDistributeObjectOps) { [T_GrantRoleStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_False, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_False,
.checkSupportedObjectType = NULL .checkSupportedObjectType = NULL
}, },
[T_CreatedbStmt] = &(NonMainDbDistributeObjectOps) { [T_CreatedbStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_True, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_True,
.checkSupportedObjectType = CreateDbStmtCheckSupportedObjectType .checkSupportedObjectType = CreateDbStmtCheckSupportedObjectType
}, },
[T_DropdbStmt] = &(NonMainDbDistributeObjectOps) { [T_DropdbStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_True, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_True,
.checkSupportedObjectType = DropDbStmtCheckSupportedObjectType .checkSupportedObjectType = DropDbStmtCheckSupportedObjectType
}, },
[T_AlterDatabaseSetStmt] = &(NonMainDbDistributeObjectOps) { [T_AlterDatabaseSetStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_False, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_False,
.checkSupportedObjectType = NULL .checkSupportedObjectType = NULL
}, },
[T_AlterDatabaseStmt] = &(NonMainDbDistributeObjectOps) { [T_AlterDatabaseStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = AlterDbCanNotBeExecutedInTransaction, .cannotBeExecutedInTransaction = AlterDbCannotBeExecutedInTransaction,
.checkSupportedObjectType = AlterDbStmtCheckSupportedObjectType .checkSupportedObjectType = AlterDbStmtCheckSupportedObjectType
}, },
#if PG_VERSION_NUM >= PG_VERSION_15 #if PG_VERSION_NUM >= PG_VERSION_15
[T_AlterDatabaseRefreshCollStmt] = &(NonMainDbDistributeObjectOps) { [T_AlterDatabaseRefreshCollStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_False, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_False,
.checkSupportedObjectType = NULL .checkSupportedObjectType = NULL
}, },
#endif #endif
[T_RenameStmt] = &(NonMainDbDistributeObjectOps) { [T_RenameStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_False, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_False,
.checkSupportedObjectType = AlterDbRenameCheckSupportedObjectType .checkSupportedObjectType = AlterDbRenameCheckSupportedObjectType
}, },
[T_AlterOwnerStmt] = &(NonMainDbDistributeObjectOps) { [T_AlterOwnerStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_False, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_False,
.checkSupportedObjectType = AlterDbOwnerCheckSupportedObjectType .checkSupportedObjectType = AlterDbOwnerCheckSupportedObjectType
}, },
[T_GrantStmt] = &(NonMainDbDistributeObjectOps) { [T_GrantStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_False, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_False,
.checkSupportedObjectType = GrantStmtCheckSupportedObjectType .checkSupportedObjectType = GrantStmtCheckSupportedObjectType
}, },
[T_SecLabelStmt] = &(NonMainDbDistributeObjectOps) { [T_SecLabelStmt] = &(NonMainDbDistributeObjectOps) {
.cannotBeExecutedInTransaction = CanNotBeExecutedInTransaction_False, .cannotBeExecutedInTransaction = CannotBeExecutedInTransaction_False,
.checkSupportedObjectType = SecLabelStmtCheckSupportedObjectType .checkSupportedObjectType = SecLabelStmtCheckSupportedObjectType
}, },
}; };
@ -383,14 +383,6 @@ AlterDbStmtCheckSupportedObjectType(Node *node)
} }
static bool
AlterDbCanNotBeExecutedInTransaction(Node *node)
{
AlterDatabaseStmt *stmt = castNode(AlterDatabaseStmt, node);
return IsSetTablespaceStatement(stmt);
}
static bool static bool
AlterDbRenameCheckSupportedObjectType(Node *node) AlterDbRenameCheckSupportedObjectType(Node *node)
{ {
@ -423,15 +415,26 @@ SecLabelStmtCheckSupportedObjectType(Node *node)
} }
/*
* cannotBeExecutedInTransaction callbacks for OperationArray lie below.
*/
static bool static bool
CanNotBeExecutedInTransaction_True(Node *node) CannotBeExecutedInTransaction_True(Node *node)
{ {
return true; return true;
} }
static bool static bool
CanNotBeExecutedInTransaction_False(Node *node) CannotBeExecutedInTransaction_False(Node *node)
{ {
return false; return false;
} }
static bool
AlterDbCannotBeExecutedInTransaction(Node *node)
{
AlterDatabaseStmt *stmt = castNode(AlterDatabaseStmt, node);
return IsSetTablespaceStatement(stmt);
}