diff options
Diffstat (limited to 'src/backend/executor/execExpr.c')
-rw-r--r-- | src/backend/executor/execExpr.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c index 7496189fabf..2a2741352af 100644 --- a/src/backend/executor/execExpr.c +++ b/src/backend/executor/execExpr.c @@ -304,6 +304,32 @@ ExecBuildProjectionInfo(List *targetList, PlanState *parent, TupleDesc inputDesc) { + return ExecBuildProjectionInfoExt(targetList, + econtext, + slot, + true, + parent, + inputDesc); +} + +/* + * ExecBuildProjectionInfoExt + * + * As above, with one additional option. + * + * If assignJunkEntries is true (the usual case), resjunk entries in the tlist + * are not handled specially: they are evaluated and assigned to the proper + * column of the result slot. If assignJunkEntries is false, resjunk entries + * are evaluated, but their result is discarded without assignment. + */ +ProjectionInfo * +ExecBuildProjectionInfoExt(List *targetList, + ExprContext *econtext, + TupleTableSlot *slot, + bool assignJunkEntries, + PlanState *parent, + TupleDesc inputDesc) +{ ProjectionInfo *projInfo = makeNode(ProjectionInfo); ExprState *state; ExprEvalStep scratch; @@ -337,7 +363,8 @@ ExecBuildProjectionInfo(List *targetList, */ if (tle->expr != NULL && IsA(tle->expr, Var) && - ((Var *) tle->expr)->varattno > 0) + ((Var *) tle->expr)->varattno > 0 && + (assignJunkEntries || !tle->resjunk)) { /* Non-system Var, but how safe is it? */ variable = (Var *) tle->expr; @@ -401,6 +428,10 @@ ExecBuildProjectionInfo(List *targetList, ExecInitExprRec(tle->expr, parent, state, &state->resvalue, &state->resnull); + /* This makes it easy to discard resjunk results when told to. */ + if (!assignJunkEntries && tle->resjunk) + continue; + /* * Column might be referenced multiple times in upper nodes, so * force value to R/O - but only if it could be an expanded datum. |