diff options
author | Jeff Davis | 2020-03-05 01:20:20 +0000 |
---|---|---|
committer | Jeff Davis | 2020-03-05 01:29:18 +0000 |
commit | c954d49046504bde0a80b5fec53f4321dd88f1ea (patch) | |
tree | 66ffd45e5be805255584236657ae1e336f541688 /src/backend/executor/execExprInterp.c | |
parent | 3ed2005ff595d349276e5b2edeca1a8100b08c87 (diff) |
Extend ExecBuildAggTrans() to support a NULL pointer check.
Optionally push a step to check for a NULL pointer to the pergroup
state.
This will be important for disk-based hash aggregation in combination
with grouping sets. When memory limits are reached, a given tuple may
find its per-group state for some grouping sets but not others. For
the former, it advances the per-group state as normal; for the latter,
it skips evaluation and the calling code will have to spill the tuple
and reprocess it in a later batch.
Add the NULL check as a separate expression step because in some
common cases it's not needed.
Discussion: https://postgr.es/m/20200221202212.ssb2qpmdgrnx52sj%40alap3.anarazel.de
Diffstat (limited to 'src/backend/executor/execExprInterp.c')
-rw-r--r-- | src/backend/executor/execExprInterp.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c index eafd4849002..113ed1547cb 100644 --- a/src/backend/executor/execExprInterp.c +++ b/src/backend/executor/execExprInterp.c @@ -435,6 +435,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) &&CASE_EEOP_AGG_DESERIALIZE, &&CASE_EEOP_AGG_STRICT_INPUT_CHECK_ARGS, &&CASE_EEOP_AGG_STRICT_INPUT_CHECK_NULLS, + &&CASE_EEOP_AGG_PLAIN_PERGROUP_NULLCHECK, &&CASE_EEOP_AGG_PLAIN_TRANS_INIT_STRICT_BYVAL, &&CASE_EEOP_AGG_PLAIN_TRANS_STRICT_BYVAL, &&CASE_EEOP_AGG_PLAIN_TRANS_BYVAL, @@ -1604,6 +1605,22 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) } /* + * Check for a NULL pointer to the per-group states. + */ + + EEO_CASE(EEOP_AGG_PLAIN_PERGROUP_NULLCHECK) + { + AggState *aggstate = castNode(AggState, state->parent); + AggStatePerGroup pergroup_allaggs = aggstate->all_pergroups + [op->d.agg_plain_pergroup_nullcheck.setoff]; + + if (pergroup_allaggs == NULL) + EEO_JUMP(op->d.agg_plain_pergroup_nullcheck.jumpnull); + + EEO_NEXT(); + } + + /* * Different types of aggregate transition functions are implemented * as different types of steps, to avoid incurring unnecessary * overhead. There's a step type for each valid combination of having |