Re: BUG #18947: TRAP: failed Assert("len_to_wrt >= 0") in pg_stat_statements

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, a(dot)kozhemyakin(at)postgrespro(dot)ru, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18947: TRAP: failed Assert("len_to_wrt >= 0") in pg_stat_statements
Date: 2025-06-12 23:50:46
Message-ID: aEtn1pJRWzJpnd1K@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Jun 12, 2025 at 08:46:26AM +0900, Michael Paquier wrote:
> Anyway, I am going to pull the plug on this one today, because we need
> to take a decision with beta2 approaching fast but it's mostly me
> being not fully confident that this is right as-is. If we're wrong in
> one path, that's an out-of-bound memory write waiting for us in PGSS
> for the query normalization, as this report proves, and that would be
> bad.

Two things that I have in mind regarding all that, worth dumping now:
- 06450c7b8c70 is reverted, but I have kept the test introduced in
this commit to check the location of multiple queries separated by
semicolons. This was something that we failed to track in the tree,
with David Steele's pgaudit only providing coverage.
- About the tests we could do to validate more in depth the locations
and lengths assigned to the parsed node without relying on PGSS and
EXPLAIN, which will support never support the full range of things
like views. I was wondering about the addition of a test module that
plugs into one or more hooks (only the post-parse one should be
enough), where we simply print the Nodes generated to a string using
the facility in src/backend/nodes/print.c. It would be then possible
to filter the output generated with some regex magic to print the
fields we want to check. That would work for the CREATE VIEW case,
for example, and it could be used for other things than just the
statement length and/or locations set in a gIven Node.
--
Michael

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2025-06-13 01:19:44 Re: BUG #18944: Assertion Failure in psql with idle_session_timeout Set
Previous Message Tom Lane 2025-06-12 21:50:12 Re: BUG #18953: Planner fails to build plan for complex query with LATERAL references