PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ _PG_init()

void _PG_init ( void  )

Definition at line 643 of file rtpostgis.c.

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