[postgis-tickets] [SCM] PostGIS branch master updated. 3.4.0rc1-710-gd20fc9357
git at osgeo.org
git at osgeo.org
Thu Oct 26 01:47:19 PDT 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, master has been updated
via d20fc93578ca375577ecb69b25e12178202ef490 (commit)
from c4a99789f6f0bf01b5e443ef3e3c163080cee6ec (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d20fc93578ca375577ecb69b25e12178202ef490
Author: Sandro Santilli <strk at kbt.io>
Date: Thu Oct 26 10:45:56 2023 +0200
Remove duplicated AddToSearchPath implementation
Use a common one, in new libpgcommon/sql directory.
References #5525
diff --git a/.gitignore b/.gitignore
index 6d0394409..4babf2b2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@ doc/raster_gardentest_*.sql
doc/tiger_geocoder_comments.sql
doc/topology_comments.sql
extensions/Makefile
+extensions/postgis_extension_helper.sql
extensions/address_standardizer/Makefile
extensions/address_standardizer/mk-st-regexp
extensions/address_standardizer/address_standardizer--*.sql
diff --git a/extensions/Makefile.in b/extensions/Makefile.in
index 56be75191..9f725a034 100644
--- a/extensions/Makefile.in
+++ b/extensions/Makefile.in
@@ -9,6 +9,13 @@
#
#############################################################################
+srcdir = @srcdir@
+SQLPP = @SQLPP@
+PERL=@PERL@
+VPATH := $(srcdir)
+
+SCRIPTS_BUILT = postgis_extension_helper.sql
+
SUBDIRS = postgis
SUBDIRS += postgis_tiger_geocoder
ifeq (@RASTER@,raster)
@@ -31,12 +38,23 @@ all clean distclean install uninstall installcheck install-extension-upgrades-fr
$(MAKE) -C "$${DIR}" $@ || exit 1; \
done
+all: $(SCRIPTS_BUILT)
+
distclean: distclean-local
distclean-local:
rm -f Makefile
-
check check-unit check-regress:
@echo "Nothing to check"
+# Generate any .sql file from .sql.in files by running them through the SQL pre-processor
+%.sql: %.sql.in
+ $(SQLPP) -I at top_builddir@/postgis -I at top_srcdir@ $< > $@.tmp
+ grep -v '^#' $@.tmp > $@;
+ rm -f $@.tmp
+
+clean: clean-local
+
+clean-local:
+ rm -f $(SCRIPTS_BUILT)
diff --git a/extensions/postgis_extension_helper.sql b/extensions/postgis_extension_helper.sql.in
similarity index 75%
rename from extensions/postgis_extension_helper.sql
rename to extensions/postgis_extension_helper.sql.in
index a984ecb92..632385133 100644
--- a/extensions/postgis_extension_helper.sql
+++ b/extensions/postgis_extension_helper.sql.in
@@ -102,60 +102,4 @@ $$
LANGUAGE plpgsql VOLATILE;
CREATE FUNCTION postgis_extension_AddToSearchPath(a_schema_name text)
-RETURNS text
-AS
-$$
-DECLARE
- var_result text;
- var_cur_search_path text;
-BEGIN
-
- WITH settings AS (
- SELECT pg_catalog.unnest(setconfig) config
- FROM pg_catalog.pg_db_role_setting
- WHERE setdatabase OPERATOR(pg_catalog.=) (
- SELECT oid
- FROM pg_catalog.pg_database
- WHERE datname OPERATOR(pg_catalog.=) pg_catalog.current_database()
- ) and setrole OPERATOR(pg_catalog.=) 0
- )
- SELECT pg_catalog.regexp_replace(config, '^search_path=', '')
- FROM settings WHERE config like 'search_path=%'
- INTO var_cur_search_path;
-
- RAISE NOTICE 'cur_search_path from pg_db_role_setting is %', var_cur_search_path;
-
- IF var_cur_search_path IS NULL THEN
- SELECT setting
- INTO var_cur_search_path
- FROM pg_catalog.pg_file_settings
- WHERE name OPERATOR(pg_catalog.=) 'search_path' AND applied;
-
- RAISE NOTICE 'cur_search_path from pg_file_settings is %', var_cur_search_path;
- END IF;
-
- IF var_cur_search_path IS NULL THEN
- SELECT boot_val
- INTO var_cur_search_path
- FROM pg_catalog.pg_settings
- WHERE name OPERATOR(pg_catalog.=) 'search_path';
-
- RAISE NOTICE 'cur_search_path from pg_settings is %', var_cur_search_path;
- END IF;
-
- IF var_cur_search_path LIKE '%' OPERATOR(pg_catalog.||) pg_catalog.quote_ident(a_schema_name) OPERATOR(pg_catalog.||) '%' THEN
- var_result := a_schema_name OPERATOR(pg_catalog.||) ' already in database search_path';
- ELSE
- var_cur_search_path := var_cur_search_path OPERATOR(pg_catalog.||) ', '
- OPERATOR(pg_catalog.||) pg_catalog.quote_ident(a_schema_name);
- EXECUTE 'ALTER DATABASE ' OPERATOR(pg_catalog.||) pg_catalog.quote_ident(pg_catalog.current_database())
- OPERATOR(pg_catalog.||) ' SET search_path = ' OPERATOR(pg_catalog.||) var_cur_search_path;
- var_result := a_schema_name OPERATOR(pg_catalog.||) ' has been added to end of database search_path ';
- END IF;
-
- EXECUTE 'SET search_path = ' OPERATOR(pg_catalog.||) var_cur_search_path;
-
- RETURN var_result;
-END
-$$
-LANGUAGE 'plpgsql' VOLATILE STRICT;
+#include "libpgcommon/sql/AddToSearchPath.sql.inc"
diff --git a/topology/sql/manage/ManageHelper.sql.in b/libpgcommon/sql/AddToSearchPath.sql.inc
similarity index 72%
copy from topology/sql/manage/ManageHelper.sql.in
copy to libpgcommon/sql/AddToSearchPath.sql.inc
index eb9da2d02..2499bfa91 100644
--- a/topology/sql/manage/ManageHelper.sql.in
+++ b/libpgcommon/sql/AddToSearchPath.sql.inc
@@ -1,29 +1,18 @@
--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
--- PostGIS - Spatial Types for PostgreSQL
--- http://www.postgis.net
---
--- Copyright (C) 2011 Regina Obe <lr at pcorp.us>
---
--- This is free software; you can redistribute and/or modify it under
--- the terms of the GNU General Public Licence. See the COPYING file.
---
--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+/*
---{
--- AddToSearchPath(schema_name)
---
--- Adds the specified schema to the database search path
--- if it is not already in the database search path
--- This is a helper function for upgrade/install
--- We may want to move this function as a generic helper
-CREATE OR REPLACE FUNCTION topology.AddToSearchPath(a_schema_name varchar)
+ Common body for a function to add a schema to the search path
+ Use as follows:
+
+ CREATE OR REPLACE FUNCTION someName(someARg text)
+ #include "libpgcommon/sql/AddToSearchPath.sql.inc"
+*/
RETURNS text
AS
-$$
+$BODY$
DECLARE
var_result text;
var_cur_search_path text;
+ a_schema_name text := $1;
BEGIN
WITH settings AS (
SELECT pg_catalog.unnest(setconfig) config
@@ -72,7 +61,6 @@ BEGIN
RETURN var_result;
END
-$$
+$BODY$
LANGUAGE 'plpgsql' VOLATILE STRICT;
---} AddToSearchPath
diff --git a/topology/Makefile.in b/topology/Makefile.in
index 23080ba31..7fb8578af 100644
--- a/topology/Makefile.in
+++ b/topology/Makefile.in
@@ -109,7 +109,7 @@ endif
# Generate any .sql file from .sql.in files by running them through the SQL pre-processor
%.sql: %.sql.in
- $(SQLPP) -I at top_builddir@/postgis $< > $@.tmp
+ $(SQLPP) -I at top_builddir@/postgis -I at top_srcdir@ $< > $@.tmp
grep -v '^#' $@.tmp | \
$(PERL) -lpe "s'MODULE_PATHNAME'\$(MODULEPATH)'g" > $@
rm -f $@.tmp
diff --git a/topology/sql/manage/ManageHelper.sql.in b/topology/sql/manage/ManageHelper.sql.in
index eb9da2d02..4c912317b 100644
--- a/topology/sql/manage/ManageHelper.sql.in
+++ b/topology/sql/manage/ManageHelper.sql.in
@@ -18,61 +18,5 @@
-- This is a helper function for upgrade/install
-- We may want to move this function as a generic helper
CREATE OR REPLACE FUNCTION topology.AddToSearchPath(a_schema_name varchar)
-RETURNS text
-AS
-$$
-DECLARE
- var_result text;
- var_cur_search_path text;
-BEGIN
- WITH settings AS (
- SELECT pg_catalog.unnest(setconfig) config
- FROM pg_catalog.pg_db_role_setting
- WHERE setdatabase OPERATOR(pg_catalog.=) (
- SELECT oid
- FROM pg_catalog.pg_database
- WHERE datname OPERATOR(pg_catalog.=) pg_catalog.current_database()
- ) and setrole OPERATOR(pg_catalog.=) 0
- )
- SELECT pg_catalog.regexp_replace(config, '^search_path=', '')
- FROM settings WHERE config like 'search_path=%'
- INTO var_cur_search_path;
-
- RAISE NOTICE 'cur_search_path from pg_db_role_setting is %', var_cur_search_path;
-
- IF var_cur_search_path IS NULL THEN
- SELECT setting
- INTO var_cur_search_path
- FROM pg_catalog.pg_file_settings
- WHERE name OPERATOR(pg_catalog.=) 'search_path' AND applied;
-
- RAISE NOTICE 'cur_search_path from pg_file_settings is %', var_cur_search_path;
- END IF;
-
- IF var_cur_search_path IS NULL THEN
- SELECT boot_val
- INTO var_cur_search_path
- FROM pg_catalog.pg_settings
- WHERE name OPERATOR(pg_catalog.=) 'search_path';
-
- RAISE NOTICE 'cur_search_path from pg_settings is %', var_cur_search_path;
- END IF;
-
- IF var_cur_search_path LIKE '%' OPERATOR(pg_catalog.||) pg_catalog.quote_ident(a_schema_name) OPERATOR(pg_catalog.||) '%' THEN
- var_result := a_schema_name OPERATOR(pg_catalog.||) ' already in database search_path';
- ELSE
- var_cur_search_path := var_cur_search_path OPERATOR(pg_catalog.||) ', '
- OPERATOR(pg_catalog.||) pg_catalog.quote_ident(a_schema_name);
- EXECUTE 'ALTER DATABASE ' OPERATOR(pg_catalog.||) pg_catalog.quote_ident(pg_catalog.current_database())
- OPERATOR(pg_catalog.||) ' SET search_path = ' OPERATOR(pg_catalog.||) var_cur_search_path;
- var_result := a_schema_name OPERATOR(pg_catalog.||) ' has been added to end of database search_path ';
- END IF;
-
- EXECUTE 'SET search_path = ' OPERATOR(pg_catalog.||) var_cur_search_path;
-
- RETURN var_result;
-END
-$$
-LANGUAGE 'plpgsql' VOLATILE STRICT;
-
+#include "libpgcommon/sql/AddToSearchPath.sql.inc"
--} AddToSearchPath
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 1 +
extensions/Makefile.in | 20 +++++++-
..._helper.sql => postgis_extension_helper.sql.in} | 58 +---------------------
.../sql/AddToSearchPath.sql.inc | 32 ++++--------
topology/Makefile.in | 2 +-
topology/sql/manage/ManageHelper.sql.in | 58 +---------------------
6 files changed, 33 insertions(+), 138 deletions(-)
rename extensions/{postgis_extension_helper.sql => postgis_extension_helper.sql.in} (75%)
copy topology/sql/manage/ManageHelper.sql.in => libpgcommon/sql/AddToSearchPath.sql.inc (72%)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list