summaryrefslogtreecommitdiff
path: root/src/include/nodes/execnodes.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-06-19 22:13:54 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2014-06-19 22:13:54 -0400
commit06d5eacbc0a7db22422fc07aca56f6e69b02b8ea (patch)
tree0d6d998e20320bb072e1cd36755c074010cb0344 /src/include/nodes/execnodes.h
parent94ab763278459ef8f279bdf98bcda9a73accad7e (diff)
Avoid leaking memory while evaluating arguments for a table function.
ExecMakeTableFunctionResult evaluated the arguments for a function-in-FROM in the query-lifespan memory context. This is insignificant in simple cases where the function relation is scanned only once; but if the function is in a sub-SELECT or is on the inside of a nested loop, any memory consumed during argument evaluation can add up quickly. (The potential for trouble here had been foreseen long ago, per existing comments; but we'd not previously seen a complaint from the field about it.) To fix, create an additional temporary context just for this purpose. Per an example from MauMau. Back-patch to all active branches.
Diffstat (limited to 'src/include/nodes/execnodes.h')
-rw-r--r--src/include/nodes/execnodes.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index c16f6404710..10f18b0ebd0 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1353,6 +1353,7 @@ typedef struct SubqueryScanState
* tupdesc expected return tuple description
* tuplestorestate private state of tuplestore.c
* funcexpr state for function expression being evaluated
+ * argcontext memory context to evaluate function arguments in
* ----------------
*/
typedef struct FunctionScanState
@@ -1362,6 +1363,7 @@ typedef struct FunctionScanState
TupleDesc tupdesc;
Tuplestorestate *tuplestorestate;
ExprState *funcexpr;
+ MemoryContext argcontext;
} FunctionScanState;
/* ----------------