From 056a5a3f63f1a29d9266165ee6e25c6a51ddd63c Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 28 Mar 2018 18:57:10 -0400 Subject: Allow committing inside cursor loop Previously, committing or aborting inside a cursor loop was prohibited because that would close and remove the cursor. To allow that, automatically convert such cursors to holdable cursors so they survive commits or rollbacks. Portals now have a new state "auto-held", which means they have been converted automatically from pinned. An auto-held portal is kept on transaction commit or rollback, but is still removed when returning to the main loop on error. This supports all languages that have cursor loop constructs: PL/pgSQL, PL/Python, PL/Perl. Reviewed-by: Ildus Kurbangaliev --- src/backend/tcop/postgres.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index f7aa4a74844..6fc1cc272b5 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3938,6 +3938,8 @@ PostgresMain(int argc, char *argv[], if (am_walsender) WalSndErrorCleanup(); + PortalErrorCleanup(); + /* * We can't release replication slots inside AbortTransaction() as we * need to be able to start and abort transactions while having a slot -- cgit v1.2.3