8000 Oops, in the previous fix to prevent a cursor that's being used in a FOR · percona/postgres@b9ded24 · GitHub
[go: up one dir, main page]

Skip to content

Commit b9ded24

Browse files
committed
Oops, in the previous fix to prevent a cursor that's being used in a FOR
loop from being dropped, I missed subtransaction cleanup. Pinned portals must be dropped at subtransaction cleanup just as they are at main transaction cleanup. Per bug #5556 by Robert Walker. Backpatch to 8.0, 7.4 didn't have subtransactions.
1 parent dae1190 commit b9ded24

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/backend/utils/mmgr/portalmem.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.82.2.3 2010/07/05 09:27:42 heikki Exp $
15+
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.82.2.4 2010/07/13 09:03:01 heikki Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -294,6 +294,9 @@ PortalCreateHoldStore(Portal portal)
294294
/*
295295
* PinPortal
296296
* Protect a portal from dropping.
297+
*
298+
* A pinned portal is still unpinned and dropped at transaction or
299+
* subtransaction abort.
297300
*/
298301
void
299302
PinPortal(Portal portal)
@@ -798,6 +801,14 @@ AtSubCleanup_Portals(SubTransactionId mySubid)
798801
if (portal->createSubid != mySubid)
799802
continue;
800803

804+
/*
805+
* If a portal is still pinned, forcibly unpin it. PortalDrop will not
806+
* let us drop the portal otherwise. Whoever pinned the portal was
807+
* interrupted by the abort too and won't try to use it anymore.
808+
*/
809+
if (portal->portalPinned)
810+
portal->portalPinned = false;
811+
801812
/* Zap it. */
802813
PortalDrop(portal, false);
803814
}

0 commit comments

Comments
 (0)
0