MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecBuildAggTransCall

Function ExecBuildAggTransCall

src/backend/executor/execExpr.c:3918–4021  ·  view source on GitHub ↗

* Build transition/combine function invocation for a single transition * value. This is separated from ExecBuildAggTrans() because there are * multiple callsites (hash and sort in some grouping set cases). */

Source from the content-addressed store, hash-verified

3916 * multiple callsites (hash and sort in some grouping set cases).
3917 */
3918static void
3919ExecBuildAggTransCall(ExprState *state, AggState *aggstate,
3920 ExprEvalStep *scratch,
3921 FunctionCallInfo fcinfo, AggStatePerTrans pertrans,
3922 int transno, int setno, int setoff, bool ishash,
3923 bool nullcheck)
3924{
3925 ExprContext *aggcontext;
3926 int adjust_jumpnull = -1;
3927
3928 if (ishash)
3929 aggcontext = aggstate->hashcontext;
3930 else
3931 aggcontext = aggstate->aggcontexts[setno];
3932
3933 /* add check for NULL pointer? */
3934 if (nullcheck)
3935 {
3936 scratch->opcode = EEOP_AGG_PLAIN_PERGROUP_NULLCHECK;
3937 scratch->d.agg_plain_pergroup_nullcheck.setoff = setoff;
3938 /* adjust later */
3939 scratch->d.agg_plain_pergroup_nullcheck.jumpnull = -1;
3940 ExprEvalPushStep(state, scratch);
3941 adjust_jumpnull = state->steps_len - 1;
3942 }
3943
3944 /*
3945 * Determine appropriate transition implementation.
3946 *
3947 * For non-ordered aggregates:
3948 *
3949 * If the initial value for the transition state doesn't exist in the
3950 * pg_aggregate table then we will let the first non-NULL value returned
3951 * from the outer procNode become the initial value. (This is useful for
3952 * aggregates like max() and min().) The noTransValue flag signals that we
3953 * need to do so. If true, generate a
3954 * EEOP_AGG_INIT_STRICT_PLAIN_TRANS{,_BYVAL} step. This step also needs to
3955 * do the work described next:
3956 *
3957 * If the function is strict, but does have an initial value, choose
3958 * EEOP_AGG_STRICT_PLAIN_TRANS{,_BYVAL}, which skips the transition
3959 * function if the transition value has become NULL (because a previous
3960 * transition function returned NULL). This step also needs to do the work
3961 * described next:
3962 *
3963 * Otherwise we call EEOP_AGG_PLAIN_TRANS{,_BYVAL}, which does not have to
3964 * perform either of the above checks.
3965 *
3966 * Having steps with overlapping responsibilities is not nice, but
3967 * aggregations are very performance sensitive, making this worthwhile.
3968 *
3969 * For ordered aggregates:
3970 *
3971 * Only need to choose between the faster path for a single ordered
3972 * column, and the one between multiple columns. Checking strictness etc
3973 * is done when finalizing the aggregate. See
3974 * process_ordered_aggregate_{single, multi} and
3975 * advance_transition_function.

Callers 1

ExecBuildAggTransFunction · 0.85

Calls 1

ExprEvalPushStepFunction · 0.85

Tested by

no test coverage detected