From 2f9661311b83dc481fc19f6e3bda015392010a40 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Mon, 2 Mar 2020 18:19:51 -0300 Subject: Represent command completion tags as structs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The backend was using strings to represent command tags and doing string comparisons in multiple places, but that's slow and unhelpful. Create a new command list with a supporting structure to use instead; this is stored in a tag-list-file that can be tailored to specific purposes with a caller-definable C macro, similar to what we do for WAL resource managers. The first first such uses are a new CommandTag enum and a CommandTagBehavior struct. Replace numerous occurrences of char *completionTag with a QueryCompletion struct so that the code no longer stores information about completed queries in a cstring. Only at the last moment, in EndCommand(), does this get converted to a string. EventTriggerCacheItem no longer holds an array of palloc’d tag strings in sorted order, but rather just a Bitmapset over the CommandTags. Author: Mark Dilger, with unsolicited help from Álvaro Herrera Reviewed-by: John Naylor, Tom Lane Discussion: https://postgr.es/m/981A9DB4-3F0C-4DA5-88AD-CB9CFF4D6CAD@enterprisedb.com --- src/backend/executor/functions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/backend/executor/functions.c') diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 5cff6c43216..9b45a8a9a0e 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -530,7 +530,7 @@ init_execution_state(List *queryTree_list, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), /* translator: %s is a SQL statement name */ errmsg("%s is not allowed in a SQL function", - CreateCommandTag(stmt->utilityStmt)))); + CreateCommandName(stmt->utilityStmt)))); } if (fcache->readonly_func && !CommandIsReadOnly(stmt)) @@ -538,7 +538,7 @@ init_execution_state(List *queryTree_list, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), /* translator: %s is a SQL statement name */ errmsg("%s is not allowed in a non-volatile function", - CreateCommandTag((Node *) stmt)))); + CreateCommandName((Node *) stmt)))); /* OK, build the execution_state for this query */ newes = (execution_state *) palloc(sizeof(execution_state)); -- cgit v1.2.3