Pass through PlanState parent to expression instantiation.
authorAndres Freund <andres@anarazel.de>
Thu, 31 Aug 2017 20:27:28 +0000 (13:27 -0700)
committerAndres Freund <andres@anarazel.de>
Fri, 1 Sep 2017 06:22:35 +0000 (23:22 -0700)
src/backend/executor/execExpr.c
src/backend/executor/execExprInterp.c

index 81549ee9156317a5fad0e93b90c0fceb2f6b5a9c..b5bde3fa80d2b5f7d6e02743dfa0f9fb81042777 100644 (file)
@@ -54,7 +54,7 @@ typedef struct LastAttnumInfo
    AttrNumber  last_scan;
 } LastAttnumInfo;
 
-static void ExecReadyExpr(ExprState *state);
+static void ExecReadyExpr(ExprState *state, PlanState *parent);
 static void ExecInitExprRec(Expr *node, PlanState *parent, ExprState *state,
                Datum *resv, bool *resnull);
 static void ExprEvalPushStep(ExprState *es, const ExprEvalStep *s);
@@ -123,6 +123,9 @@ ExecInitExpr(Expr *node, PlanState *parent)
    state = makeNode(ExprState);
    state->expr = node;
 
+   scratch.resvalue = NULL;
+   scratch.resnull = NULL;
+
    /* Insert EEOP_*_FETCHSOME steps as needed */
    ExecInitExprSlots(state, (Node *) node);
 
@@ -133,7 +136,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
    scratch.opcode = EEOP_DONE;
    ExprEvalPushStep(state, &scratch);
 
-   ExecReadyExpr(state);
+   ExecReadyExpr(state, parent);
 
    return state;
 }
@@ -225,7 +228,7 @@ ExecInitQual(List *qual, PlanState *parent)
    scratch.opcode = EEOP_DONE;
    ExprEvalPushStep(state, &scratch);
 
-   ExecReadyExpr(state);
+   ExecReadyExpr(state, parent);
 
    return state;
 }
@@ -316,6 +319,9 @@ ExecBuildProjectionInfo(List *targetList,
    state->expr = (Expr *) targetList;
    state->resultslot = slot;
 
+   scratch.resvalue = NULL;
+   scratch.resnull = NULL;
+
    /* Insert EEOP_*_FETCHSOME steps as needed */
    ExecInitExprSlots(state, (Node *) targetList);
 
@@ -417,7 +423,7 @@ ExecBuildProjectionInfo(List *targetList,
    scratch.opcode = EEOP_DONE;
    ExprEvalPushStep(state, &scratch);
 
-   ExecReadyExpr(state);
+   ExecReadyExpr(state, parent);
 
    return projInfo;
 }
@@ -571,9 +577,9 @@ ExecCheck(ExprState *state, ExprContext *econtext)
  * ExecReadyInterpretedExpr().
  */
 static void
-ExecReadyExpr(ExprState *state)
+ExecReadyExpr(ExprState *state, PlanState *parent)
 {
-   ExecReadyInterpretedExpr(state);
+   ExecReadyInterpretedExpr(state, parent);
 }
 
 /*
@@ -2173,6 +2179,9 @@ ExecInitExprSlots(ExprState *state, Node *node)
    LastAttnumInfo info = {0, 0, 0};
    ExprEvalStep scratch;
 
+   scratch.resvalue = NULL;
+   scratch.resnull = NULL;
+
    /*
     * Figure out which attributes we're going to need.
     */
index 50e3f8b176971f0d58b2cc3ad4ced1ead3db0b56..df453b2ab4cf6c4c7b3fed619e7e56fea5bbe37a 100644 (file)
@@ -151,7 +151,7 @@ static Datum ExecJustAssignScanVar(ExprState *state, ExprContext *econtext, bool
  * Prepare ExprState for interpreted execution.
  */
 void
-ExecReadyInterpretedExpr(ExprState *state)
+ExecReadyInterpretedExpr(ExprState *state, PlanState *parent)
 {
    /* Ensure one-time interpreter setup has been done */
    ExecInitInterpreter();