341 FuncCallContext *funcctx;
351 if (SRF_IS_FIRSTCALL()) {
352 MemoryContext oldcontext;
355 funcctx = SRF_FIRSTCALL_INIT();
358 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
361 if (NULL == drv_set || !drv_count) {
362 elog(NOTICE,
"No GDAL drivers found");
363 MemoryContextSwitchTo(oldcontext);
364 SRF_RETURN_DONE(funcctx);
370 funcctx->user_fctx = drv_set;
373 funcctx->max_calls = drv_count;
376 if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
378 errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
380 "function returning record called in context "
381 "that cannot accept type record"
386 BlessTupleDesc(tupdesc);
387 funcctx->tuple_desc = tupdesc;
388 MemoryContextSwitchTo(oldcontext);
392 funcctx = SRF_PERCALL_SETUP();
394 call_cntr = funcctx->call_cntr;
395 max_calls = funcctx->max_calls;
396 tupdesc = funcctx->tuple_desc;
397 drv_set2 = funcctx->user_fctx;
400 if (call_cntr < max_calls) {
410 values[0] = Int32GetDatum(drv_set2[call_cntr].idx);
411 values[1] = CStringGetTextDatum(drv_set2[call_cntr].short_name);
412 values[2] = CStringGetTextDatum(drv_set2[call_cntr].long_name);
413 values[3] = BoolGetDatum(drv_set2[call_cntr].can_read);
414 values[4] = BoolGetDatum(drv_set2[call_cntr].can_write);
415 values[5] = CStringGetTextDatum(drv_set2[call_cntr].create_options);
418 POSTGIS_RT_DEBUGF(4,
"Result %d, Short Name %s", call_cntr, drv_set2[call_cntr].short_name);
419 POSTGIS_RT_DEBUGF(4,
"Result %d, Full Name %s", call_cntr, drv_set2[call_cntr].long_name);
420 POSTGIS_RT_DEBUGF(4,
"Result %d, Can Read %s", call_cntr, drv_set2[call_cntr].can_read);
421 POSTGIS_RT_DEBUGF(4,
"Result %d, Can Write %s", call_cntr, drv_set2[call_cntr].can_write);
422 POSTGIS_RT_DEBUGF(5,
"Result %d, Create Options %s", call_cntr, drv_set2[call_cntr].create_options);
425 tuple = heap_form_tuple(tupdesc, values, nulls);
428 result = HeapTupleGetDatum(tuple);
431 pfree(drv_set2[call_cntr].short_name);
432 pfree(drv_set2[call_cntr].long_name);
433 pfree(drv_set2[call_cntr].create_options);
435 SRF_RETURN_NEXT(funcctx, result);
440 SRF_RETURN_DONE(funcctx);
rt_gdaldriver rt_raster_gdal_drivers(uint32_t *drv_count, uint8_t cancc)
Returns a set of available GDAL drivers.
#define POSTGIS_RT_DEBUGF(level, msg,...)