pgsql: Represent command completion tags as structs

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Represent command completion tags as structs
Date: 2020-03-02 21:44:08
Message-ID: E1j8srA-00033t-42@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2f9661311b83dc481fc19f6e3bda015392010a40

Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c | 20 +-
contrib/sepgsql/hooks.c | 6 +-
doc/src/sgml/event-trigger.sgml | 2 +-
src/backend/commands/createas.c | 14 +-
src/backend/commands/event_trigger.c | 160 +-----
src/backend/commands/matview.c | 2 +-
src/backend/commands/portalcmds.c | 16 +-
src/backend/commands/prepare.c | 4 +-
src/backend/executor/execMain.c | 4 +-
src/backend/executor/functions.c | 4 +-
src/backend/executor/spi.c | 21 +-
src/backend/replication/logical/decode.c | 2 +-
src/backend/replication/walsender.c | 18 +-
src/backend/tcop/Makefile | 1 +
src/backend/tcop/cmdtag.c | 98 ++++
src/backend/tcop/dest.c | 32 +-
src/backend/tcop/postgres.c | 33 +-
src/backend/tcop/pquery.c | 112 ++--
src/backend/tcop/utility.c | 561 ++++++++++-----------
src/backend/utils/cache/evtcache.c | 30 +-
src/backend/utils/cache/plancache.c | 8 +-
src/backend/utils/mmgr/portalmem.c | 6 +-
src/include/commands/createas.h | 3 +-
src/include/commands/event_trigger.h | 3 +-
src/include/commands/matview.h | 2 +-
src/include/commands/portalcmds.h | 2 +-
src/include/commands/prepare.h | 2 +-
src/include/tcop/cmdtag.h | 58 +++
src/include/tcop/cmdtaglist.h | 218 ++++++++
src/include/tcop/dest.h | 6 +-
src/include/tcop/pquery.h | 2 +-
src/include/tcop/utility.h | 15 +-
src/include/utils/evtcache.h | 3 +-
src/include/utils/plancache.h | 7 +-
src/include/utils/portal.h | 6 +-
src/pl/plperl/plperl.c | 2 +-
src/pl/plpgsql/src/pl_exec.c | 10 +-
src/pl/tcl/pltcl.c | 3 +-
.../modules/test_ddl_deparse/test_ddl_deparse.c | 2 +-
39 files changed, 877 insertions(+), 621 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2020-03-02 23:36:49 Re: pgsql: Revert "initdb: Change authentication defaults"
Previous Message Tom Lane 2020-03-02 19:35:26 pgsql: Blacklist port/win32_msvc/utime.h in cpluspluscheck and headersc