1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-11 04:22:52 +03:00

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  by Robert Walker. Backpatch to 8.0, 7.4 didn't have
subtransactions.
This commit is contained in:
Heikki Linnakangas
2010-07-13 09:02:30 +00:00
parent f0fd939655
commit 2751a249cb

@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.120 2010/07/06 19:18:59 momjian Exp $ * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.121 2010/07/13 09:02:30 heikki Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@@ -379,6 +379,9 @@ PortalCreateHoldStore(Portal portal)
/* /*
* PinPortal * PinPortal
* Protect a portal from dropping. * Protect a portal from dropping.
*
* A pinned portal is still unpinned and dropped at transaction or
* subtransaction abort.
*/ */
void void
PinPortal(Portal portal) PinPortal(Portal portal)
@@ -902,6 +905,14 @@ AtSubCleanup_Portals(SubTransactionId mySubid)
if (portal->createSubid != mySubid) if (portal->createSubid != mySubid)
continue; 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. */ /* Zap it. */
PortalDrop(portal, false); PortalDrop(portal, false);
} }