PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ _PG_init()

void _PG_init ( void  )

Definition at line 421 of file rtpostgis.c.

421  {
422 
423  bool boot_postgis_enable_outdb_rasters = false;
424  MemoryContext old_context;
425 
426  /*
427  * Change to context for memory allocation calls like palloc() in the
428  * extension initialization routine
429  */
430  old_context = MemoryContextSwitchTo(TopMemoryContext);
431 
432  /*
433  use POSTGIS_GDAL_ENABLED_DRIVERS to set the bootValue
434  of GUC postgis.gdal_enabled_drivers
435  */
436  env_postgis_gdal_enabled_drivers = getenv("POSTGIS_GDAL_ENABLED_DRIVERS");
437  if (env_postgis_gdal_enabled_drivers == NULL) {
439  sizeof(char) * (strlen(GDAL_DISABLE_ALL) + 1)
440  );
442  }
443  else {
446  );
447  }
449  4,
450  "boot_postgis_gdal_enabled_drivers = %s",
452  );
453 
454  /*
455  use POSTGIS_ENABLE_OUTDB_RASTERS to set the bootValue
456  of GUC postgis.enable_outdb_rasters
457  */
458  env_postgis_enable_outdb_rasters = getenv("POSTGIS_ENABLE_OUTDB_RASTERS");
459  if (env_postgis_enable_outdb_rasters != NULL) {
461 
462  /* out of memory */
463  if (env == NULL) {
464  elog(ERROR, "_PG_init: Cannot process environmental variable: POSTGIS_ENABLE_OUTDB_RASTERS");
465  return;
466  }
467 
468  if (strcmp(env, "1") == 0)
469  boot_postgis_enable_outdb_rasters = true;
470 
472  pfree(env);
473  }
475  4,
476  "boot_postgis_enable_outdb_rasters = %s",
477  boot_postgis_enable_outdb_rasters ? "TRUE" : "FALSE"
478  );
479 
480  /* Install liblwgeom handlers */
481  pg_install_lwgeom_handlers();
482 
483  /* Install rtcore handlers */
485 
486  /* Define custom GUC variables. */
487  if ( postgis_guc_find_option("postgis.gdal_datapath") )
488  {
489  /* In this narrow case the previously installed GUC is tied to the callback in */
490  /* the previously loaded library. Probably this is happening during an */
491  /* upgrade, so the old library is where the callback ties to. */
492  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_datapath");
493  }
494  else
495  {
496  DefineCustomStringVariable(
497  "postgis.gdal_datapath", /* name */
498  "Path to GDAL data files.", /* short_desc */
499  "Physical path to directory containing GDAL data files (sets the GDAL_DATA config option).", /* long_desc */
500  &gdal_datapath, /* valueAddr */
501  NULL, /* bootValue */
502  PGC_SUSET, /* GucContext context */
503  0, /* int flags */
504  NULL, /* GucStringCheckHook check_hook */
505  rtpg_assignHookGDALDataPath, /* GucStringAssignHook assign_hook */
506  NULL /* GucShowHook show_hook */
507  );
508  }
509 
510  if ( postgis_guc_find_option("postgis.gdal_enabled_drivers") )
511  {
512  /* In this narrow case the previously installed GUC is tied to the callback in */
513  /* the previously loaded library. Probably this is happening during an */
514  /* upgrade, so the old library is where the callback ties to. */
515  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_enabled_drivers");
516  }
517  else
518  {
519  DefineCustomStringVariable(
520  "postgis.gdal_enabled_drivers", /* name */
521  "Enabled GDAL drivers.", /* short_desc */
522  "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 */
523  &gdal_enabled_drivers, /* valueAddr */
524  boot_postgis_gdal_enabled_drivers, /* bootValue */
525  PGC_SUSET, /* GucContext context */
526  0, /* int flags */
527  NULL, /* GucStringCheckHook check_hook */
528  rtpg_assignHookGDALEnabledDrivers, /* GucStringAssignHook assign_hook */
529  NULL /* GucShowHook show_hook */
530  );
531  }
532 
533  if ( postgis_guc_find_option("postgis.enable_outdb_rasters") )
534  {
535  /* In this narrow case the previously installed GUC is tied to the callback in */
536  /* the previously loaded library. Probably this is happening during an */
537  /* upgrade, so the old library is where the callback ties to. */
538  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.enable_outdb_rasters");
539  }
540  else
541  {
542  DefineCustomBoolVariable(
543  "postgis.enable_outdb_rasters", /* name */
544  "Enable Out-DB raster bands", /* short_desc */
545  "If true, rasters can access data located outside the database", /* long_desc */
546  &enable_outdb_rasters, /* valueAddr */
547  boot_postgis_enable_outdb_rasters, /* bootValue */
548  PGC_SUSET, /* GucContext context */
549  0, /* int flags */
550  NULL, /* GucStringCheckHook check_hook */
551  rtpg_assignHookEnableOutDBRasters, /* GucBoolAssignHook assign_hook */
552  NULL /* GucShowHook show_hook */
553  );
554  }
555 
556  /* Revert back to old context */
557  MemoryContextSwitchTo(old_context);
558 }
#define GDAL_DISABLE_ALL
Definition: librtcore.h:2049
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
char * rtpg_trim(const char *input)
static char * env_postgis_enable_outdb_rasters
Definition: rtpostgis.c:257
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_error(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:204
bool enable_outdb_rasters
Definition: rt_band.c:417
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
static char * boot_postgis_gdal_enabled_drivers
Definition: rtpostgis.c:256
static void rtpg_assignHookGDALEnabledDrivers(const char *enabled_drivers, void *extra)
Definition: rtpostgis.c:278
static void * rt_pg_realloc(void *mem, size_t size)
Definition: rtpostgis.c:178
static void rt_pg_free(void *ptr)
Definition: rtpostgis.c:194
char * gdal_enabled_drivers
Definition: rt_util.c:375
static void rtpg_assignHookEnableOutDBRasters(bool enable, void *extra)
Definition: rtpostgis.c:415
static void rt_pg_debug(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:232
static char * gdal_datapath
Definition: rtpostgis.c:247
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:65

References boot_postgis_gdal_enabled_drivers, enable_outdb_rasters, env_postgis_enable_outdb_rasters, env_postgis_gdal_enabled_drivers, gdal_datapath, GDAL_DISABLE_ALL, gdal_enabled_drivers, 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().

Here is the call graph for this function: