76 FuncCallContext *funcctx;
77 MemoryContext oldcontext, newcontext;
87 bool isnull[2] = {0,0};
90 if (SRF_IS_FIRSTCALL()) {
91 funcctx = SRF_FIRSTCALL_INIT();
93 newcontext = funcctx->multi_call_memory_ctx;
94 oldcontext = MemoryContextSwitchTo(newcontext);
97 pglwgeom = PG_GETARG_GSERIALIZED_P_COPY(0);
102 MemoryContextSwitchTo(oldcontext);
103 funcctx = SRF_PERCALL_SETUP();
104 SRF_RETURN_DONE(funcctx);
108 state =
lwalloc(
sizeof *state);
109 state->
root = lwgeom;
115 funcctx->user_fctx = state;
128 if (get_call_result_type(fcinfo, 0, &funcctx->tuple_desc) != TYPEFUNC_COMPOSITE) {
129 ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
130 errmsg(
"set-valued function called in context that cannot accept a set")));
133 BlessTupleDesc(funcctx->tuple_desc);
136 get_typlenbyvalalign(INT4OID, &state->
typlen, &state->
byval, &state->
align);
138 MemoryContextSwitchTo(oldcontext);
142 funcctx = SRF_PERCALL_SETUP();
143 newcontext = funcctx->multi_call_memory_ctx;
146 state = funcctx->user_fctx;
171 switch(lwgeom->
type) {
174 if (state->
pt == 0) {
177 if (state->
pt <= 3) {
235 ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
236 errmsg(
"Invalid Geometry type %d passed to ST_DumpPoints()", lwgeom->
type)));
251 if (--state->
stacklen == 0) SRF_RETURN_DONE(funcctx);
259 pathpt[0] = PointerGetDatum(construct_array(state->
path, state->
pathlen+1,
264 tuple = heap_form_tuple(funcctx->tuple_desc, pathpt, isnull);
265 result = HeapTupleGetDatum(tuple);
266 SRF_RETURN_NEXT(funcctx, result);
275 lwgeom = lwcoll->
geoms[node->
idx++];
290 if (--state->
stacklen == 0) SRF_RETURN_DONE(funcctx);
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)