76 FuncCallContext *funcctx;
81 AttInMetadata *attinmeta;
82 MemoryContext oldcontext, newcontext;
89 if (SRF_IS_FIRSTCALL())
91 funcctx = SRF_FIRSTCALL_INIT();
92 newcontext = funcctx->multi_call_memory_ctx;
94 oldcontext = MemoryContextSwitchTo(newcontext);
96 pglwgeom = PG_GETARG_GSERIALIZED_P_COPY(0);
101 state->
root = lwgeom;
115 funcctx->user_fctx = state;
121 get_call_result_type(fcinfo, 0, &tupdesc);
122 BlessTupleDesc(tupdesc);
128 attinmeta = TupleDescGetAttInMetadata(tupdesc);
129 funcctx->attinmeta = attinmeta;
131 MemoryContextSwitchTo(oldcontext);
135 funcctx = SRF_PERCALL_SETUP();
136 newcontext = funcctx->multi_call_memory_ctx;
139 state = funcctx->user_fctx;
142 if ( ! state->
root ) SRF_RETURN_DONE(funcctx);
149 tuple = BuildTupleFromCStrings(funcctx->attinmeta, values);
150 result = HeapTupleGetDatum(tuple);
153 SRF_RETURN_NEXT(funcctx, result);
171 if ( i ) ptr += sprintf(ptr,
",");
172 ptr += sprintf(ptr,
"%d", state->
stack[i]->
idx+1);
186 oldcontext = MemoryContextSwitchTo(newcontext);
193 MemoryContextSwitchTo(oldcontext);
198 if ( !
POP(state) ) SRF_RETURN_DONE(funcctx);
206 tuple = BuildTupleFromCStrings(funcctx->attinmeta, values);
207 result = TupleGetDatum(funcctx->slot, tuple);
209 SRF_RETURN_NEXT(funcctx, result);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
char * lwgeom_to_hexwkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
void * lwalloc(size_t size)
GEOMDUMPNODE * stack[MAXDEPTH]