Ensure that ExecPrepareExprList's result is all in one memory context.

Noted by Amit Langote.

Discussion: https://postgr.es/m/aad31672-4983-d95d-d24e-6b42fee9b985@lab.ntt.co.jp
This commit is contained in:
Tom Lane 2017-04-07 12:54:17 -04:00
parent 0c732850d2
commit dbb2a93147
1 changed files with 6 additions and 0 deletions

View File

@ -511,8 +511,12 @@ List *
ExecPrepareExprList(List *nodes, EState *estate)
{
List *result = NIL;
MemoryContext oldcontext;
ListCell *lc;
/* Ensure that the list cell nodes are in the right context too */
oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
foreach(lc, nodes)
{
Expr *e = (Expr *) lfirst(lc);
@ -520,6 +524,8 @@ ExecPrepareExprList(List *nodes, EState *estate)
result = lappend(result, ExecPrepareExpr(e, estate));
}
MemoryContextSwitchTo(oldcontext);
return result;
}