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

From a81f2312b895582475a733fae497594df2727dfa Mon Sep 17 00:00:00 2001
From: Mircea Cadariu <[email protected]>
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.pl
index 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 via email to