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

Skip to content
8000

Commit b239670

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 b8accd6 comm
8000
it b239670

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.76.4.3 2010/07/05 09:27:49 heikki Exp $
15+
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.76.4.4 2010/07/13 09:03:11 heikki Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -298,6 +298,9 @@ PortalCreateHoldStore(Portal portal)
298298
/*
299299
* PinPortal
300300
* Protect a portal from dropping.
301+
*
302+
* A pinned portal is still unpinned and dropped at transaction or
303+
* subtransaction abort.
301304
*/
302305
void
303306
PinPortal(Portal portal)
@@ -764,6 +767,14 @@ AtSubCleanup_Portals(SubTransactionId mySubid)
764767
if (portal->createSubid != mySubid)
765768
continue;
766769

770+
/*
771+
* If a portal is still pinned, forcibly unpin it. PortalDrop will not
772+
* let us drop the portal otherwise. Whoever pinned the portal was
773+
* interrupted by the abort too and won't try to use it anymore.
774+
*/
775+
if (portal->portalPinned)
776+
portal->portalPinned = false;
777+
767778
/* Zap it. */
768779
PortalDrop(portal, false);
769780
}

0 commit comments

Comments
 (0)
0