PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ _PG_init()

void _PG_init ( void  )

Definition at line 644 of file rtpostgis.c.

644  {
645 
646  bool boot_postgis_enable_outdb_rasters = false;
647  MemoryContext old_context;
648 
649  /*
650  * Change to context for memory allocation calls like palloc() in the
651  * extension initialization routine
652  */
653  old_context = MemoryContextSwitchTo(TopMemoryContext);
654 
655  /*
656  use POSTGIS_GDAL_ENABLED_DRIVERS to set the bootValue
657  of GUC postgis.gdal_enabled_drivers
658  */
659  env_postgis_gdal_enabled_drivers = getenv("POSTGIS_GDAL_ENABLED_DRIVERS");
660  if (env_postgis_gdal_enabled_drivers == NULL) {
661  size_t sz = sizeof(char) * (strlen(GDAL_DISABLE_ALL) + 1);
664  }
665  else {
668  );
669  }
671  4,
672  "boot_postgis_gdal_enabled_drivers = %s",
674  );
675 
676  /*
677  use POSTGIS_ENABLE_OUTDB_RASTERS to set the bootValue
678  of GUC postgis.enable_outdb_rasters
679  */
680  env_postgis_enable_outdb_rasters = getenv("POSTGIS_ENABLE_OUTDB_RASTERS");
681  if (env_postgis_enable_outdb_rasters != NULL) {
683 
684  /* out of memory */
685  if (env == NULL) {
686  elog(ERROR, "_PG_init: Cannot process environmental variable: POSTGIS_ENABLE_OUTDB_RASTERS");
687  return;
688  }
689 
690  if (strcmp(env, "1") == 0)
691  boot_postgis_enable_outdb_rasters = true;
692 
694  pfree(env);
695  }
697  4,
698  "boot_postgis_enable_outdb_rasters = %s",
699  boot_postgis_enable_outdb_rasters ? "TRUE" : "FALSE"
700  );
701 
702  /* Install liblwgeom handlers */
703  pg_install_lwgeom_handlers();
704 
705  /* Install rtcore handlers */
708  rt_pg_options);
709 
710  /* Define custom GUC variables. */
711  if ( postgis_guc_find_option("postgis.gdal_datapath") )
712  {
713  /* In this narrow case the previously installed GUC is tied to the callback in */
714  /* the previously loaded library. Probably this is happening during an */
715  /* upgrade, so the old library is where the callback ties to. */
716  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_datapath");
717  }
718  else
719  {
720  DefineCustomStringVariable(
721  "postgis.gdal_datapath", /* name */
722  "Path to GDAL data files.", /* short_desc */
723  "Physical path to directory containing GDAL data files (sets the GDAL_DATA config option).", /* long_desc */
724  &gdal_datapath, /* valueAddr */
725  NULL, /* bootValue */
726  PGC_SUSET, /* GucContext context */
727  0, /* int flags */
728  NULL, /* GucStringCheckHook check_hook */
729  rtpg_assignHookGDALDataPath, /* GucStringAssignHook assign_hook */
730  NULL /* GucShowHook show_hook */
731  );
732  }
733 
734  if ( postgis_guc_find_option("postgis.gdal_enabled_drivers") )
735  {
736  /* In this narrow case the previously installed GUC is tied to the callback in */
737  /* the previously loaded library. Probably this is happening during an */
738  /* upgrade, so the old library is where the callback ties to. */
739  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_enabled_drivers");
740  }
741  else
742  {
743  DefineCustomStringVariable(
744  "postgis.gdal_enabled_drivers", /* name */
745  "Enabled GDAL drivers.", /* short_desc */
746  "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 */
747  &gdal_enabled_drivers, /* valueAddr */
748  boot_postgis_gdal_enabled_drivers, /* bootValue */
749  PGC_SUSET, /* GucContext context */
750  0, /* int flags */
751  NULL, /* GucStringCheckHook check_hook */
752  rtpg_assignHookGDALEnabledDrivers, /* GucStringAssignHook assign_hook */
753  NULL /* GucShowHook show_hook */
754  );
755  }
756 
757  if ( postgis_guc_find_option("postgis.enable_outdb_rasters") )
758  {
759  /* In this narrow case the previously installed GUC is tied to the callback in */
760  /* the previously loaded library. Probably this is happening during an */
761  /* upgrade, so the old library is where the callback ties to. */
762  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.enable_outdb_rasters");
763  }
764  else
765  {
766  DefineCustomBoolVariable(
767  "postgis.enable_outdb_rasters", /* name */
768  "Enable Out-DB raster bands", /* short_desc */
769  "If true, rasters can access data located outside the database", /* long_desc */
770  &enable_outdb_rasters, /* valueAddr */
771  boot_postgis_enable_outdb_rasters, /* bootValue */
772  PGC_SUSET, /* GucContext context */
773  0, /* int flags */
774  NULL, /* GucBoolCheckHook check_hook */
775  rtpg_assignHookEnableOutDBRasters, /* GucBoolAssignHook assign_hook */
776  NULL /* GucShowHook show_hook */
777  );
778  }
779 
780  if ( postgis_guc_find_option("postgis.gdal_vsi_options") )
781  {
782  elog(WARNING, "'%s' is already set and cannot be changed until you reconnect", "postgis.gdal_vsi_options");
783  }
784  else
785  {
786  DefineCustomStringVariable(
787  "postgis.gdal_vsi_options", /* name */
788  "VSI config options", /* short_desc */
789  "Set the config options to be used when opening /vsi/ network files", /* long_desc */
790  &gdal_vsi_options, /* valueAddr */
791  "", /* bootValue */
792  PGC_USERSET, /* GucContext context */
793  0, /* int flags */
794  rt_pg_vsi_check_options, /* GucStringCheckHook check_hook */
795  NULL, /* GucStringAssignHook assign_hook */
796  NULL /* GucShowHook show_hook */
797  );
798  }
799 
800  /* Revert back to old context */
801  MemoryContextSwitchTo(old_context);
802 }
#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:245
static char * env_postgis_enable_outdb_rasters
Definition: rtpostgis.c:465
static void * rt_pg_alloc(size_t size)
Definition: rtpostgis.c:168
static char * gdal_vsi_options
Definition: rtpostgis.c:454
static void rtpg_assignHookGDALDataPath(const char *newpath, void *extra)
Definition: rtpostgis.c:469
static void rt_pg_error(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:206
static bool enable_outdb_rasters
Definition: rtpostgis.c:457
static void rt_pg_notice(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:220
static bool rt_pg_vsi_check_options(char **newval, void **extra, GucSource source)
Definition: rtpostgis.c:413
static char * env_postgis_gdal_enabled_drivers
Definition: rtpostgis.c:463
static char * boot_postgis_gdal_enabled_drivers
Definition: rtpostgis.c:464
static void rtpg_assignHookGDALEnabledDrivers(const char *enabled_drivers, void *extra)
Definition: rtpostgis.c:486
static void * rt_pg_realloc(void *mem, size_t size)
Definition: rtpostgis.c:180
static void rt_pg_free(void *ptr)
Definition: rtpostgis.c:196
static char * gdal_enabled_drivers
Definition: rtpostgis.c:456
static void rtpg_assignHookEnableOutDBRasters(bool enable, void *extra)
Definition: rtpostgis.c:637
static void rt_pg_debug(const char *fmt, va_list ap) __attribute__((format(printf
Definition: rtpostgis.c:234
static char * gdal_datapath
Definition: rtpostgis.c:453
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:73

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, 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(), and rtpg_trim().

Here is the call graph for this function: