122 Oid arg1_typeid = get_fn_expr_argtype(fcinfo->flinfo, 1);
123 MemoryContext aggcontext;
124 ArrayBuildState *state;
128 if (arg1_typeid == InvalidOid)
130 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
131 errmsg(
"could not determine input data type")));
133 if ( ! AggCheckCallContext(fcinfo, &aggcontext) )
136 elog(ERROR,
"%s called in non-aggregate context", __func__);
140 if ( PG_ARGISNULL(0) )
144 p->
data = (Datum) NULL;
148 Datum argument = PG_GETARG_DATUM(2);
149 Oid dataOid = get_fn_expr_argtype(fcinfo->flinfo, 2);
150 MemoryContext old = MemoryContextSwitchTo(aggcontext);
152 p->
data = datumCopy(argument, get_typbyval(dataOid), get_typlen(dataOid));
154 MemoryContextSwitchTo(old);
159 p = (
pgis_abs*) PG_GETARG_POINTER(0);
162 elem = PG_ARGISNULL(1) ? (Datum) 0 : PG_GETARG_DATUM(1);
163 state = accumArrayResult(state,
170 PG_RETURN_POINTER(p);
To pass the internal ArrayBuildState pointer between the transfn and finalfn we need to wrap it into ...