1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-19 13:42:17 +03:00

Add test for temporary file removal and WITH HOLD cursor

This new test, added in 009_log_temp_files, checks that the temporary
files created by a WITH HOLD cursor are dropped at the end of the
transaction where the transaction has been created.

The portal's executor is shutdown in PersistHoldablePortal(), after for
example some forced detoast, so as the cursor data can be accessed
without requiring a snapshot.

Author: Mircea Cadariu <cadariu.mircea@gmail.com>
Discussion: https://postgr.es/m/0a666d28-9080-4239-90d6-f6345bb43468@gmail.com
This commit is contained in:
Michael Paquier
2025-11-17 08:01:04 +09:00
parent 1b92fe7bb9
commit e7cde9dad2

View File

@@ -123,12 +123,27 @@ ok( $node->log_contains(
$log_offset),
"cursor");
note "cursor WITH HOLD: temporary file dropped under 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),
"cursor WITH HOLD");
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;