47{
48#if ! (defined HAVE_LIBPROTOBUF && defined HAVE_GEOBUF)
49 elog(ERROR, "ST_AsGeobuf: Missing libprotobuf-c >= version 1.1");
50 PG_RETURN_NULL();
51#else
52 MemoryContext aggcontext, oldcontext;
54
55
56 postgis_initialize_cache(fcinfo);
57
58 if (!AggCheckCallContext(fcinfo, &aggcontext))
59 elog(ERROR, "pgis_asgeobuf_transfn: called in non-aggregate context");
60 oldcontext = MemoryContextSwitchTo(aggcontext);
61
62 if (PG_ARGISNULL(0)) {
63 ctx = palloc(sizeof(*ctx));
64
66 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
69 } else {
71 }
72
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");
75
76
77 if (PG_ARGISNULL(1)) {
78 PG_RETURN_NULL();
79 }
80
81 ctx->
row = PG_GETARG_HEAPTUPLEHEADER(1);
82
84 MemoryContextSwitchTo(oldcontext);
85 PG_RETURN_POINTER(ctx);
86#endif
87}
void geobuf_agg_init_context(struct geobuf_agg_context *ctx)
Initialize aggregation context.
void geobuf_agg_transfn(struct geobuf_agg_context *ctx)
Aggregation step.
char * text_to_cstring(const text *textptr)