Skip to content

Commit f4d5aa3

Browse files
author
Commitfest Bot
committed
[CF 5724] v17 - temporary file usage report with extended protocol and unnamed portals
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5724 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CAA5RZ0saywFCjKFrSS9p2Yv4o35o0yh9JnHW+SEs9KCeOhbD=A@mail.gmail.com Author(s): Sami Imseih, Frédéric Yhuel
2 parents 0a3d27b + 0a23b48 commit f4d5aa3

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

doc/src/sgml/protocol.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,8 @@ SELCT 1/0;<!-- this typo is intentional -->
10061006
<para>
10071007
If successfully created, a named portal object lasts till the end of the
10081008
current transaction, unless explicitly destroyed. An unnamed portal is
1009-
destroyed at the end of the transaction, or as soon as the next Bind
1010-
statement specifying the unnamed portal as destination is issued. (Note
1009+
destroyed at the end of the transaction, or as soon as the statement
1010+
specifying the unnamed portal as destination is processed to completion. (Note
10111011
that a simple Query message also destroys the unnamed portal.) Named
10121012
portals must be explicitly closed before they can be redefined by another
10131013
Bind message, but this is not required for the unnamed portal.

src/backend/tcop/postgres.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,6 +2327,13 @@ exec_execute_message(const char *portal_name, long max_rows)
23272327
* message. The next protocol message will start a fresh timeout.
23282328
*/
23292329
disable_statement_timeout();
2330+
2331+
/*
2332+
* We completed fetching from an unnamed portal, we don't need it
2333+
* beyond this point.
2334+
*/
2335+
if (portal->name[0] == '\0')
2336+
PortalDrop(portal, false);
23302337
}
23312338

23322339
/* Send appropriate CommandComplete to client */

src/test/modules/test_misc/t/009_log_temp_files.pl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
END;
4040
});
4141
ok( $node->log_contains(
42-
qr/LOG:\s+temporary file: path.*\n.*\ STATEMENT:\s+SELECT 'unnamed portal'/s,
42+
qr/LOG:\s+temporary file: path.*\n.*\ STATEMENT:\s+SELECT a FROM foo ORDER BY a OFFSET \$1/s,
4343
$log_offset),
4444
"unnamed portal");
4545

@@ -49,10 +49,8 @@
4949
"postgres", qq{
5050
SELECT a FROM foo ORDER BY a OFFSET \$1 \\bind 4991 \\g
5151
});
52-
ok( $node->log_contains(qr/LOG:\s+temporary file:/s, $log_offset),
53-
"bind and implicit transaction, temporary file removed");
54-
ok( !$node->log_contains(qr/STATEMENT:/s, $log_offset),
55-
"bind and implicit transaction, no statement logged");
52+
ok( $node->log_contains(qr/LOG:\s+temporary file: path.*\n.*\ STATEMENT:\s+SELECT a FROM foo ORDER BY a OFFSET \$1/s, $log_offset),
53+
"bind and implicit transaction");
5654

5755
note "named portal: temporary file dropped under second SELECT query";
5856
$node->safe_psql(
@@ -64,7 +62,7 @@
6462
END;
6563
});
6664
ok( $node->log_contains(
67-
qr/LOG:\s+temporary file: path.*\n.*\ STATEMENT:\s+SELECT 'named portal'/s,
65+
qr/LOG:\s+temporary file: path.*\n.*\ STATEMENT:\s+SELECT a FROM foo ORDER BY a OFFSET \$1/s,
6866
$log_offset),
6967
"named portal");
7068

@@ -78,7 +76,7 @@
7876
\\endpipeline
7977
});
8078
ok( $node->log_contains(
81-
qr/LOG:\s+temporary file: path.*\n.*\ STATEMENT:\s+SELECT 'pipelined query'/s,
79+
qr/LOG:\s+temporary file: path.*\n.*\ STATEMENT:\s+SELECT a FROM foo ORDER BY a OFFSET \$1/s,
8280
$log_offset),
8381
"pipelined query");
8482

@@ -89,10 +87,8 @@
8987
SELECT a, a, a FROM foo ORDER BY a OFFSET \$1 \\parse p1
9088
\\bind_named p1 4993 \\g
9189
});
92-
ok($node->log_contains(qr/LOG:\s+temporary file:/s, $log_offset),
93-
"parse and bind, temporary file removed");
94-
ok(!$node->log_contains(qr/STATEMENT:/s, $log_offset),
95-
"bind and bind, no statement logged");
90+
ok($node->log_contains(qr/LOG:\s+temporary file: path.*\n.*\ STATEMENT:\s+SELECT a, a, a FROM foo ORDER BY a OFFSET \$1/s, $log_offset),
91+
"parse and bind");
9692

9793
note "simple query: temporary file dropped under SELECT query";
9894
$log_offset = -s $node->logfile;

0 commit comments

Comments
 (0)