From: Mircea Cadariu <cadariu.mircea@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Sami Imseih <samimseih@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Frédéric Yhuel <frederic.yhuel@dalibo.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: pgsql: Drop unnamed portal immediately after execution to completion
Date: Fri, 14 Nov 2025 15:10:32 +0000
Message-ID: <0a666d28-9080-4239-90d6-f6345bb43468@gmail.com> (raw)
In-Reply-To: <aRbGaQTisuKMREuS@paquier.xyz>
References: <E1vGWIt-0056al-2N@gemulon.postgresql.org>
<CA+TgmoYFJyJNQw3RT7veO3M2BWRE9Aw4hprC5rOcawHZti-f8g@mail.gmail.com>
<1982325.1762810082@sss.pgh.pa.us>
<aRJ1zn0z-Bn0qc2H@paquier.xyz>
<CA+TgmoYR2OP8C+MHC8VCA80-r=Q09aF-_=juvBLvUKS09d__Mw@mail.gmail.com>
<00d71a54-2118-4b18-87e8-33f4a99dc624@gmail.com>
<aRV6D3vxMQTQ7CxG@paquier.xyz>
<e0ab1ea2-7084-44c5-b6aa-f01db7be7792@gmail.com>
<CAA5RZ0uFhj3bGbwSFWX1_hRhdHvp3JO1zAuSvp=XrfOoZ2GCcw@mail.gmail.com>
<aRbGaQTisuKMREuS@paquier.xyz>
Hi Michael,
I think I found a gap in the tests we added previously for documenting
the current behaviour. See attached patch for your consideration.
What's interesting about the holdable cursors scenario is that as far as
I can tell the temp files are cleaned up during PersistHoldablePortal
instead of PortalDrop.
Kind regards,
Mircea Cadariu
Attachments:v1-0001-add-holdable-cursors-test.patch (text/plain, 1.4K) download
From a81f2312b895582475a733fae497594df2727dfa Mon Sep 17 00:00:00 2001
From: Mircea Cadariu <cadariu.mircea@gmail.com>
Date: Fri, 14 Nov 2025 14:46:43 +0000
Subject: [PATCH v1] add holdable cursors test
---
.../modules/test_misc/t/009_log_temp_files.pl | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/test/modules/test_misc/t/009_log_temp_files.pl b/src/test/modules/test_misc/t/009_log_temp_files.plindex 462a949e41..5cac8f0122 100644--- a/src/test/modules/test_misc/t/009_log_temp_files.pl+++ b/src/test/modules/test_misc/t/009_log_temp_files.pl@@ -123,12 +123,27 @@ ok( $node->log_contains(
$log_offset),
"cursor");
+note "holdable cursor: temporary file dropped during COMMIT";+$log_offset = -s $node->logfile;+$node->safe_psql(+ "postgres", qq{+BEGIN;+DECLARE holdcur CURSOR WITH HOLD FOR SELECT a FROM foo ORDER BY a OFFSET 4996;+FETCH 10 FROM holdcur;+COMMIT;+CLOSE holdcur;+});+ok( $node->log_contains(+ qr/LOG:\s+temporary file: path.*\n.*\ STATEMENT:\s+COMMIT;/s,+ $log_offset),+ "holdable cursor");+
note "prepare/execute: temporary file dropped under EXECUTE";
$log_offset = -s $node->logfile;
$node->safe_psql(
"postgres", qq{
BEGIN;
-PREPARE p1 AS SELECT a FROM foo ORDER BY a OFFSET 4996;+PREPARE p1 AS SELECT a FROM foo ORDER BY a OFFSET 4997;
EXECUTE p1;
DEALLOCATE p1;
END;
--
2.39.5 (Apple Git-154)
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: cadariu.mircea@gmail.com, michael@paquier.xyz, samimseih@gmail.com, robertmhaas@gmail.com, tgl@sss.pgh.pa.us, frederic.yhuel@dalibo.com, pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Drop unnamed portal immediately after execution to completion
In-Reply-To: <0a666d28-9080-4239-90d6-f6345bb43468@gmail.com>
* 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