diff --git a/src/backend/distributed/commands/utility_hook.c b/src/backend/distributed/commands/utility_hook.c index 2f152f8a5..512f20c44 100644 --- a/src/backend/distributed/commands/utility_hook.c +++ b/src/backend/distributed/commands/utility_hook.c @@ -154,6 +154,7 @@ static void RunPreprocessMainDBCommand(Node *parsetree, const char *queryString) static void RunPostprocessMainDBCommand(Node *parsetree); static bool IsStatementSupportedIn2PC(Node *parsetree); static bool DoesStatementRequireMarkDistributedFor2PC(Node *parsetree); +static bool IsObjectTypeSupported(Node *parsetree, TwoPcStatementInfo twoPcSupportedStatement); /* * ProcessUtilityParseTree is a convenience method to create a PlannedStmt out of @@ -1701,18 +1702,7 @@ IsStatementSupportedIn2PC(Node *parsetree) { if (type == T_GrantStmt) { - GrantStmt *stmt = castNode(GrantStmt, parsetree); - /* check if stmt->objtype is in supportedObjectTypes */ - for (int j = 0; j < - twoPcSupportedStatements[i].supportedObjectTypesSize; j++) - { - if (stmt->objtype == - twoPcSupportedStatements[i].supportedObjectTypes[j]) - { - return true; - } - } - return false; + return IsObjectTypeSupported(parsetree, twoPcSupportedStatements[i]); } } } @@ -1721,6 +1711,25 @@ IsStatementSupportedIn2PC(Node *parsetree) return false; } +bool IsObjectTypeSupported(Node *parsetree, TwoPcStatementInfo twoPcSupportedStatement) +{ + NodeTag type = nodeTag(parsetree); + if (type == T_GrantStmt) + { + GrantStmt *stmt = castNode(GrantStmt, parsetree); + /* check if stmt->objtype is in supportedObjectTypes */ + for (int j = 0; j < twoPcSupportedStatement.supportedObjectTypesSize; j++) + { + if (stmt->objtype == twoPcSupportedStatement.supportedObjectTypes[j]) + { + return true; + } + } + return false; + } + return false; +} + /* * DoesStatementRequireMarkDistributedFor2PC returns true if the statement should be marked