PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ _PG_init()

void _PG_init ( void  )

Definition at line 693 of file rtpostgis.c.

693  {
694 
695  bool boot_postgis_enable_outdb_rasters = false;
696  MemoryContext old_context;
697 
698  /* Set up interrupt capture */
699  coreIntHandler = pqsignal(SIGINT, handleInterrupt);
700 
701 #ifdef WIN32
702  GEOS_interruptRegisterCallback(interruptCallback);
703  lwgeom_register_interrupt_callback(interruptCallback);
704 #endif
705 
706 
707  /*
708  * Change to context for memory allocation calls like palloc() in the
709  * extension initialization routine
710  */
711  old_context = MemoryContextSwitchTo(TopMemoryContext);
712 
713  /*
714  use POSTGIS_GDAL_ENABLED_DRIVERS to set the bootValue
715  of GUC postgis.gdal_enabled_drivers
716  */
717  env_postgis_gdal_enabled_drivers = getenv("POSTGIS_GDAL_ENABLED_DRIVERS");
718  if (env_postgis_gdal_enabled_drivers == NULL) {
719  size_t sz = sizeof(char) * (strlen(GDAL_DISABLE_ALL) + 1);
722  }
723  else {
726  );
727  }
729  4,
730  "boot_postgis_gdal_enabled_drivers = %s",
732  );
733 
734  /*
735  use POSTGIS_ENABLE_OUTDB_RASTERS to set the bootValue
736  of GUC postgis.enable_outdb_rasters
737  */
738  env_postgis_enable_outdb_rasters = getenv("POSTGIS_ENABLE_OUTDB_RASTERS");
739  if (env_postgis_enable_outdb_rasters != NULL) {
741 
742  /* out of memory */
743  if (env == NULL) {
744  elog(ERROR, "_PG_init: Cannot process environmental variable: POSTGIS_ENABLE_OUTDB_RASTERS");
745  return;
746  }
747 
748  if (strcmp(env, "1") == 0)
749  boot_postgis_enable_outdb_rasters = true;
750 
752  pfree(env);
753  }
755  4,
756  "boot_postgis_enable_outdb_rasters = %s",
757  boot_postgis_enable_outdb_rasters ? "TRUE" : "FALSE"
758  );
759 
760  /* Install liblwgeom handlers */
761  pg_install_lwgeom_handlers();
762 
763  /* Install rtcore handlers */
766  rt_pg_options);
767 
768  /* Define custom GUC variables. */
769  if ( postgis_guc_find_option("postgis.gdal_datapath") )
770  {
771  /* In this narrow case the previously installed GUC is tied to the callback in */
772  /* the previously loaded library. Probably this is happening during an */
773  /* upgrade, so the old library is where the callback ties to. */
774  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_datapath");
775  }
776  else
777  {
778  DefineCustomStringVariable(
779  "postgis.gdal_datapath", /* name */
780  "Path to GDAL data files.", /* short_desc */
781  "Physical path to directory containing GDAL data files (sets the GDAL_DATA config option).", /* long_desc */
782  &gdal_datapath, /* valueAddr */
783  NULL, /* bootValue */
784  PGC_SUSET, /* GucContext context */
785  0, /* int flags */
786  NULL, /* GucStringCheckHook check_hook */
787  rtpg_assignHookGDALDataPath, /* GucStringAssignHook assign_hook */
788  NULL /* GucShowHook show_hook */
789  );
790  }
791 
792  if ( postgis_guc_find_option("postgis.gdal_enabled_drivers") )
793  {
794  /* In this narrow case the previously installed GUC is tied to the callback in */
795  /* the previously loaded library. Probably this is happening during an */
796  /* upgrade, so the old library is where the callback ties to. */
797  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_enabled_drivers");
798  }
799  else
800  {
801  DefineCustomStringVariable(
802  "postgis.gdal_enabled_drivers", /* name */
803  "Enabled GDAL drivers.", /* short_desc */
804  "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 */
805  &gdal_enabled_drivers, /* valueAddr */
806  boot_postgis_gdal_enabled_drivers, /* bootValue */
807  PGC_SUSET, /* GucContext context */
808  0, /* int flags */
809  NULL, /* GucStringCheckHook check_hook */
810  rtpg_assignHookGDALEnabledDrivers, /* GucStringAssignHook assign_hook */
811  NULL /* GucShowHook show_hook */
812  );
813  }
814 
815  if ( postgis_guc_find_option("postgis.enable_outdb_rasters") )
816  {
817  /* In this narrow case the previously installed GUC is tied to the callback in */
818  /* the previously loaded library. Probably this is happening during an */
819  /* upgrade, so the old library is where the callback ties to. */
820  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.enable_outdb_rasters");
821  }
822  else
823  {
824  DefineCustomBoolVariable(
825  "postgis.enable_outdb_rasters", /* name */
826  "Enable Out-DB raster bands", /* short_desc */
827  "If true, rasters can access data located outside the database", /* long_desc */
828  &enable_outdb_rasters, /* valueAddr */
829  boot_postgis_enable_outdb_rasters, /* bootValue */
830  PGC_SUSET, /* GucContext context */
831  0, /* int flags */
832  NULL, /* GucBoolCheckHook check_hook */
833  rtpg_assignHookEnableOutDBRasters, /* GucBoolAssignHook assign_hook */
834  NULL /* GucShowHook show_hook */
835  );
836  }
837 
838  if ( postgis_guc_find_option("postgis.gdal_vsi_options") )
839  {
840  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_vsi_options");
841  }
842  else
843  {
844  DefineCustomStringVariable(
845  "postgis.gdal_vsi_options", /* name */
846  "VSI config options", /* short_desc */
847  "Set the config options to be used when opening /vsi/ network files", /* long_desc */
848  &gdal_vsi_options, /* valueAddr */
849  "", /* bootValue */
850  PGC_USERSET, /* GucContext context */
851  0, /* int flags */
852  rt_pg_vsi_check_options, /* GucStringCheckHook check_hook */
853  NULL, /* GucStringAssignHook assign_hook */
854  NULL /* GucShowHook show_hook */
855  );
856  }
857 
858  /* Revert back to old context */
859  MemoryContextSwitchTo(old_context);
860 }
lwinterrupt_callback * lwgeom_register_interrupt_callback(lwinterrupt_callback *)
Definition: lwgeom_api.c:673
#define GDAL_DISABLE_ALL
Definition: librtcore.h:2193
void rt_set_handlers_options(rt_allocator allocator, rt_reallocator reallocator, rt_deallocator deallocator, rt_message_handler error_handler, rt_message_handler info_handler, rt_message_handler warning_handler, rt_options options_handler)
Definition: rt_context.c:169
char * rtpg_trim(const char *input)
static char * rt_pg_options(const char *varname)
Definition: rtpostgis.c:253
static void handleInterrupt(int sig)
Definition: rtpostgis.c:672
static char * env_postgis_enable_outdb_rasters
Definition: rtpostgis.c:472
static void * rt_pg_alloc(size_t size)
Definition: rtpostgis.c:176
static char * gdal_vsi_options
Definition: rtpostgis.c:462
static void rtpg_assignHookGDALDataPath(const char *newpath, void *extra)
Definition: rtpostgis.c:476
static void rt_pg_error(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:214
static bool enable_outdb_rasters
Definition: rtpostgis.c:464
static void rt_pg_notice(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:228
static bool rt_pg_vsi_check_options(char **newval, void **extra, GucSource source)
Definition: rtpostgis.c:421
static pqsigfunc coreIntHandler
Definition: rtpostgis.c:655
static char * env_postgis_gdal_enabled_drivers
Definition: rtpostgis.c:470
static char * boot_postgis_gdal_enabled_drivers
Definition: rtpostgis.c:471
static void rtpg_assignHookGDALEnabledDrivers(const char *enabled_drivers, void *extra)
Definition: rtpostgis.c:493
static void * rt_pg_realloc(void *mem, size_t size)
Definition: rtpostgis.c:188
static void rt_pg_free(void *ptr)
Definition: rtpostgis.c:204
static char * gdal_enabled_drivers
Definition: rtpostgis.c:463
static void rtpg_assignHookEnableOutDBRasters(bool enable, void *extra)
Definition: rtpostgis.c:644
static void rt_pg_debug(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:242
static char * gdal_datapath
Definition: rtpostgis.c:461
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:69

References boot_postgis_gdal_enabled_drivers, coreIntHandler, enable_outdb_rasters, env_postgis_enable_outdb_rasters, env_postgis_gdal_enabled_drivers, gdal_datapath, GDAL_DISABLE_ALL, gdal_enabled_drivers, gdal_vsi_options, handleInterrupt(), lwgeom_register_interrupt_callback(), POSTGIS_RT_DEBUGF, rt_pg_alloc(), rt_pg_debug(), rt_pg_error(), rt_pg_free(), rt_pg_notice(), rt_pg_options(), rt_pg_realloc(), rt_pg_vsi_check_options(), rt_set_handlers_options(), rtpg_assignHookEnableOutDBRasters(), rtpg_assignHookGDALDataPath(), rtpg_assignHookGDALEnabledDrivers(), and rtpg_trim().

Here is the call graph for this function: