Use PROCESS_UTILITY_QUERY in utility calls

When we use PROCESS_UTILITY_TOPLEVEL it causes some problems when
combined with other extensions such as pg_audit. With this commit we use
PROCESS_UTILITY_QUERY in the codebase to fix those problems.

(cherry picked from commit dcf54eaf2a)

 Conflicts:
	src/backend/distributed/commands/alter_table.c
	src/backend/distributed/commands/cascade_table_operation_for_connected_relations.c
	src/backend/distributed/executor/local_executor.c
	src/backend/distributed/utils/role.c
	src/backend/distributed/worker/worker_create_or_replace.c
	src/backend/distributed/worker/worker_data_fetch_protocol.c
pull/5087/head
SaitTalhaNisanci 2021-02-19 13:42:19 +03:00 committed by Onur Tirtir
parent 1eec630640
commit 45671a1caa
6 changed files with 14 additions and 13 deletions

View File

@ -569,7 +569,7 @@ ExecuteAndLogDDLCommand(const char *commandString)
ereport(DEBUG4, (errmsg("executing \"%s\"", commandString))); ereport(DEBUG4, (errmsg("executing \"%s\"", commandString)));
Node *parseTree = ParseTreeNode(commandString); Node *parseTree = ParseTreeNode(commandString);
CitusProcessUtility(parseTree, commandString, PROCESS_UTILITY_TOPLEVEL, CitusProcessUtility(parseTree, commandString, PROCESS_UTILITY_QUERY,
NULL, None_Receiver, NULL); NULL, None_Receiver, NULL);
} }

View File

@ -1658,7 +1658,7 @@ UndistributeTable(Oid relationId)
Node *parseTree = ParseTreeNode(tableCreationCommand); Node *parseTree = ParseTreeNode(tableCreationCommand);
RelayEventExtendNames(parseTree, schemaName, hashOfName); RelayEventExtendNames(parseTree, schemaName, hashOfName);
CitusProcessUtility(parseTree, tableCreationCommand, PROCESS_UTILITY_TOPLEVEL, CitusProcessUtility(parseTree, tableCreationCommand, PROCESS_UTILITY_QUERY,
NULL, None_Receiver, NULL); NULL, None_Receiver, NULL);
} }

View File

@ -409,7 +409,8 @@ LocallyExecuteUtilityTask(const char *localTaskQueryCommand)
* process utility. * process utility.
*/ */
CitusProcessUtility(localTaskRawParseTree, localTaskQueryCommand, CitusProcessUtility(localTaskRawParseTree, localTaskQueryCommand,
PROCESS_UTILITY_TOPLEVEL, NULL, None_Receiver, NULL); PROCESS_UTILITY_QUERY, NULL, None_Receiver,
NULL);
} }
} }
} }

View File

@ -41,7 +41,7 @@ alter_role_if_exists(PG_FUNCTION_ARGS)
Node *parseTree = ParseTreeNode(utilityQuery); Node *parseTree = ParseTreeNode(utilityQuery);
CitusProcessUtility(parseTree, utilityQuery, PROCESS_UTILITY_TOPLEVEL, NULL, CitusProcessUtility(parseTree, utilityQuery, PROCESS_UTILITY_QUERY, NULL,
None_Receiver, NULL); None_Receiver, NULL);
PG_RETURN_BOOL(true); PG_RETURN_BOOL(true);
@ -98,7 +98,7 @@ worker_create_or_alter_role(PG_FUNCTION_ARGS)
CitusProcessUtility(parseTree, CitusProcessUtility(parseTree,
createRoleUtilityQuery, createRoleUtilityQuery,
PROCESS_UTILITY_TOPLEVEL, PROCESS_UTILITY_QUERY,
NULL, NULL,
None_Receiver, NULL); None_Receiver, NULL);
@ -126,7 +126,7 @@ worker_create_or_alter_role(PG_FUNCTION_ARGS)
CitusProcessUtility(parseTree, CitusProcessUtility(parseTree,
alterRoleUtilityQuery, alterRoleUtilityQuery,
PROCESS_UTILITY_TOPLEVEL, PROCESS_UTILITY_QUERY,
NULL, NULL,
None_Receiver, NULL); None_Receiver, NULL);

View File

@ -111,12 +111,12 @@ worker_create_or_replace_object(PG_FUNCTION_ARGS)
RenameStmt *renameStmt = CreateRenameStatement(&address, newName); RenameStmt *renameStmt = CreateRenameStatement(&address, newName);
const char *sqlRenameStmt = DeparseTreeNode((Node *) renameStmt); const char *sqlRenameStmt = DeparseTreeNode((Node *) renameStmt);
CitusProcessUtility((Node *) renameStmt, sqlRenameStmt, CitusProcessUtility((Node *) renameStmt, sqlRenameStmt,
PROCESS_UTILITY_TOPLEVEL, PROCESS_UTILITY_QUERY,
NULL, None_Receiver, NULL); NULL, None_Receiver, NULL);
} }
/* apply create statement locally */ /* apply create statement locally */
CitusProcessUtility(parseTree, sqlStatement, PROCESS_UTILITY_TOPLEVEL, NULL, CitusProcessUtility(parseTree, sqlStatement, PROCESS_UTILITY_QUERY, NULL,
None_Receiver, NULL); None_Receiver, NULL);
/* type has been created */ /* type has been created */

View File

@ -396,7 +396,7 @@ worker_apply_shard_ddl_command(PG_FUNCTION_ARGS)
/* extend names in ddl command and apply extended command */ /* extend names in ddl command and apply extended command */
RelayEventExtendNames(ddlCommandNode, schemaName, shardId); RelayEventExtendNames(ddlCommandNode, schemaName, shardId);
CitusProcessUtility(ddlCommandNode, ddlCommand, PROCESS_UTILITY_TOPLEVEL, NULL, CitusProcessUtility(ddlCommandNode, ddlCommand, PROCESS_UTILITY_QUERY, NULL,
None_Receiver, NULL); None_Receiver, NULL);
PG_RETURN_VOID(); PG_RETURN_VOID();
@ -428,7 +428,7 @@ worker_apply_inter_shard_ddl_command(PG_FUNCTION_ARGS)
RelayEventExtendNamesForInterShardCommands(ddlCommandNode, leftShardId, RelayEventExtendNamesForInterShardCommands(ddlCommandNode, leftShardId,
leftShardSchemaName, rightShardId, leftShardSchemaName, rightShardId,
rightShardSchemaName); rightShardSchemaName);
CitusProcessUtility(ddlCommandNode, ddlCommand, PROCESS_UTILITY_TOPLEVEL, NULL, CitusProcessUtility(ddlCommandNode, ddlCommand, PROCESS_UTILITY_QUERY, NULL,
None_Receiver, NULL); None_Receiver, NULL);
PG_RETURN_VOID(); PG_RETURN_VOID();
@ -461,7 +461,7 @@ worker_apply_sequence_command(PG_FUNCTION_ARGS)
} }
/* run the CREATE SEQUENCE command */ /* run the CREATE SEQUENCE command */
CitusProcessUtility(commandNode, commandString, PROCESS_UTILITY_TOPLEVEL, NULL, CitusProcessUtility(commandNode, commandString, PROCESS_UTILITY_QUERY, NULL,
None_Receiver, NULL); None_Receiver, NULL);
CommandCounterIncrement(); CommandCounterIncrement();
@ -669,7 +669,7 @@ worker_append_table_to_shard(PG_FUNCTION_ARGS)
SetUserIdAndSecContext(CitusExtensionOwner(), SECURITY_LOCAL_USERID_CHANGE); SetUserIdAndSecContext(CitusExtensionOwner(), SECURITY_LOCAL_USERID_CHANGE);
CitusProcessUtility((Node *) localCopyCommand, queryString->data, CitusProcessUtility((Node *) localCopyCommand, queryString->data,
PROCESS_UTILITY_TOPLEVEL, NULL, None_Receiver, NULL); PROCESS_UTILITY_QUERY, NULL, None_Receiver, NULL);
SetUserIdAndSecContext(savedUserId, savedSecurityContext); SetUserIdAndSecContext(savedUserId, savedSecurityContext);
@ -782,7 +782,7 @@ AlterSequenceMinMax(Oid sequenceId, char *schemaName, char *sequenceName,
/* since the command is an AlterSeqStmt, a dummy command string works fine */ /* since the command is an AlterSeqStmt, a dummy command string works fine */
CitusProcessUtility((Node *) alterSequenceStatement, dummyString, CitusProcessUtility((Node *) alterSequenceStatement, dummyString,
PROCESS_UTILITY_TOPLEVEL, NULL, None_Receiver, NULL); PROCESS_UTILITY_QUERY, NULL, None_Receiver, NULL);
} }
} }