Re: pgsql: Drop unnamed portal immediately after execution to completion

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgsql: Drop unnamed portal immediately after execution to completion
Date: 2025-11-10 23:31:26
Message-ID: aRJ1zn0z-Bn0qc2H@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Mon, Nov 10, 2025 at 04:28:02PM -0500, Tom Lane wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> This patch doesn't look well-considered to me. One problem is that
>> it's a wire protocol change to fix a minor logging anomaly, which
>> seems disproportionate. Another problem is that the new portal-drop
>> behavior is conditional on whether XACT_FLAGS_NEEDIMMEDIATECOMMIT gets
>> set, which seems unprincipled. In addition to those points, I am not
>> entirely certain that the "here is no need for it beyond this point"
>> comment is correct. I mean, I think it will normally be true, but what
>> if the client wants to send a Describe message after-the-fact, or an
>> additional Execute message that will presumably return zero rows?
>
> Yeah, the whole idea of changing the wire-level behavior to fix this
> has been making me itch: I don't believe for a moment that it won't
> cause compatibility problems.
>
> I do not have a better proposal for fixing the problem though.

All the other solutions mentioned mean to work around the issue of the
unnamed portal still being present by maintaining the query string it
in a different context across multiple messages. And I doubt that
anybody would be thrilled by that.

If you think that we should continue to live with the protocol for
unnamed portals as-is and continue to live with the existing behavior,
meaning a revert of 1fd981f05369, that would not be the end of the
world here: we'd still have some tests that track the
past-and-currently-released behavior.

Even if strange, it works with the timing where the unnamed protocol
is dropped. Perhaps somebody would be able to come up with a approach
better than a more aggressive portal drop once completed, but I don't
quite see how much can be done as long as we manipulate the unnamed
portals this way (aka drop then with a follow-up bind, and expect the
logging to show the correct statements attached to a previous
message that we have no knowledge about). The original statement
logging did not really consider all these fancier cases with the
extended query protocol.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-11-10 23:34:03 Re: Add tests for object size limits of injection points
Previous Message Michael Paquier 2025-11-10 23:21:26 Re: [Proposal] Adding callback support for custom statistics kinds

Browse pgsql-committers by date

  From Date Subject
Previous Message Tom Lane 2025-11-10 21:59:47 pgsql: Stamp 13.23.