48 #if !(defined HAVE_LIBPROTOBUF)
49 elog(ERROR,
"ST_AsGeobuf: Compiled without protobuf-c support");
52 MemoryContext aggcontext, oldcontext;
56 postgis_initialize_cache();
58 if (!AggCheckCallContext(fcinfo, &aggcontext))
59 elog(ERROR,
"pgis_asgeobuf_transfn: called in non-aggregate context");
60 oldcontext = MemoryContextSwitchTo(aggcontext);
62 if (PG_ARGISNULL(0)) {
63 ctx = palloc(
sizeof(*ctx));
66 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
67 ctx->
geom_name = text_to_cstring(PG_GETARG_TEXT_P(2));
73 if (!type_is_rowtype(get_fn_expr_argtype(fcinfo->flinfo, 1)))
74 elog(ERROR,
"pgis_asgeobuf_transfn: parameter row cannot be other than a rowtype");
77 if (PG_ARGISNULL(1)) {
81 ctx->
row = PG_GETARG_HEAPTUPLEHEADER(1);
84 MemoryContextSwitchTo(oldcontext);
85 PG_RETURN_POINTER(ctx);
void geobuf_agg_init_context(struct geobuf_agg_context *ctx)
Initialize aggregation context.
void geobuf_agg_transfn(struct geobuf_agg_context *ctx)
Aggregation step.