75 FuncCallContext *funcctx;
80 AttInMetadata *attinmeta;
81 MemoryContext oldcontext, newcontext;
88 if (SRF_IS_FIRSTCALL())
90 funcctx = SRF_FIRSTCALL_INIT();
91 newcontext = funcctx->multi_call_memory_ctx;
93 oldcontext = MemoryContextSwitchTo(newcontext);
95 pglwgeom = PG_GETARG_GSERIALIZED_P_COPY(0);
100 state->
root = lwgeom;
114 funcctx->user_fctx = state;
120 get_call_result_type(fcinfo, 0, &tupdesc);
121 BlessTupleDesc(tupdesc);
127 attinmeta = TupleDescGetAttInMetadata(tupdesc);
128 funcctx->attinmeta = attinmeta;
130 MemoryContextSwitchTo(oldcontext);
134 funcctx = SRF_PERCALL_SETUP();
135 newcontext = funcctx->multi_call_memory_ctx;
138 state = funcctx->user_fctx;
141 if ( ! state->
root ) SRF_RETURN_DONE(funcctx);
148 tuple = BuildTupleFromCStrings(funcctx->attinmeta, values);
149 result = HeapTupleGetDatum(tuple);
152 SRF_RETURN_NEXT(funcctx, result);
170 if ( i ) ptr += sprintf(ptr,
",");
171 ptr += sprintf(ptr,
"%d", state->
stack[i]->
idx+1);
185 oldcontext = MemoryContextSwitchTo(newcontext);
192 MemoryContextSwitchTo(oldcontext);
197 if ( !
POP(state) ) SRF_RETURN_DONE(funcctx);
205 tuple = BuildTupleFromCStrings(funcctx->attinmeta, values);
206 result = TupleGetDatum(funcctx->slot, tuple);
208 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)
void * lwalloc(size_t size)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
GEOMDUMPNODE * stack[MAXDEPTH]