124 Oid arg1_typeid = get_fn_expr_argtype(fcinfo->flinfo, 1);
125 MemoryContext aggcontext;
126 ArrayBuildState *state;
130 if (arg1_typeid == InvalidOid)
132 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
133 errmsg(
"could not determine input data type")));
135 if ( ! AggCheckCallContext(fcinfo, &aggcontext) )
138 elog(ERROR,
"%s called in non-aggregate context", __func__);
142 if ( PG_ARGISNULL(0) )
144 MemoryContext old = MemoryContextSwitchTo(aggcontext);
147 p->
data = (Datum) NULL;
151 Datum argument = PG_GETARG_DATUM(2);
152 Oid dataOid = get_fn_expr_argtype(fcinfo->flinfo, 2);
154 p->
data = datumCopy(argument, get_typbyval(dataOid), get_typlen(dataOid));
157 MemoryContextSwitchTo(old);
161 p = (
pgis_abs*) PG_GETARG_POINTER(0);
164 elem = PG_ARGISNULL(1) ? (Datum) 0 : PG_GETARG_DATUM(1);
165 state = accumArrayResult(state,
172 PG_RETURN_POINTER(p);
To pass the internal ArrayBuildState pointer between the transfn and finalfn we need to wrap it into ...