33 #include "utils/builtins.h"
34 #include "executor/spi.h"
36 #include "../postgis_config.h"
37 #include "lwgeom_pg.h"
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);
95 #if !(defined HAVE_LIBPROTOBUF)
96 elog(ERROR,
"ST_AsGeobuf: Compiled without protobuf-c support");
101 if (!AggCheckCallContext(fcinfo, NULL))
102 elog(ERROR,
"pgis_asmvt_finalfn called in non-aggregate context");
109 PG_RETURN_BYTEA_P(buf);
uint8_t * geobuf_agg_finalfn(struct geobuf_agg_context *ctx)
Finalize aggregation.
void geobuf_agg_init_context(struct geobuf_agg_context *ctx)
Initialize aggregation context.
void geobuf_agg_transfn(struct geobuf_agg_context *ctx)
Aggregation step.
This library is the generic geometry handling section of PostGIS.
Datum pgis_asgeobuf_transfn(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(pgis_asgeobuf_transfn)
Process input parameters and row data into state.
Datum pgis_asgeobuf_finalfn(PG_FUNCTION_ARGS)