summaryrefslogtreecommitdiff
path: root/src/backend/executor/execExprInterp.c
diff options
context:
space:
mode:
authorDaniel Gustafsson2025-03-11 11:02:38 +0000
committerDaniel Gustafsson2025-03-11 11:02:38 +0000
commit8dd7c7cd0a2605d5301266a6b67a569d6a305106 (patch)
tree1da627dcaf9c5f7cc30de84292b2463858de8f58 /src/backend/executor/execExprInterp.c
parentdabccf45139a8c7c3c2e7683a943c31077e55a78 (diff)
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 <[email protected]> Co-authored-by: Daniel Gustafsson <[email protected]> Reviewed-by: Andreas Karlsson <[email protected]> Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/executor/execExprInterp.c')
-rw-r--r--src/backend/executor/execExprInterp.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 1c3477b03c9..491ecad8dc6 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -246,7 +246,8 @@ ExecReadyInterpretedExpr(ExprState *state)
/* Simple validity checks on expression */
Assert(state->steps_len >= 1);
- Assert(state->steps[state->steps_len - 1].opcode == EEOP_DONE);
+ Assert(state->steps[state->steps_len - 1].opcode == EEOP_DONE_RETURN ||
+ state->steps[state->steps_len - 1].opcode == EEOP_DONE_NO_RETURN);
/*
* Don't perform redundant initialization. This is unreachable in current
@@ -469,7 +470,8 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
*/
#if defined(EEO_USE_COMPUTED_GOTO)
static const void *const dispatch_table[] = {
- &&CASE_EEOP_DONE,
+ &&CASE_EEOP_DONE_RETURN,
+ &&CASE_EEOP_DONE_NO_RETURN,
&&CASE_EEOP_INNER_FETCHSOME,
&&CASE_EEOP_OUTER_FETCHSOME,
&&CASE_EEOP_SCAN_FETCHSOME,
@@ -612,9 +614,16 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
EEO_SWITCH()
{
- EEO_CASE(EEOP_DONE)
+ EEO_CASE(EEOP_DONE_RETURN)
{
- goto out;
+ *isnull = state->resnull;
+ return state->resvalue;
+ }
+
+ EEO_CASE(EEOP_DONE_NO_RETURN)
+ {
+ Assert(isnull == NULL);
+ return (Datum) 0;
}
EEO_CASE(EEOP_INNER_FETCHSOME)
@@ -2188,13 +2197,13 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
{
/* unreachable */
Assert(false);
- goto out;
+ goto out_error;
}
}
-out:
- *isnull = state->resnull;
- return state->resvalue;
+out_error:
+ pg_unreachable();
+ return (Datum) 0;
}
/*