summaryrefslogtreecommitdiff
path: root/src/include/executor/executor.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/executor/executor.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/executor/executor.h')
-rw-r--r--src/include/executor/executor.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index b834282287d..2eb9b1f2538 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -223,6 +223,7 @@ extern Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname,
bool *isNull);
extern Tuplestorestate *ExecMakeTableFunctionResult(ExprState *funcexpr,
ExprContext *econtext,
+ MemoryContext argContext,
TupleDesc expectedDesc,
bool randomAccess);
extern Datum ExecEvalExprSwitchContext(ExprState *expression, ExprContext *econtext,