pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Drop unnamed portal immediately after execution to completion
Date: Wed, 05 Nov 2025 05:43:31 +0000
Message-ID: <E1vGWIt-0056al-2N@gemulon.postgresql.org> (raw)

Drop unnamed portal immediately after execution to completion

Previously, unnamed portals were kept until the next Bind message or the
end of the transaction.  This could cause temporary files to persist
longer than expected and make logging not reflect the actual SQL
responsible for the temporary file.

This patch changes exec_execute_message() to drop unnamed portals
immediately after execution to completion at the end of an Execute
message, making their removal more aggressive.  This forces temporary
file cleanups to happen at the same time as the completion of the portal
execution, with statement logging correctly reflecting to which
statements these temporary files were attached to (see the diffs in the
TAP test updated by this commit for an idea).

The documentation is updated to describe the lifetime of unnamed
portals, and test cases are updated to verify temporary file removal and
proper statement logging after unnamed portal execution.  This changes
how unnamed portals are handled in the protocol, hence no backpatch is
done.

Author: Frédéric Yhuel <frederic.yhuel@dalibo.com>
Co-Authored-by: Sami Imseih <samimseih@gmail.com>
Co-Authored-by: Mircea Cadariu <cadariu.mircea@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0tTrTUoEr3kDXCuKsvqYGq8OOHiBwoD-dyJocq95uEOTQ%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1fd981f05369340a8afa4d013a350b0b2ac6e33e

Modified Files
--------------
doc/src/sgml/protocol.sgml                         |  4 +--
src/backend/tcop/postgres.c                        | 10 +++++++
src/test/modules/test_misc/t/009_log_temp_files.pl | 33 +++++++++++-----------
3 files changed, 29 insertions(+), 18 deletions(-)



view thread (14+ messages)  latest in thread

Message-ID: <E1vGWIt-0056al-2N@gemulon.postgresql.org>
Permalink:  ../E1vGWIt-0056al-2N@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vGWIt-0056al-2N@gemulon.postgresql.org

 · 

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: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Drop unnamed portal immediately after execution to completion
  In-Reply-To: <E1vGWIt-0056al-2N@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox