*/
portal = CreatePortal(cstmt->portalname, false, false);
- oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
+ oldContext = MemoryContextSwitchTo(portal->portalContext);
plan = copyObject(plan);
ActivePortal = portal;
if (portal->resowner)
CurrentResourceOwner = portal->resowner;
- PortalContext = PortalGetHeapMemory(portal);
+ PortalContext = portal->portalContext;
MemoryContextSwitchTo(PortalContext);
PopActiveSnapshot();
/*
- * We can now release any subsidiary memory of the portal's heap context;
+ * We can now release any subsidiary memory of the portal's context;
* we'll never use it again. The executor already dropped its context,
- * but this will clean up anything that glommed onto the portal's heap via
+ * but this will clean up anything that glommed onto the portal's context via
* PortalContext.
*/
- MemoryContextDeleteChildren(PortalGetHeapMemory(portal));
+ MemoryContextDeleteChildren(portal->portalContext);
}
portal->visible = false;
/* Copy the plan's saved query string into the portal's memory */
- query_string = MemoryContextStrdup(PortalGetHeapMemory(portal),
+ query_string = MemoryContextStrdup(portal->portalContext,
entry->plansource->query_string);
/* Replan if needed, and increment plan refcount for portal */
}
/* Copy the plan's query string into the portal */
- query_string = MemoryContextStrdup(PortalGetHeapMemory(portal),
+ query_string = MemoryContextStrdup(portal->portalContext,
plansource->query_string);
/*
* will result in leaking our refcount on the plan, but it doesn't
* matter because the plan is unsaved and hence transient anyway.
*/
- oldcontext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
+ oldcontext = MemoryContextSwitchTo(portal->portalContext);
stmt_list = copyObject(stmt_list);
MemoryContextSwitchTo(oldcontext);
ReleaseCachedPlan(cplan, false);
*/
if (paramLI)
{
- oldcontext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
+ oldcontext = MemoryContextSwitchTo(portal->portalContext);
paramLI = copyParamList(paramLI);
MemoryContextSwitchTo(oldcontext);
}
* don't want a failure to occur between GetCachedPlan and
* PortalDefineQuery; that would result in leaking our plancache refcount.
*/
- oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
+ oldContext = MemoryContextSwitchTo(portal->portalContext);
/* Copy the plan's query string into the portal */
query_string = pstrdup(psrc->query_string);
ActivePortal = portal;
if (portal->resowner)
CurrentResourceOwner = portal->resowner;
- PortalContext = PortalGetHeapMemory(portal);
+ PortalContext = portal->portalContext;
- oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal));
+ oldContext = MemoryContextSwitchTo(PortalContext);
/* Must remember portal param list, if any */
portal->portalParams = params;
return;
natts = portal->tupDesc->natts;
portal->formats = (int16 *)
- MemoryContextAlloc(PortalGetHeapMemory(portal),
+ MemoryContextAlloc(portal->portalContext,
natts * sizeof(int16));
if (nFormats > 1)
{
ActivePortal = portal;
if (portal->resowner)
CurrentResourceOwner = portal->resowner;
- PortalContext = PortalGetHeapMemory(portal);
+ PortalContext = portal->portalContext;
MemoryContextSwitchTo(PortalContext);
completionTag);
/* Some utility statements may change context on us */
- MemoryContextSwitchTo(PortalGetHeapMemory(portal));
+ MemoryContextSwitchTo(portal->portalContext);
/*
* Some utility commands may pop the ActiveSnapshot stack from under us,
/*
* Clear subsidiary contexts to recover temporary memory.
*/
- Assert(PortalGetHeapMemory(portal) == CurrentMemoryContext);
+ Assert(portal->portalContext == CurrentMemoryContext);
- MemoryContextDeleteChildren(PortalGetHeapMemory(portal));
+ MemoryContextDeleteChildren(portal->portalContext);
}
/* Pop the snapshot if we pushed one. */
ActivePortal = portal;
if (portal->resowner)
CurrentResourceOwner = portal->resowner;
- PortalContext = PortalGetHeapMemory(portal);
+ PortalContext = portal->portalContext;
oldContext = MemoryContextSwitchTo(PortalContext);
elog(WARNING, "trying to delete portal name that does not exist"); \
} while(0)
-static MemoryContext PortalMemory = NULL;
+static MemoryContext TopPortalContext = NULL;
/* ----------------------------------------------------------------
{
HASHCTL ctl;
- Assert(PortalMemory == NULL);
+ Assert(TopPortalContext == NULL);
- PortalMemory = AllocSetContextCreate(TopMemoryContext,
- "PortalMemory",
+ TopPortalContext = AllocSetContextCreate(TopMemoryContext,
+ "TopPortalContext",
ALLOCSET_DEFAULT_SIZES);
ctl.keysize = MAX_PORTALNAME_LEN;
}
/* make new portal structure */
- portal = (Portal) MemoryContextAllocZero(PortalMemory, sizeof *portal);
+ portal = (Portal) MemoryContextAllocZero(TopPortalContext, sizeof *portal);
- /* initialize portal heap context; typically it won't store much */
- portal->heap = AllocSetContextCreate(PortalMemory,
- "PortalHeapMemory",
- ALLOCSET_SMALL_SIZES);
+ /* initialize portal context; typically it won't store much */
+ portal->portalContext = AllocSetContextCreate(TopPortalContext,
+ "PortalContext",
+ ALLOCSET_SMALL_SIZES);
/* create a resource owner for the portal */
portal->resowner = ResourceOwnerCreate(CurTransactionResourceOwner,
*
* If cplan is NULL, then it is the caller's responsibility to ensure that
* the passed plan trees have adequate lifetime. Typically this is done by
- * copying them into the portal's heap context.
+ * copying them into the portal's context.
*
* The caller is also responsible for ensuring that the passed prepStmtName
* (if not NULL) and sourceText have adequate lifetime.
/*
* Create the memory context that is used for storage of the tuple set.
- * Note this is NOT a child of the portal's heap memory.
+ * Note this is NOT a child of the portal's portalContext.
*/
portal->holdContext =
- AllocSetContextCreate(PortalMemory,
+ AllocSetContextCreate(TopPortalContext,
"PortalHoldContext",
ALLOCSET_DEFAULT_SIZES);
MemoryContextDelete(portal->holdContext);
/* release subsidiary storage */
- MemoryContextDelete(PortalGetHeapMemory(portal));
+ MemoryContextDelete(portal->portalContext);
- /* release portal struct (it's in PortalMemory) */
+ /* release portal struct (it's in TopPortalContext) */
pfree(portal);
}
* The cleanup hook was the last thing that might have needed data
* there.
*/
- MemoryContextDeleteChildren(PortalGetHeapMemory(portal));
+ MemoryContextDeleteChildren(portal->portalContext);
}
}
* The cleanup hook was the last thing that might have needed data
* there.
*/
- MemoryContextDeleteChildren(PortalGetHeapMemory(portal));
+ MemoryContextDeleteChildren(portal->portalContext);
}
}
/* Bookkeeping data */
const char *name; /* portal's name */
const char *prepStmtName; /* source prepared statement (NULL if none) */
- MemoryContext heap; /* subsidiary memory for portal */
+ MemoryContext portalContext;/* subsidiary memory for portal */
ResourceOwner resowner; /* resources owned by portal */
void (*cleanup) (Portal portal); /* cleanup hook */
* Access macros for Portal ... use these in preference to field access.
*/
#define PortalGetQueryDesc(portal) ((portal)->queryDesc)
-#define PortalGetHeapMemory(portal) ((portal)->heap)
/* Prototypes for functions in utils/mmgr/portalmem.c */