diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2010-07-05 09:27:57 +0000 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2010-07-05 09:27:57 +0000 |
commit | 97f29c865f4332d48465735b22a42d9b0deacd12 (patch) | |
tree | f9ba1948ac1c0490787ddad03ba7212f9fc99dda /src/include/utils/portal.h | |
parent | 5e7776941370491b17755de7472a81631fcfaeae (diff) |
The previous fix in CVS HEAD and 8.4 for handling the case where a cursor
being used in a PL/pgSQL FOR loop is closed was inadequate, as Tom Lane
pointed out. The bug affects FOR statement variants too, because you can
close an implicitly created cursor too by guessing the "<unnamed portal X>"
name created for it.
To fix that, "pin" the portal to prevent it from being dropped while it's
being used in a PL/pgSQL FOR loop. Backpatch all the way to 7.4 which is
the oldest supported version.
Diffstat (limited to 'src/include/utils/portal.h')
-rw-r--r-- | src/include/utils/portal.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index 3faf3ec562f..2006c4ce970 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -39,7 +39,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: portal.h,v 1.47 2003/08/08 21:42:55 momjian Exp $ + * $Id: portal.h,v 1.47.4.1 2010/07/05 09:27:56 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -117,6 +117,7 @@ typedef struct PortalData bool portalUtilReady; /* PortalRunUtility complete? */ bool portalActive; /* portal is running (can't delete it) */ bool portalDone; /* portal is finished (don't re-run it) */ + bool portalPinned; /* portal is pinned (can't delete it) */ /* If not NULL, Executor is active; call ExecutorEnd eventually: */ QueryDesc *queryDesc; /* info needed for executor invocation */ @@ -169,6 +170,8 @@ extern void AtAbort_Portals(void); extern void AtCleanup_Portals(void); extern Portal CreatePortal(const char *name, bool allowDup, bool dupSilent); extern Portal CreateNewPortal(void); +extern void PinPortal(Portal portal); +extern void UnpinPortal(Portal portal); extern void PortalDrop(Portal portal, bool isError); extern void DropDependentPortals(MemoryContext queryContext); extern Portal GetPortalByName(const char *name); |