public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michael Paquier <[email protected]>
To: Anthonin Bonnefoy <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Correctly propagate queryId for utility stmt in function
Date: Fri, 19 Jul 2024 09:13:11 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAO6_XqrGp-uwBqi3vBPLuRULKkddjC7R5QZCgsFren=8E+m2Sg@mail.gmail.com>
References: <CAO6_XqrGp-uwBqi3vBPLuRULKkddjC7R5QZCgsFren=8E+m2Sg@mail.gmail.com>

On Thu, Jul 18, 2024 at 01:37:40PM +0200, Anthonin Bonnefoy wrote:
> For utility statements defined within a function, the queryTree is
> copied to a plannedStmt as utility commands don't require planning.
> However, the queryId is not propagated to the plannedStmt. This leads
> to plugins relying on queryId like pg_stat_statements to not be able
> to track utility statements within function calls.

You are right, good catch.  This leads to only partial information
being reported depending on the setting of pg_stat_statements.track.
It is a point of detail, but I'd rather expand a bit more the tests on
top of what you are proposing:
- Upper and down-casing for non-top utility commands, to check that
they are counted consistently.
- Check with pg_stat_statements.track = 'top'
- Not cross-checking pg_stat_statements.track_utility = false is OK.

While this qualifies as something that could go down to all the stable
branches, it is much easier to think about utility statements in 16~
now that we compile the query IDs depending on their parsed tree, so
will apply down to that.

pg_stat_statements tests have also been refactored in 16~, but that's
a nit here..
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, ../[email protected]/2-signature.asc)
  download

view thread (2+ messages)

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: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Correctly propagate queryId for utility stmt in function
  In-Reply-To: <[email protected]>

* 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