PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ _PG_init()

void _PG_init ( void  )

Definition at line 435 of file rtpostgis.c.

435  {
436 
437  bool boot_postgis_enable_outdb_rasters = false;
438  MemoryContext old_context;
439 
440  /*
441  * Change to context for memory allocation calls like palloc() in the
442  * extension initialization routine
443  */
444  old_context = MemoryContextSwitchTo(TopMemoryContext);
445 
446  /*
447  use POSTGIS_GDAL_ENABLED_DRIVERS to set the bootValue
448  of GUC postgis.gdal_enabled_drivers
449  */
450  env_postgis_gdal_enabled_drivers = getenv("POSTGIS_GDAL_ENABLED_DRIVERS");
451  if (env_postgis_gdal_enabled_drivers == NULL) {
452  size_t sz = sizeof(char) * (strlen(GDAL_DISABLE_ALL) + 1);
455  }
456  else {
459  );
460  }
462  4,
463  "boot_postgis_gdal_enabled_drivers = %s",
465  );
466 
467  /*
468  use POSTGIS_ENABLE_OUTDB_RASTERS to set the bootValue
469  of GUC postgis.enable_outdb_rasters
470  */
471  env_postgis_enable_outdb_rasters = getenv("POSTGIS_ENABLE_OUTDB_RASTERS");
472  if (env_postgis_enable_outdb_rasters != NULL) {
474 
475  /* out of memory */
476  if (env == NULL) {
477  elog(ERROR, "_PG_init: Cannot process environmental variable: POSTGIS_ENABLE_OUTDB_RASTERS");
478  return;
479  }
480 
481  if (strcmp(env, "1") == 0)
482  boot_postgis_enable_outdb_rasters = true;
483 
485  pfree(env);
486  }
488  4,
489  "boot_postgis_enable_outdb_rasters = %s",
490  boot_postgis_enable_outdb_rasters ? "TRUE" : "FALSE"
491  );
492 
493  /* Install liblwgeom handlers */
494  pg_install_lwgeom_handlers();
495 
496  /* Install rtcore handlers */
498 
499  /* Define custom GUC variables. */
500  if ( postgis_guc_find_option("postgis.gdal_datapath") )
501  {
502  /* In this narrow case the previously installed GUC is tied to the callback in */
503  /* the previously loaded library. Probably this is happening during an */
504  /* upgrade, so the old library is where the callback ties to. */
505  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_datapath");
506  }
507  else
508  {
509  DefineCustomStringVariable(
510  "postgis.gdal_datapath", /* name */
511  "Path to GDAL data files.", /* short_desc */
512  "Physical path to directory containing GDAL data files (sets the GDAL_DATA config option).", /* long_desc */
513  &gdal_datapath, /* valueAddr */
514  NULL, /* bootValue */
515  PGC_SUSET, /* GucContext context */
516  0, /* int flags */
517  NULL, /* GucStringCheckHook check_hook */
518  rtpg_assignHookGDALDataPath, /* GucStringAssignHook assign_hook */
519  NULL /* GucShowHook show_hook */
520  );
521  }
522 
523  if ( postgis_guc_find_option("postgis.gdal_enabled_drivers") )
524  {
525  /* In this narrow case the previously installed GUC is tied to the callback in */
526  /* the previously loaded library. Probably this is happening during an */
527  /* upgrade, so the old library is where the callback ties to. */
528  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_enabled_drivers");
529  }
530  else
531  {
532  DefineCustomStringVariable(
533  "postgis.gdal_enabled_drivers", /* name */
534  "Enabled GDAL drivers.", /* short_desc */
535  "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 */
536  &gdal_enabled_drivers, /* valueAddr */
537  boot_postgis_gdal_enabled_drivers, /* bootValue */
538  PGC_SUSET, /* GucContext context */
539  0, /* int flags */
540  NULL, /* GucStringCheckHook check_hook */
541  rtpg_assignHookGDALEnabledDrivers, /* GucStringAssignHook assign_hook */
542  NULL /* GucShowHook show_hook */
543  );
544  }
545 
546  if ( postgis_guc_find_option("postgis.enable_outdb_rasters") )
547  {
548  /* In this narrow case the previously installed GUC is tied to the callback in */
549  /* the previously loaded library. Probably this is happening during an */
550  /* upgrade, so the old library is where the callback ties to. */
551  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.enable_outdb_rasters");
552  }
553  else
554  {
555  DefineCustomBoolVariable(
556  "postgis.enable_outdb_rasters", /* name */
557  "Enable Out-DB raster bands", /* short_desc */
558  "If true, rasters can access data located outside the database", /* long_desc */
559  &enable_outdb_rasters, /* valueAddr */
560  boot_postgis_enable_outdb_rasters, /* bootValue */
561  PGC_SUSET, /* GucContext context */
562  0, /* int flags */
563  NULL, /* GucStringCheckHook check_hook */
564  rtpg_assignHookEnableOutDBRasters, /* GucBoolAssignHook assign_hook */
565  NULL /* GucShowHook show_hook */
566  );
567  }
568 
569  /* Revert back to old context */
570  MemoryContextSwitchTo(old_context);
571 }
#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:377
static void rtpg_assignHookEnableOutDBRasters(bool enable, void *extra)
Definition: rtpostgis.c:429
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: