From e4186762ffaa4188e16702e8f4f299ea70988b96 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 29 Aug 2002 17:14:33 +0000 Subject: Adjust nodeFunctionscan.c to reset transient memory context between calls to the table function, thus preventing memory leakage accumulation across calls. This means that SRFs need to be careful to distinguish permanent and local storage; adjust code and documentation accordingly. Patch by Joe Conway, very minor tweaks by Tom Lane. --- src/backend/executor/nodeFunctionscan.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/backend/executor/nodeFunctionscan.c') diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c index 381b6047bf0..d58d312238e 100644 --- a/src/backend/executor/nodeFunctionscan.c +++ b/src/backend/executor/nodeFunctionscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.6 2002/08/29 00:17:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.7 2002/08/29 17:14:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -428,6 +428,12 @@ function_getonetuple(FunctionScanState *scanstate, ExprContext *econtext = scanstate->csstate.cstate.cs_ExprContext; TupleTableSlot *slot = scanstate->csstate.css_ScanTupleSlot; + /* + * reset per-tuple memory context before each call of the function. + * This cleans up any local memory the function may leak when called. + */ + ResetExprContext(econtext); + /* * get the next Datum from the function */ -- cgit v1.2.3