diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-07-12 02:37:39 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-07-12 02:37:39 +0000 |
commit | badce86a2c327b40c6146242526d1523455d64a6 (patch) | |
tree | 6e0cb658889a2688e76d9ac19a56555c5eb0e738 /src/backend/utils/cache | |
parent | 46fb9c29e2990ba470bb741ff6dd60f2ae218e64 (diff) |
First stage of reclaiming memory in executor by resetting short-term
memory contexts. Currently, only leaks in expressions executed as
quals or projections are handled. Clean up some old dead cruft in
executor while at it --- unused fields in state nodes, that sort of thing.
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/fcache.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/backend/utils/cache/fcache.c b/src/backend/utils/cache/fcache.c index 7e9d18c7e27..ba34dfd03dc 100644 --- a/src/backend/utils/cache/fcache.c +++ b/src/backend/utils/cache/fcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.33 2000/07/05 23:11:39 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.34 2000/07/12 02:37:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -75,6 +75,7 @@ init_fcache(Oid foid, retval = (FunctionCachePtr) palloc(sizeof(FunctionCache)); MemSet(retval, 0, sizeof(FunctionCache)); + retval->fcacheCxt = CurrentMemoryContext; /* ---------------- * get the procedure tuple corresponding to the given functionOid @@ -256,22 +257,26 @@ init_fcache(Oid foid, void setFcache(Node *node, Oid foid, List *argList, ExprContext *econtext) { - Func *fnode; - Oper *onode; + MemoryContext oldcontext; FunctionCachePtr fcache; + /* Switch to a context long-lived enough for the fcache entry */ + oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_query_memory); + fcache = init_fcache(foid, argList, econtext); if (IsA(node, Oper)) { - onode = (Oper *) node; + Oper *onode = (Oper *) node; onode->op_fcache = fcache; } else if (IsA(node, Func)) { - fnode = (Func *) node; + Func *fnode = (Func *) node; fnode->func_fcache = fcache; } else elog(ERROR, "init_fcache: node must be Oper or Func!"); + + MemoryContextSwitchTo(oldcontext); } |