Commit dbb2a931 authored by Tom Lane's avatar Tom Lane

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
parent 0c732850
...@@ -511,8 +511,12 @@ List * ...@@ -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) ...@@ -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;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment