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

Function array_agg_finalfn

src/backend/utils/adt/array_userfuncs.c:523–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

521}
522
523Datum
524array_agg_finalfn(PG_FUNCTION_ARGS)
525{
526 Datum result;
527 ArrayBuildState *state;
528 int dims[1];
529 int lbs[1];
530
531 /* cannot be called directly because of internal-type argument */
532 Assert(AggCheckCallContext(fcinfo, NULL));
533
534 state = PG_ARGISNULL(0) ? NULL : (ArrayBuildState *) PG_GETARG_POINTER(0);
535
536 if (state == NULL)
537 PG_RETURN_NULL(); /* returns null iff no input values */
538
539 dims[0] = state->nelems;
540 lbs[0] = 1;
541
542 /*
543 * Make the result. We cannot release the ArrayBuildState because
544 * sometimes aggregate final functions are re-executed. Rather, it is
545 * nodeAgg.c's responsibility to reset the aggcontext when it's safe to do
546 * so.
547 */
548 result = makeMdArrayResult(state, 1, dims, lbs,
549 CurrentMemoryContext,
550 false);
551
552 PG_RETURN_DATUM(result);
553}
554
555Datum
556array_agg_combine(PG_FUNCTION_ARGS)

Callers

nothing calls this directly

Calls 2

AggCheckCallContextFunction · 0.85
makeMdArrayResultFunction · 0.85

Tested by

no test coverage detected