summaryrefslogtreecommitdiff
path: root/src/backend/tcop
diff options
context:
space:
mode:
authorPeter Eisentraut2017-12-16 22:26:26 +0000
committerPeter Eisentraut2018-01-09 18:47:56 +0000
commit0f7c49e85518dd846ccd0a044d49a922b9132983 (patch)
tree1bcbff190de4cc6f8c02e3ecbb2e9b753bbb1ef5 /src/backend/tcop
parent3cb1b2a8804da8365fe17f687d96b720df4a583d (diff)
Update portal-related memory context names and API
Rename PortalMemory to TopPortalContext, to avoid confusion with PortalContext and align naming with similar top-level memory contexts. Rename PortalData's "heap" field to portalContext. The "heap" naming seems quite antiquated and confusing. Also get rid of the PortalGetHeapMemory() macro and access the field directly, which we do for other portal fields, so this abstraction doesn't buy anything. Reviewed-by: Andrew Dunstan <andrew.dunstan@2ndquadrant.com> Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Diffstat (limited to 'src/backend/tcop')
-rw-r--r--src/backend/tcop/postgres.c2
-rw-r--r--src/backend/tcop/pquery.c16
2 files changed, 9 insertions, 9 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 4654a01eabe..ddc3ec860ae 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -1608,7 +1608,7 @@ exec_bind_message(StringInfo input_message)
* 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);
diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c
index 9925712768f..0420231864f 100644
--- a/src/backend/tcop/pquery.c
+++ b/src/backend/tcop/pquery.c
@@ -466,9 +466,9 @@ PortalStart(Portal portal, ParamListInfo params,
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;
@@ -634,7 +634,7 @@ PortalSetResultFormat(Portal portal, int nFormats, int16 *formats)
return;
natts = portal->tupDesc->natts;
portal->formats = (int16 *)
- MemoryContextAlloc(PortalGetHeapMemory(portal),
+ MemoryContextAlloc(portal->portalContext,
natts * sizeof(int16));
if (nFormats > 1)
{
@@ -748,7 +748,7 @@ PortalRun(Portal portal, long count, bool isTopLevel, bool run_once,
ActivePortal = portal;
if (portal->resowner)
CurrentResourceOwner = portal->resowner;
- PortalContext = PortalGetHeapMemory(portal);
+ PortalContext = portal->portalContext;
MemoryContextSwitchTo(PortalContext);
@@ -1184,7 +1184,7 @@ PortalRunUtility(Portal portal, PlannedStmt *pstmt,
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,
@@ -1343,9 +1343,9 @@ PortalRunMulti(Portal portal,
/*
* 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. */
@@ -1424,7 +1424,7 @@ PortalRunFetch(Portal portal,
ActivePortal = portal;
if (portal->resowner)
CurrentResourceOwner = portal->resowner;
- PortalContext = PortalGetHeapMemory(portal);
+ PortalContext = portal->portalContext;
oldContext = MemoryContextSwitchTo(PortalContext);