1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-03 22:24:49 +03:00

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

View File

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