agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Mark JumbleState as a const in the post_parse_analyze hook
Date: Tue, 07 Apr 2026 06:25:19 +0000
Message-ID: <E1w9zsE-003LYx-3A@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1w9zsE-003LYx-3A@gemulon.postgresql.org>
Permalink:  ../E1w9zsE-003LYx-3A@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w9zsE-003LYx-3A@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Mark JumbleState as a const in the post_parse_analyze hook
  In-Reply-To: <E1w9zsE-003LYx-3A@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox