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

Function array_agg_array_transfn

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

* ARRAY_AGG(anyarray) aggregate function */

Source from the content-addressed store, hash-verified

1098 * ARRAY_AGG(anyarray) aggregate function
1099 */
1100Datum
1101array_agg_array_transfn(PG_FUNCTION_ARGS)
1102{
1103 Oid arg1_typeid = get_fn_expr_argtype(fcinfo->flinfo, 1);
1104 MemoryContext aggcontext;
1105 ArrayBuildStateArr *state;
1106
1107 if (arg1_typeid == InvalidOid)
1108 ereport(ERROR,
1109 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1110 errmsg("could not determine input data type")));
1111
1112 /*
1113 * Note: we do not need a run-time check about whether arg1_typeid is a
1114 * valid array type, because the parser would have verified that while
1115 * resolving the input/result types of this polymorphic aggregate.
1116 */
1117
1118 if (!AggCheckCallContext(fcinfo, &aggcontext))
1119 {
1120 /* cannot be called directly because of internal-type argument */
1121 elog(ERROR, "array_agg_array_transfn called in non-aggregate context");
1122 }
1123
1124
1125 if (PG_ARGISNULL(0))
1126 state = initArrayResultArr(arg1_typeid, InvalidOid, aggcontext, false);
1127 else
1128 state = (ArrayBuildStateArr *) PG_GETARG_POINTER(0);
1129
1130 state = accumArrayResultArr(state,
1131 PG_GETARG_DATUM(1),
1132 PG_ARGISNULL(1),
1133 arg1_typeid,
1134 aggcontext);
1135
1136 /*
1137 * The transition type for array_agg() is declared to be "internal", which
1138 * is a pass-by-value type the same size as a pointer. So we can safely
1139 * pass the ArrayBuildStateArr pointer through nodeAgg.c's machinations.
1140 */
1141 PG_RETURN_POINTER(state);
1142}
1143
1144Datum
1145array_agg_array_finalfn(PG_FUNCTION_ARGS)

Callers

nothing calls this directly

Calls 6

get_fn_expr_argtypeFunction · 0.85
AggCheckCallContextFunction · 0.85
initArrayResultArrFunction · 0.85
accumArrayResultArrFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected