diff options
| author | Tom Lane | 2001-01-02 04:33:24 +0000 |
|---|---|---|
| committer | Tom Lane | 2001-01-02 04:33:24 +0000 |
| commit | 1b8a219eefb9235f0fdc8ebc2afb6887932dce02 (patch) | |
| tree | 43c737a565c2f2b3fde74e5507104f8d6d96a49a /src/backend/utils/mmgr | |
| parent | 25d88e4c53e4249f3ba033d7f1b424396c5b65b0 (diff) | |
Clean up non-reentrant interface for hash_seq/HashTableWalk, so that
starting a new hashtable search no longer clobbers any other search
active anywhere in the system. Fix RelationCacheInvalidate() so that
it will not crash or go into an infinite loop if invoked recursively,
as for example by a second SI Reset message arriving while we are still
processing a prior one.
Diffstat (limited to 'src/backend/utils/mmgr')
| -rw-r--r-- | src/backend/utils/mmgr/portalmem.c | 72 |
1 files changed, 14 insertions, 58 deletions
diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 21aeb0a8a5f..fe68d5adc64 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.37 2000/06/28 03:32:50 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.38 2001/01/02 04:33:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -55,8 +55,6 @@ #include "utils/memutils.h" #include "utils/portal.h" -static void CollectNamedPortals(Portal *portalP, int destroy); - /* ---------------- * Global state * ---------------- @@ -121,64 +119,10 @@ static MemoryContext PortalMemory = NULL; /* ---------------------------------------------------------------- - * private internal support routines - * ---------------------------------------------------------------- - */ - -/* - * This routine is used to collect all portals created in this xaction - * and then destroy them. There is a little trickiness required as a - * result of the dynamic hashing interface to getting every hash entry - * sequentially. Its use of static variables requires that we get every - * entry *before* we destroy anything (destroying updates the hashtable - * and screws up the sequential walk of the table). -mer 17 Aug 1992 - */ -static void -CollectNamedPortals(Portal *portalP, int destroy) -{ - static Portal *portalList = (Portal *) NULL; - static int listIndex = 0; - static int maxIndex = 9; - - if (portalList == (Portal *) NULL) - portalList = (Portal *) malloc(10 * sizeof(Portal)); - - if (destroy != 0) - { - int i; - - for (i = 0; i < listIndex; i++) - PortalDrop(&portalList[i]); - listIndex = 0; - } - else - { - Assert(portalP); - Assert(*portalP); - - portalList[listIndex] = *portalP; - listIndex++; - if (listIndex == maxIndex) - { - portalList = (Portal *) - realloc(portalList, (maxIndex + 11) * sizeof(Portal)); - maxIndex += 10; - } - } - return; -} - -void -AtEOXact_portals() -{ - HashTableWalk(PortalHashTable, (HashtFunc) CollectNamedPortals, 0); - CollectNamedPortals(NULL, 1); -} - -/* ---------------------------------------------------------------- * public portal interface functions * ---------------------------------------------------------------- */ + /* * EnablePortalManager * Enables the portal management module at backend startup. @@ -337,6 +281,9 @@ CreatePortal(char *name) * Exceptions: * BadState if called when disabled. * BadArg if portal is invalid. + * + * Note peculiar calling convention: pass a pointer to a portal pointer. + * This is mainly so that this routine can be used as a hashtable walker. */ void PortalDrop(Portal *portalP) @@ -361,6 +308,15 @@ PortalDrop(Portal *portalP) } /* + * Destroy all portals created in the current transaction (ie, all of them). + */ +void +AtEOXact_portals(void) +{ + HashTableWalk(PortalHashTable, (HashtFunc) PortalDrop, 0); +} + +/* * PortalGetHeapMemory * Returns heap memory context for a given portal. */ |
