Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dbd23d2

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 03c53a7 commit dbd23d2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/backend/tcop/postgres.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,6 +2321,10 @@ exec_execute_message(const char *portal_name, long max_rows)
23212321
* message. The next protocol message will start a fresh timeout.
23222322
*/
23232323
disable_statement_timeout();
2324+
2325+
/* unnamed portal executed to completion, so close it */
2326+
if (portal_name[0] == '\0')
2327+
PortalDrop(portal, false);
23242328
}
23252329

23262330
/* Send appropriate CommandComplete to client */

0 commit comments

Comments
 (0)