PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ _PG_init()

void _PG_init ( void  )

Definition at line 651 of file rtpostgis.c.

651  {
652 
653  bool boot_postgis_enable_outdb_rasters = false;
654  MemoryContext old_context;
655 
656  /*
657  * Change to context for memory allocation calls like palloc() in the
658  * extension initialization routine
659  */
660  old_context = MemoryContextSwitchTo(TopMemoryContext);
661 
662  /*
663  use POSTGIS_GDAL_ENABLED_DRIVERS to set the bootValue
664  of GUC postgis.gdal_enabled_drivers
665  */
666  env_postgis_gdal_enabled_drivers = getenv("POSTGIS_GDAL_ENABLED_DRIVERS");
667  if (env_postgis_gdal_enabled_drivers == NULL) {
668  size_t sz = sizeof(char) * (strlen(GDAL_DISABLE_ALL) + 1);
671  }
672  else {
675  );
676  }
678  4,
679  "boot_postgis_gdal_enabled_drivers = %s",
681  );
682 
683  /*
684  use POSTGIS_ENABLE_OUTDB_RASTERS to set the bootValue
685  of GUC postgis.enable_outdb_rasters
686  */
687  env_postgis_enable_outdb_rasters = getenv("POSTGIS_ENABLE_OUTDB_RASTERS");
688  if (env_postgis_enable_outdb_rasters != NULL) {
690 
691  /* out of memory */
692  if (env == NULL) {
693  elog(ERROR, "_PG_init: Cannot process environmental variable: POSTGIS_ENABLE_OUTDB_RASTERS");
694  return;
695  }
696 
697  if (strcmp(env, "1") == 0)
698  boot_postgis_enable_outdb_rasters = true;
699 
701  pfree(env);
702  }
704  4,
705  "boot_postgis_enable_outdb_rasters = %s",
706  boot_postgis_enable_outdb_rasters ? "TRUE" : "FALSE"
707  );
708 
709  /* Install liblwgeom handlers */
710  pg_install_lwgeom_handlers();
711 
712  /* Install rtcore handlers */
715  rt_pg_options);
716 
717  /* Define custom GUC variables. */
718  if ( postgis_guc_find_option("postgis.gdal_datapath") )
719  {
720  /* In this narrow case the previously installed GUC is tied to the callback in */
721  /* the previously loaded library. Probably this is happening during an */
722  /* upgrade, so the old library is where the callback ties to. */
723  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_datapath");
724  }
725  else
726  {
727  DefineCustomStringVariable(
728  "postgis.gdal_datapath", /* name */
729  "Path to GDAL data files.", /* short_desc */
730  "Physical path to directory containing GDAL data files (sets the GDAL_DATA config option).", /* long_desc */
731  &gdal_datapath, /* valueAddr */
732  NULL, /* bootValue */
733  PGC_SUSET, /* GucContext context */
734  0, /* int flags */
735  NULL, /* GucStringCheckHook check_hook */
736  rtpg_assignHookGDALDataPath, /* GucStringAssignHook assign_hook */
737  NULL /* GucShowHook show_hook */
738  );
739  }
740 
741  if ( postgis_guc_find_option("postgis.gdal_enabled_drivers") )
742  {
743  /* In this narrow case the previously installed GUC is tied to the callback in */
744  /* the previously loaded library. Probably this is happening during an */
745  /* upgrade, so the old library is where the callback ties to. */
746  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_enabled_drivers");
747  }
748  else
749  {
750  DefineCustomStringVariable(
751  "postgis.gdal_enabled_drivers", /* name */
752  "Enabled GDAL drivers.", /* short_desc */
753  "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 */
754  &gdal_enabled_drivers, /* valueAddr */
755  boot_postgis_gdal_enabled_drivers, /* bootValue */
756  PGC_SUSET, /* GucContext context */
757  0, /* int flags */
758  NULL, /* GucStringCheckHook check_hook */
759  rtpg_assignHookGDALEnabledDrivers, /* GucStringAssignHook assign_hook */
760  NULL /* GucShowHook show_hook */
761  );
762  }
763 
764  if ( postgis_guc_find_option("postgis.enable_outdb_rasters") )
765  {
766  /* In this narrow case the previously installed GUC is tied to the callback in */
767  /* the previously loaded library. Probably this is happening during an */
768  /* upgrade, so the old library is where the callback ties to. */
769  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.enable_outdb_rasters");
770  }
771  else
772  {
773  DefineCustomBoolVariable(
774  "postgis.enable_outdb_rasters", /* name */
775  "Enable Out-DB raster bands", /* short_desc */
776  "If true, rasters can access data located outside the database", /* long_desc */
777  &enable_outdb_rasters, /* valueAddr */
778  boot_postgis_enable_outdb_rasters, /* bootValue */
779  PGC_SUSET, /* GucContext context */
780  0, /* int flags */
781  NULL, /* GucBoolCheckHook check_hook */
782  rtpg_assignHookEnableOutDBRasters, /* GucBoolAssignHook assign_hook */
783  NULL /* GucShowHook show_hook */
784  );
785  }
786 
787  /* Prototype for CPL_Degbuf control function. */
788  if ( postgis_guc_find_option("postgis.gdal_cpl_debug") )
789  {
790  /* In this narrow case the previously installed GUC is tied to the callback in */
791  /* the previously loaded library. Probably this is happening during an */
792  /* upgrade, so the old library is where the callback ties to. */
793  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_cpl_debug");
794  }
795  else
796  {
797  DefineCustomBoolVariable(
798  "postgis.gdal_cpl_debug", /* name */
799  "Enable GDAL debugging messages", /* short_desc */
800  "GDAL debug messages will be sent at the PgSQL debug log level", /* long_desc */
801  &gdal_cpl_debug, /* valueAddr */
802  false, /* bootValue */
803  PGC_SUSET, /* GucContext context */
804  0, /* int flags */
805  NULL, /* GucBoolCheckHook check_hook */
806  rtpg_gdal_set_cpl_debug, /* GucBoolAssignHook assign_hook */
807  NULL /* GucShowHook show_hook */
808  );
809  }
810 
811  if ( postgis_guc_find_option("postgis.gdal_vsi_options") )
812  {
813  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_vsi_options");
814  }
815  else
816  {
817  DefineCustomStringVariable(
818  "postgis.gdal_vsi_options", /* name */
819  "VSI config options", /* short_desc */
820  "Set the config options to be used when opening /vsi/ network files", /* long_desc */
821  &gdal_vsi_options, /* valueAddr */
822  "", /* bootValue */
823  PGC_USERSET, /* GucContext context */
824  0, /* int flags */
825  rt_pg_vsi_check_options, /* GucStringCheckHook check_hook */
826  NULL, /* GucStringAssignHook assign_hook */
827  NULL /* GucShowHook show_hook */
828  );
829  }
830 
831  /* Revert back to old context */
832  MemoryContextSwitchTo(old_context);
833 }
#define GDAL_DISABLE_ALL
Definition: librtcore.h:2238
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
void rtpg_gdal_set_cpl_debug(bool value, void *extra)
Definition: rtpg_gdal.c:1147
char * rtpg_trim(const char *input)
static char * rt_pg_options(const char *varname)
Definition: rtpostgis.c:252
static char * env_postgis_enable_outdb_rasters
Definition: rtpostgis.c:472
static void * rt_pg_alloc(size_t size)
Definition: rtpostgis.c:175
static char * gdal_vsi_options
Definition: rtpostgis.c:461
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:213
static bool enable_outdb_rasters
Definition: rtpostgis.c:463
static void rt_pg_notice(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:227
static bool rt_pg_vsi_check_options(char **newval, void **extra, GucSource source)
Definition: rtpostgis.c:420
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:187
static void rt_pg_free(void *ptr)
Definition: rtpostgis.c:203
static bool gdal_cpl_debug
Definition: rtpostgis.c:464
static char * gdal_enabled_drivers
Definition: rtpostgis.c:462
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:241
static char * gdal_datapath
Definition: rtpostgis.c:460
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:69

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

Here is the call graph for this function: