From: Heikki Linnakangas Date: Tue, 13 Jul 2010 09:02:46 +0000 (+0000) Subject: Oops, in the previous fix to prevent a cursor that's being used in a FOR X-Git-Tag: REL8_3_12~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20b63e97b6482ac5769a35d821b3f516f0087e87;p=postgresql 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. --- diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 1bd4c6d2fd..6d60415a4e 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.106.2.4 2010/07/05 09:27:31 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.106.2.5 2010/07/13 09:02:46 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -369,6 +369,9 @@ PortalCreateHoldStore(Portal portal) /* * PinPortal * Protect a portal from dropping. + * + * A pinned portal is still unpinned and dropped at transaction or + * subtransaction abort. */ void PinPortal(Portal portal) @@ -902,6 +905,14 @@ AtSubCleanup_Portals(SubTransactionId mySubid) if (portal->createSubid != mySubid) continue; + /* + * If a portal is still pinned, forcibly unpin it. PortalDrop will not + * let us drop the portal otherwise. Whoever pinned the portal was + * interrupted by the abort too and won't try to use it anymore. + */ + if (portal->portalPinned) + portal->portalPinned = false; + /* Zap it. */ PortalDrop(portal, false); }