Re: Regression in statement locations - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Regression in statement locations
Date
Msg-id aCv-EZpnoLA3s5ux@paquier.xyz
Whole thread Raw
In response to Re: Regression in statement locations  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Regression in statement locations
List pgsql-hackers
On Tue, May 20, 2025 at 08:38:47AM +0900, Michael Paquier wrote:
> With the semicolon in place, stmt_len gets set for the last query of
> the string.  Still digging more..

And got it.  The problem is that we are failing to update the
statement location in a couple of cases with subqueries, and that we
should handle (p_stmt_len == 0) as of using the remaining bytes in
the string when a location is available, but the code was too
aggressive in thinking that the length = 0 case should be always
discarded.

Once I have fixed that, I've been a bit puzzled by the difference in
output in the tests of pg_overexplain, but I think that the new output
is actually the correct one: the queries whose plan outputs have
changed are passed as arguments of the explain_filter() function,
hence the location of the inner queries point at the start location of
the inner query instead of the start of the top-level query.  Note
that if you add a semicolon at the end of these three queries in the
pg_overexplain tests, we finish with an end location reported.

I have also played with 499edb0 reverted and noted that the results of
pg_overexplain were inconsistent when the module has been originally
introduced, with two queries choking a bit.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Add comment explaining why queryid is int64 in pg_stat_statements
Next
From: Amit Kapila
Date:
Subject: Re: Document default values for pgoutput options + fix missing initialization for "origin"