Skip to content

Commit 0b2efb3

Browse files
Sami Imseih (AWS)Commitfest Bot
Sami Imseih (AWS)
authored and
Commitfest Bot
committed
Correct timing of portal drop in an execute message
In the extended query protocol, unnamed portals within a transaction are dropped whenever the next query execution starts, which at that point creating a new unnamed portal requires dropping the previous one. This is problematic for problematic for several reasons, not least because it delays the execution of the ExecutorEnd hook or delays the logging of temp file usage ( log_temp_files ). This patch addresses the issue by ensuring that the portal is dropped only after it has been fully fetched to completion, in the cases that the portal is not a transaction control statement or requires to be run outside of a transaction block.
1 parent 15b1b4d commit 0b2efb3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/backend/tcop/postgres.c

+4
Original file line numberDiff line numberDiff line change
@@ -2323,6 +2323,10 @@ exec_execute_message(const char *portal_name, long max_rows)
23232323
* message. The next protocol message will start a fresh timeout.
23242324
*/
23252325
disable_statement_timeout();
2326+
2327+
/* unnamed portal executed to completion, so close it */
2328+
if (portal_name[0] == '\0')
2329+
PortalDrop(portal, false);
23262330
}
23272331

23282332
/* Send appropriate CommandComplete to client */

0 commit comments

Comments
 (0)