pgsql: Mark JumbleState as a const in the post_parse_analyze hook - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Mark JumbleState as a const in the post_parse_analyze hook
Date
Msg-id E1w9zsE-003LYx-3A@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Mark JumbleState as a const in the post_parse_analyze hook

This commit changes the post_parse_analyze_hook_type() hook to take a
const JumbleState, to tell external modules that they are not allowed to
touch the JumbleState that has been compiled by the core code.  This
fixes a pretty old problem with pg_stat_statements, that had always the
idea of modifying the lengths of the constants stored in the
JumbleState.  The previous state could confuse extensions that need to
look at a JumbleState depending on the loading order, if
pg_stat_statements is part of the stack loaded.

Another piece included in this commit is the move of the routine
fill_in_constant_lengths() to queryjumblefuncs.c, to give an option to
extensions to compile the lengths of the constants, if necessary.  I was
surprised by the number of external code that carries a copy of this
routine (see the thread for details).  Previously, this routine modified
JumbleState.  It now copies the set of LocationLens from JumbleState,
and fills the constant lengths for separate use.

pg_stat_statements is updated to use the new ComputeConstantLengths().
JumbleState is now marked with a const in the module, where relevant.

Author: Sami Imseih <samimseih@gmail.com>
Co-authored-by: Lukas Fittl <lukas@fittl.com>
Discussion: https://postgr.es/m/CAA5RZ0tZp5qU0ikZEEqJnxvdSNGh1DWv80sb-k4QAUmiMoOp_Q@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/49cc0d41488b92a1d547e278b459c3b224393c8f

Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c | 176 +++---------------------
src/backend/nodes/queryjumblefuncs.c            | 155 +++++++++++++++++++++
src/include/nodes/queryjumble.h                 |   3 +
src/include/parser/analyze.h                    |   2 +-
4 files changed, 179 insertions(+), 157 deletions(-)


pgsql-committers by date:

Previous
From: John Naylor
Date:
Subject: pgsql: Split CREATE STATISTICS error reasons out into errdetails
Next
From: John Naylor
Date:
Subject: pgsql: Simplify SortSupport for the macaddr data type