]> granicus.if.org Git - postgresql/commitdiff
Ensure that ExecPrepareExprList's result is all in one memory context.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 7 Apr 2017 16:54:17 +0000 (12:54 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 7 Apr 2017 16:54:23 +0000 (12:54 -0400)
Noted by Amit Langote.

Discussion: https://postgr.es/m/aad31672-4983-d95d-d24e-6b42fee9b985@lab.ntt.co.jp

src/backend/executor/execExpr.c

index cd0dce150d65da23fe27c7fdb8c22a06e0d3ccde..97ec8fb033bb2bb9aeeb297c0d7c5afccda0fe81 100644 (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;
 }