Re: pg_stat_statements: Fix nested tracking for implicitly closed cursors - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: pg_stat_statements: Fix nested tracking for implicitly closed cursors
Date
Msg-id aW2igHBhiRI_Ud7Q@paquier.xyz
Whole thread Raw
In response to Re: pg_stat_statements: Fix nested tracking for implicitly closed cursors  (Sami Imseih <samimseih@gmail.com>)
Responses Re: pg_stat_statements: Fix nested tracking for implicitly closed cursors
List pgsql-hackers
On Fri, Jan 16, 2026 at 06:12:16PM -0600, Sami Imseih wrote:
> This is the key point to this fix. So, in v2, is_txn_end is reset at the start
> of pgss_planner, pgss_post_parse_analyze and pgss_ProcessUtility. But now
> I realized that is_txn_end should also be reset at
> pgss_ExecutorStart/Run and should
> always be reset at the end of pgss_ExecutorEnd.

Hmm.  While reading through the patch, I am wondering if this approach
to this kind of problem is the right thing to do long-term, relying on
a static flag to decide if the nesting level should be manipulated or
not when we end the executor.  pgss is not the only module where I
have seen that we want to track a nesting level in a precise way.  So
could be it more flexible to attach that to a backend structure at
this point and make manipulations of this number through the core
backend, reducing TRY/CATCH blocks required in extension code?
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Richard Guo
Date:
Subject: Re: Fwd: pg18 bug? SELECT query doesn't work
Next
From: Peter Smith
Date:
Subject: Re: Proposal: Conflict log history table for Logical Replication