71 MemoryContext aggcontext, old;
75 Datum argType = get_fn_expr_argtype(fcinfo->flinfo, 1);
76 double gridSize = -1.0;
78 if (argType == InvalidOid)
80 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
81 errmsg(
"could not determine input data type")));
83 if ( ! AggCheckCallContext(fcinfo, &aggcontext) )
86 elog(ERROR,
"%s called in non-aggregate context", __func__);
90 if ( PG_ARGISNULL(0) )
99 for (
int i = 0; i < n; i++)
101 Datum argument = PG_GETARG_DATUM(i+2);
102 Oid dataOid = get_fn_expr_argtype(fcinfo->flinfo, i+2);
103 old = MemoryContextSwitchTo(aggcontext);
104 state->
data[i] = datumCopy(argument, get_typbyval(dataOid), get_typlen(dataOid));
105 MemoryContextSwitchTo(old);
113 if (!PG_ARGISNULL(1))
114 gser = PG_GETARG_GSERIALIZED_P(1);
116 if (PG_NARGS()>2 && !PG_ARGISNULL(2))
118 gridSize = PG_GETARG_FLOAT8(2);
124 old = MemoryContextSwitchTo(aggcontext);
132 state->
geoms = list_make1(geom);
134 MemoryContextSwitchTo(old);
136 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]