From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Revert support for improved tracking of nested queries
Date: Thu, 12 Jun 2025 01:09:18 +0000
Message-ID: <E1uPWRR-001F8p-37@gemulon.postgresql.org> (raw)
Revert support for improved tracking of nested queries
This commit reverts the two following commits:
- 499edb09741b, track more precisely query locations for nested
statements.
- 06450c7b8c70, a follow-up fix of 499edb09741b with query locations.
The test introduced in this commit is not reverted. This is proving
useful to track a problem that only pgaudit was able to detect.
These prove to have issues with the tracking of SELECT statements, when
these use multiple parenthesis which is something supported by the
grammar. Incorrect location and lengths are causing pg_stat_statements
to become confused, failing its job in query normalization with
potential out-of-bound writes because the location and the length may
not match with what can be handled. A lot of the query patterns
discussed when this issue was reported have no test coverage in the main
regression test suite, or the recovery test 027_stream_regress.pl would
have caught the problems as pg_stat_statements is loaded by the node
running the regression tests. A first step would be to improve the test
coverage to stress more the query normalization logic.
A different portion of this work was done in 45e0ba30fc40, with the
addition of tests for nested queries. These can be left in the tree.
They are useful to track the way inner queries are currently tracked by
PGSS with non-top-level entries, and will be useful when reconsidering
in the future the work reverted here.
Reported-by: Alexander Kozhemyakin <a.kozhemyakin@postgrespro.ru>
Discussion: https://postgr.es/m/18947-cdd2668beffe02bf@postgresql.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f85f6ab051b7cf6950247e5fa6072c4130613555
Modified Files
--------------
contrib/pg_overexplain/expected/pg_overexplain.out | 12 +-
.../pg_stat_statements/expected/level_tracking.out | 182 +++++++++++----------
contrib/pg_stat_statements/expected/planning.out | 10 +-
contrib/pg_stat_statements/expected/select.out | 2 +-
contrib/pg_stat_statements/expected/utility.out | 2 +-
contrib/pg_stat_statements/sql/planning.sql | 4 +-
src/backend/parser/analyze.c | 90 +---------
src/backend/parser/gram.y | 80 +--------
src/include/nodes/parsenodes.h | 10 --
src/include/parser/parse_node.h | 16 --
10 files changed, 119 insertions(+), 289 deletions(-)
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: Revert support for improved tracking of nested queries
In-Reply-To: <E1uPWRR-001F8p-37@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox