aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execExpr.c
diff options
context:
space:
mode:
authorDaniel Gustafsson <dgustafsson@postgresql.org>2025-03-11 12:02:38 +0100
committerDaniel Gustafsson <dgustafsson@postgresql.org>2025-03-11 12:02:38 +0100
commit8dd7c7cd0a2605d5301266a6b67a569d6a305106 (patch)
tree1da627dcaf9c5f7cc30de84292b2463858de8f58 /src/backend/executor/execExpr.c
parentdabccf45139a8c7c3c2e7683a943c31077e55a78 (diff)
downloadpostgresql-8dd7c7cd0a2605d5301266a6b67a569d6a305106.tar.gz
postgresql-8dd7c7cd0a2605d5301266a6b67a569d6a305106.zip
Replace EEOP_DONE with special steps for return/no return
Knowing when the side-effects of an expression is the intended result of the execution, rather than the returnvalue, is important for being able generate more efficient JITed code. This replaces EEOP_DONE with two new steps: EEOP_DONE_RETURN and EEOP_DONE_NO_RETURN. Expressions which return a value should use the former step; expressions used for their side-effects which don't return value should use the latter. Author: Andres Freund <andres@anarazel.de> Co-authored-by: Daniel Gustafsson <daniel@yesql.se> Reviewed-by: Andreas Karlsson <andreas@proxel.se> Discussion: https://postgr.es/m/415721CE-7D2E-4B74-B5D9-1950083BA03E@yesql.se Discussion: https://postgr.es/m/20191023163849.sosqbfs5yenocez3@alap3.anarazel.de
Diffstat (limited to 'src/backend/executor/execExpr.c')
-rw-r--r--src/backend/executor/execExpr.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c
index 03566c4d181..0175b152980 100644
--- a/src/backend/executor/execExpr.c
+++ b/src/backend/executor/execExpr.c
@@ -8,7 +8,7 @@
* using ExecInitExpr() et al. This converts the tree into a flat array
* of ExprEvalSteps, which may be thought of as instructions in a program.
* At runtime, we'll execute steps, starting with the first, until we reach
- * an EEOP_DONE opcode.
+ * an EEOP_DONE_{RETURN|NO_RETURN} opcode.
*
* This file contains the "compilation" logic. It is independent of the
* specific execution technology we use (switch statement, computed goto,
@@ -162,7 +162,7 @@ ExecInitExpr(Expr *node, PlanState *parent)
ExecInitExprRec(node, state, &state->resvalue, &state->resnull);
/* Finally, append a DONE step */
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_RETURN;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);
@@ -199,7 +199,7 @@ ExecInitExprWithParams(Expr *node, ParamListInfo ext_params)
ExecInitExprRec(node, state, &state->resvalue, &state->resnull);
/* Finally, append a DONE step */
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_RETURN;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);
@@ -291,7 +291,7 @@ ExecInitQual(List *qual, PlanState *parent)
* have yielded TRUE, and since its result is stored in the desired output
* location, we're done.
*/
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_RETURN;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);
@@ -503,7 +503,7 @@ ExecBuildProjectionInfo(List *targetList,
}
}
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_NO_RETURN;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);
@@ -742,7 +742,7 @@ ExecBuildUpdateProjection(List *targetList,
}
}
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_NO_RETURN;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);
@@ -1714,7 +1714,7 @@ ExecInitExprRec(Expr *node, ExprState *state,
else
{
/* Not trivial, so append a DONE step */
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_RETURN;
ExprEvalPushStep(elemstate, &scratch);
/* and ready the subexpression */
ExecReadyExpr(elemstate);
@@ -3991,7 +3991,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
scratch.resvalue = NULL;
scratch.resnull = NULL;
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_NO_RETURN;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);
@@ -4258,7 +4258,7 @@ ExecBuildHash32FromAttrs(TupleDesc desc, const TupleTableSlotOps *ops,
scratch.resvalue = NULL;
scratch.resnull = NULL;
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_RETURN;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);
@@ -4431,7 +4431,7 @@ ExecBuildHash32Expr(TupleDesc desc, const TupleTableSlotOps *ops,
scratch.resvalue = NULL;
scratch.resnull = NULL;
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_RETURN;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);
@@ -4586,7 +4586,7 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
scratch.resvalue = NULL;
scratch.resnull = NULL;
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_RETURN;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);
@@ -4722,7 +4722,7 @@ ExecBuildParamSetEqual(TupleDesc desc,
scratch.resvalue = NULL;
scratch.resnull = NULL;
- scratch.opcode = EEOP_DONE;
+ scratch.opcode = EEOP_DONE_RETURN;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);