70 MemoryContext aggcontext, old;
74 Datum argType = get_fn_expr_argtype(fcinfo->flinfo, 1);
75 double gridSize = -1.0;
77 if (argType == InvalidOid)
79 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
80 errmsg(
"could not determine input data type")));
82 if ( ! AggCheckCallContext(fcinfo, &aggcontext) )
85 elog(ERROR,
"%s called in non-aggregate context", __func__);
89 if ( PG_ARGISNULL(0) )
98 for (
int i = 0; i < n; i++)
100 Datum argument = PG_GETARG_DATUM(i+2);
101 Oid dataOid = get_fn_expr_argtype(fcinfo->flinfo, i+2);
102 old = MemoryContextSwitchTo(aggcontext);
103 state->
data[i] = datumCopy(argument, get_typbyval(dataOid), get_typlen(dataOid));
104 MemoryContextSwitchTo(old);
112 if (!PG_ARGISNULL(1))
113 gser = PG_GETARG_GSERIALIZED_P(1);
115 if (PG_NARGS()>2 && !PG_ARGISNULL(2))
117 gridSize = PG_GETARG_FLOAT8(2);
123 old = MemoryContextSwitchTo(aggcontext);
131 state->
geoms = list_make1(geom);
133 MemoryContextSwitchTo(old);
135 PG_RETURN_POINTER(state);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
#define CollectionBuildStateDataSize
To pass the internal state of our collection between the transfn and finalfn we need to wrap it into ...
Datum data[CollectionBuildStateDataSize]