mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +03:00
Represent command completion tags as structs
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
This commit is contained in:
@@ -281,7 +281,7 @@ void
|
||||
PortalDefineQuery(Portal portal,
|
||||
const char *prepStmtName,
|
||||
const char *sourceText,
|
||||
const char *commandTag,
|
||||
CommandTag commandTag,
|
||||
List *stmts,
|
||||
CachedPlan *cplan)
|
||||
{
|
||||
@@ -289,10 +289,12 @@ PortalDefineQuery(Portal portal,
|
||||
AssertState(portal->status == PORTAL_NEW);
|
||||
|
||||
AssertArg(sourceText != NULL);
|
||||
AssertArg(commandTag != NULL || stmts == NIL);
|
||||
AssertArg(commandTag != CMDTAG_UNKNOWN || stmts == NIL);
|
||||
|
||||
portal->prepStmtName = prepStmtName;
|
||||
portal->sourceText = sourceText;
|
||||
portal->qc.commandTag = commandTag;
|
||||
portal->qc.nprocessed = 0;
|
||||
portal->commandTag = commandTag;
|
||||
portal->stmts = stmts;
|
||||
portal->cplan = cplan;
|
||||
|
||||
Reference in New Issue
Block a user