PostGIS  2.2.7dev-r@@SVN_REVISION@@
void _PG_init ( void  )

Definition at line 421 of file rtpostgis.c.

References GDAL_DISABLE_ALL, POSTGIS_PGSQL_VERSION, POSTGIS_RT_DEBUGF, rt_pg_alloc(), rt_pg_debug(), rt_pg_error(), rt_pg_free(), rt_pg_notice(), rt_pg_realloc(), rt_set_handlers(), rtpg_assignHookEnableOutDBRasters(), rtpg_assignHookGDALDataPath(), rtpg_assignHookGDALEnabledDrivers(), and rtpg_trim().

421  {
422 
423  bool boot_postgis_enable_outdb_rasters = false;
424  MemoryContext old_context;
425 
426  /* Install liblwgeom handlers */
427  pg_install_lwgeom_handlers();
428 
429  /* Install rtcore handlers */
431 
432  /*
433  * Change to context for memory allocation calls like palloc() in the
434  * extension initialization routine
435  */
436  old_context = MemoryContextSwitchTo(TopMemoryContext);
437 
438  /*
439  use POSTGIS_GDAL_ENABLED_DRIVERS to set the bootValue
440  of GUC postgis.gdal_enabled_drivers
441  */
442  env_postgis_gdal_enabled_drivers = getenv("POSTGIS_GDAL_ENABLED_DRIVERS");
443  if (env_postgis_gdal_enabled_drivers == NULL) {
445  sizeof(char) * (strlen(GDAL_DISABLE_ALL) + 1)
446  );
448  }
449  else {
452  );
453  }
455  4,
456  "boot_postgis_gdal_enabled_drivers = %s",
458  );
459 
460  /*
461  use POSTGIS_ENABLE_OUTDB_RASTERS to set the bootValue
462  of GUC postgis.enable_outdb_rasters
463  */
464  env_postgis_enable_outdb_rasters = getenv("POSTGIS_ENABLE_OUTDB_RASTERS");
465  if (env_postgis_enable_outdb_rasters != NULL) {
467 
468  /* out of memory */
469  if (env == NULL) {
470  elog(ERROR, "_PG_init: Cannot process environmental variable: POSTGIS_ENABLE_OUTDB_RASTERS");
471  return;
472  }
473 
474  if (strcmp(env, "1") == 0)
475  boot_postgis_enable_outdb_rasters = true;
476 
477  pfree(env);
478  }
480  4,
481  "boot_postgis_enable_outdb_rasters = %s",
482  boot_postgis_enable_outdb_rasters ? "TRUE" : "FALSE"
483  );
484 
485  /* Define custom GUC variables. */
486  DefineCustomStringVariable(
487  "postgis.gdal_datapath", /* name */
488  "Path to GDAL data files.", /* short_desc */
489  "Physical path to directory containing GDAL data files (sets the GDAL_DATA config option).", /* long_desc */
490  &gdal_datapath, /* valueAddr */
491  NULL, /* bootValue */
492  PGC_SUSET, /* GucContext context */
493  0, /* int flags */
494 #if POSTGIS_PGSQL_VERSION >= 91
495  NULL, /* GucStringCheckHook check_hook */
496 #endif
497  rtpg_assignHookGDALDataPath, /* GucStringAssignHook assign_hook */
498  NULL /* GucShowHook show_hook */
499  );
500 
501  DefineCustomStringVariable(
502  "postgis.gdal_enabled_drivers", /* name */
503  "Enabled GDAL drivers.", /* short_desc */
504  "List of enabled GDAL drivers by short name. To enable/disable all drivers, use 'ENABLE_ALL' or 'DISABLE_ALL' (sets the GDAL_SKIP config option).", /* long_desc */
505  &gdal_enabled_drivers, /* valueAddr */
506  boot_postgis_gdal_enabled_drivers, /* bootValue */
507  PGC_SUSET, /* GucContext context */
508  0, /* int flags */
509 #if POSTGIS_PGSQL_VERSION >= 91
510  NULL, /* GucStringCheckHook check_hook */
511 #endif
512  rtpg_assignHookGDALEnabledDrivers, /* GucStringAssignHook assign_hook */
513  NULL /* GucShowHook show_hook */
514  );
515 
516  DefineCustomBoolVariable(
517  "postgis.enable_outdb_rasters", /* name */
518  "Enable Out-DB raster bands", /* short_desc */
519  "If true, rasters can access data located outside the database", /* long_desc */
520  &enable_outdb_rasters, /* valueAddr */
521  boot_postgis_enable_outdb_rasters, /* bootValue */
522  PGC_SUSET, /* GucContext context */
523  0, /* int flags */
524 #if POSTGIS_PGSQL_VERSION >= 91
525  NULL, /* GucStringCheckHook check_hook */
526 #endif
527  rtpg_assignHookEnableOutDBRasters, /* GucBoolAssignHook assign_hook */
528  NULL /* GucShowHook show_hook */
529  );
530 
531  /* Revert back to old context */
532  MemoryContextSwitchTo(old_context);
533 }
static void rtpg_assignHookGDALEnabledDrivers(const char *enabled_drivers, void *extra)
Definition: rtpostgis.c:278
void rt_set_handlers(rt_allocator allocator, rt_reallocator reallocator, rt_deallocator deallocator, rt_message_handler error_handler, rt_message_handler info_handler, rt_message_handler warning_handler)
This function is called when the PostgreSQL backend is taking care of the memory and we want to use p...
Definition: rt_context.c:151
static void rt_pg_notice(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:218
static char * env_postgis_gdal_enabled_drivers
Definition: rtpostgis.c:255
char enable_outdb_rasters
Definition: rt_band.c:319
#define GDAL_DISABLE_ALL
Definition: librtcore.h:2012
static char * env_postgis_enable_outdb_rasters
Definition: rtpostgis.c:257
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:57
static void rtpg_assignHookEnableOutDBRasters(bool enable, void *extra)
Definition: rtpostgis.c:415
char * gdal_enabled_drivers
Definition: rt_util.c:373
static char * boot_postgis_gdal_enabled_drivers
Definition: rtpostgis.c:256
static char * gdal_datapath
Definition: rtpostgis.c:247
#define POSTGIS_PGSQL_VERSION
Definition: sqldefines.h:9
char * rtpg_trim(const char *input)
static void rt_pg_error(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:204
static void rt_pg_free(void *ptr)
Definition: rtpostgis.c:194
static void rt_pg_debug(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:232
static void * rt_pg_alloc(size_t size)
Definition: rtpostgis.c:166
static void rtpg_assignHookGDALDataPath(const char *newpath, void *extra)
Definition: rtpostgis.c:261
static void * rt_pg_realloc(void *mem, size_t size)
Definition: rtpostgis.c:178

Here is the call graph for this function: