From 32a11bdf6cb577518ba9969cfb02bf296de7da48 Mon Sep 17 00:00:00 2001 From: Marco Slot Date: Thu, 26 Sep 2019 11:43:35 +0200 Subject: [PATCH] Return early for common commands in the utility hook (#3031) We started copying parse trees by default further on in `multi_ProcessUtility`. That's not a problem for maintenance command, but might register for things like `PREPARE` and `EXECUTE`, which might happen thousands of times per second. Add a few common commands to the check at the start. --- src/backend/distributed/commands/utility_hook.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/commands/utility_hook.c b/src/backend/distributed/commands/utility_hook.c index e1f90aa22..f6911eb70 100644 --- a/src/backend/distributed/commands/utility_hook.c +++ b/src/backend/distributed/commands/utility_hook.c @@ -53,6 +53,7 @@ #include "distributed/version_compat.h" #include "distributed/worker_transaction.h" #include "lib/stringinfo.h" +#include "nodes/parsenodes.h" #include "nodes/pg_list.h" #include "tcop/utility.h" #include "utils/builtins.h" @@ -116,9 +117,19 @@ multi_ProcessUtility(PlannedStmt *pstmt, List *ddlJobs = NIL; bool checkExtensionVersion = false; - if (IsA(parsetree, TransactionStmt)) + if (IsA(parsetree, TransactionStmt) || + IsA(parsetree, LockStmt) || + IsA(parsetree, ListenStmt) || + IsA(parsetree, NotifyStmt) || + IsA(parsetree, ExecuteStmt) || + IsA(parsetree, PrepareStmt) || + IsA(parsetree, DiscardStmt) || + IsA(parsetree, DeallocateStmt)) { /* + * Skip additional checks for common commands that do not have any + * Citus-specific logic. + * * Transaction statements (e.g. ABORT, COMMIT) can be run in aborted * transactions in which case a lot of checks cannot be done safely in * that state. Since we never need to intercept transaction statements,