31 #include "utils/builtins.h"
32 #include "executor/spi.h"
34 #include "../postgis_config.h"
35 #include "lwgeom_pg.h"
46 MemoryContext aggcontext, oldcontext;
47 char *geom_name = NULL;
48 bool create_index =
false;
51 POSTGIS_DEBUG(2,
"calling pgis_asflatgeobuf_transfn");
54 postgis_initialize_cache();
56 if (!AggCheckCallContext(fcinfo, &aggcontext))
57 elog(ERROR,
"pgis_asflatgeobuf_transfn: called in non-aggregate context");
58 oldcontext = MemoryContextSwitchTo(aggcontext);
60 if (PG_ARGISNULL(0)) {
61 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
62 create_index = PG_GETARG_BOOL(2);
63 if (PG_NARGS() > 3 && !PG_ARGISNULL(3))
64 geom_name = text_to_cstring(PG_GETARG_TEXT_P(3));
70 if (!type_is_rowtype(get_fn_expr_argtype(fcinfo->flinfo, 1)))
71 elog(ERROR,
"pgis_asflatgeobuf_transfn: parameter row cannot be other than a rowtype");
72 ctx->
row = PG_GETARG_HEAPTUPLEHEADER(1);
75 MemoryContextSwitchTo(oldcontext);
76 PG_RETURN_POINTER(ctx);
87 if (!AggCheckCallContext(fcinfo, NULL))
88 elog(ERROR,
"pgis_asflatgeobuf_finalfn called in non-aggregate context");
95 PG_RETURN_BYTEA_P(buf);
uint8_t * flatgeobuf_agg_finalfn(struct flatgeobuf_agg_ctx *ctx)
Finalize aggregation.
struct flatgeobuf_agg_ctx * flatgeobuf_agg_ctx_init(const char *geom_name, const bool create_index)
Initialize aggregation context.
void flatgeobuf_agg_transfn(struct flatgeobuf_agg_ctx *ctx)
Aggregation step.
This library is the generic geometry handling section of PostGIS.
Datum pgis_asflatgeobuf_transfn(PG_FUNCTION_ARGS)
Datum pgis_asflatgeobuf_finalfn(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(pgis_asflatgeobuf_transfn)
Process input parameters and row data into state.