348 FuncCallContext *funcctx;
358 if (SRF_IS_FIRSTCALL()) {
359 MemoryContext oldcontext;
362 funcctx = SRF_FIRSTCALL_INIT();
365 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
368 if (NULL == drv_set || !drv_count) {
369 elog(NOTICE,
"No GDAL drivers found");
370 MemoryContextSwitchTo(oldcontext);
371 SRF_RETURN_DONE(funcctx);
377 funcctx->user_fctx = drv_set;
380 funcctx->max_calls = drv_count;
383 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
385 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
387 "function returning record called in context " 388 "that cannot accept type record" 393 BlessTupleDesc(tupdesc);
394 funcctx->tuple_desc = tupdesc;
395 MemoryContextSwitchTo(oldcontext);
399 funcctx = SRF_PERCALL_SETUP();
401 call_cntr = funcctx->call_cntr;
402 max_calls = funcctx->max_calls;
403 tupdesc = funcctx->tuple_desc;
404 drv_set2 = funcctx->user_fctx;
407 if (call_cntr < max_calls) {
417 values[0] = Int32GetDatum(drv_set2[call_cntr].idx);
418 values[1] = CStringGetTextDatum(drv_set2[call_cntr].short_name);
419 values[2] = CStringGetTextDatum(drv_set2[call_cntr].long_name);
420 values[3] = CStringGetTextDatum(drv_set2[call_cntr].create_options);
423 POSTGIS_RT_DEBUGF(4,
"Result %d, Short Name %s", call_cntr, drv_set2[call_cntr].short_name);
424 POSTGIS_RT_DEBUGF(4,
"Result %d, Full Name %s", call_cntr, drv_set2[call_cntr].long_name);
425 POSTGIS_RT_DEBUGF(5,
"Result %d, Create Options %s", call_cntr, drv_set2[call_cntr].create_options);
428 tuple = heap_form_tuple(tupdesc, values, nulls);
431 result = HeapTupleGetDatum(tuple);
434 pfree(drv_set2[call_cntr].short_name);
435 pfree(drv_set2[call_cntr].long_name);
436 pfree(drv_set2[call_cntr].create_options);
438 SRF_RETURN_NEXT(funcctx, result);
443 SRF_RETURN_DONE(funcctx);
#define POSTGIS_RT_DEBUGF(level, msg,...)
rt_gdaldriver rt_raster_gdal_drivers(uint32_t *drv_count, uint8_t cancc)
Returns a set of available GDAL drivers.