summaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/plancache.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2020-03-02 18:19:51 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2020-03-02 18:19:51 -0300
commit2f9661311b83dc481fc19f6e3bda015392010a40 (patch)
tree9a1aabe1d15ac894f7badbc886ae33f16bbfc3b6 /src/backend/utils/cache/plancache.c
parent7b425a5283cb2c8a452c2e79d6218e41373fd641 (diff)
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
Diffstat (limited to 'src/backend/utils/cache/plancache.c')
-rw-r--r--src/backend/utils/cache/plancache.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/utils/cache/plancache.c b/src/backend/utils/cache/plancache.c
index c47be0ba4cd..dbae18d68c6 100644
--- a/src/backend/utils/cache/plancache.c
+++ b/src/backend/utils/cache/plancache.c
@@ -158,12 +158,12 @@ InitPlanCache(void)
*
* raw_parse_tree: output of raw_parser(), or NULL if empty query
* query_string: original query text
- * commandTag: compile-time-constant tag for query, or NULL if empty query
+ * commandTag: command tag for query, or UNKNOWN if empty query
*/
CachedPlanSource *
CreateCachedPlan(RawStmt *raw_parse_tree,
const char *query_string,
- const char *commandTag)
+ CommandTag commandTag)
{
CachedPlanSource *plansource;
MemoryContext source_context;
@@ -241,12 +241,12 @@ CreateCachedPlan(RawStmt *raw_parse_tree,
*
* raw_parse_tree: output of raw_parser(), or NULL if empty query
* query_string: original query text
- * commandTag: compile-time-constant tag for query, or NULL if empty query
+ * commandTag: command tag for query, or NULL if empty query
*/
CachedPlanSource *
CreateOneShotCachedPlan(RawStmt *raw_parse_tree,
const char *query_string,
- const char *commandTag)
+ CommandTag commandTag)
{
CachedPlanSource *plansource;