128 #ifndef HAVE_LIBPROTOBUF
129 elog(ERROR,
"ST_AsMVT: Compiled without protobuf-c support");
132 MemoryContext aggcontext, old_context;
136 postgis_initialize_cache();
138 if (!AggCheckCallContext(fcinfo, &aggcontext))
139 elog(ERROR,
"%s called in non-aggregate context", __func__);
141 if (PG_ARGISNULL(0)) {
142 old_context = MemoryContextSwitchTo(aggcontext);
143 ctx = palloc(
sizeof(*ctx));
144 ctx->
name =
"default";
145 if (PG_NARGS() > 2 && !PG_ARGISNULL(2))
146 ctx->
name = text_to_cstring(PG_GETARG_TEXT_P(2));
148 if (PG_NARGS() > 3 && !PG_ARGISNULL(3))
149 ctx->
extent = PG_GETARG_INT32(3);
151 if (PG_NARGS() > 4 && !PG_ARGISNULL(4))
152 ctx->
geom_name = text_to_cstring(PG_GETARG_TEXT_P(4));
153 if (PG_NARGS() > 5 && !PG_ARGISNULL(5))
154 ctx->
id_name = text_to_cstring(PG_GETARG_TEXT_P(5));
158 ctx->
trans_context = AllocSetContextCreate(aggcontext,
"MVT transfn", ALLOCSET_DEFAULT_SIZES);
162 MemoryContextSwitchTo(old_context);
167 if (!type_is_rowtype(get_fn_expr_argtype(fcinfo->flinfo, 1)))
168 elog(ERROR,
"%s: parameter row cannot be other than a rowtype", __func__);
169 ctx->
row = PG_GETARG_HEAPTUPLEHEADER(1);
173 MemoryContextSwitchTo(old_context);
175 PG_FREE_IF_COPY(ctx->
row, 1);
176 PG_RETURN_POINTER(ctx);
void mvt_agg_init_context(mvt_agg_context *ctx)
Initialize aggregation context.
void mvt_agg_transfn(mvt_agg_context *ctx)
Aggregation step.
MemoryContext trans_context