[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0rc1-413-g87a815c

git at osgeo.org git at osgeo.org
Fri Aug 20 23:00:22 PDT 2021


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  87a815cfb038e24e760cbdba1d9fb64d5debd943 (commit)
      from  86a8a59791431b279e4d6511c96af0d3e45332d5 (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 87a815cfb038e24e760cbdba1d9fb64d5debd943
Author: Regina Obe <lr at pcorp.us>
Date:   Sat Aug 21 01:53:53 2021 -0400

    Upgrade path patchfor address_standardizer_data_us
    and minor fix to patch Closes #4974
    
    PostGIS upgrade change to not use temp tables Closes #4975
    Closes https://github.com/postgis/postgis/pull/623
    
    Credits: Jan Katins (Aiven)

diff --git a/NEWS b/NEWS
index ba7bec1..e9eafe3 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,9 @@ PostGIS 3.2.0
   - ST_Srid(topogeometry) override, to speedup lookups (Sandro Santilli)
   - #2175, Avoid creating additional nodes when adding same closed
            line to topology (Sandro Santilli)
+  - #4974, Upgrade path for address_standardizer_data_us
+    (Jan Katins of Aiven, Regina Obe)
+  - #4975, PostGIS upgrade change to not use temp tables (Jan Katins of Aiven)
 
  * New features*
   - #4923, topology.ValidateTopologyRelation (Sandro Santilli)
diff --git a/extensions/address_standardizer/Makefile.in b/extensions/address_standardizer/Makefile.in
index 3c64b47..820b7e8 100644
--- a/extensions/address_standardizer/Makefile.in
+++ b/extensions/address_standardizer/Makefile.in
@@ -47,7 +47,7 @@ DATA_built = \
 
 all:  sql/address_standardizer.sql sql/address_standardizer--1.0--$(EXTVERSION).sql sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--ANY--$(EXTVERSION).sql \
  sql/$(EXTENSION)_data_us.sql sql/address_standardizer-- at POSTGIS_LIB_VERSION@.sql sql/$(EXTENSION)_data_us-- at POSTGIS_LIB_VERSION@.sql  sql/$(EXTENSION)_data_us--$(EXTVERSION)--$(EXTVERSION)next.sql \
-sql/$(EXTENSION)_data_us--$(EXTVERSION)next--$(EXTVERSION).sql \
+sql/$(EXTENSION)_data_us--$(EXTVERSION)next--$(EXTVERSION).sql sql/$(EXTENSION)_data_us--ANY--$(EXTVERSION).sql \
 sql/test-init-extensions.sql sql/test-parseaddress.sql sql/test-standardize_address_1.sql sql/test-standardize_address_2.sql
 
 EXTRA_CLEAN = sql/
@@ -118,8 +118,25 @@ sql/$(EXTENSION)_data_us--$(EXTVERSION)next--$(EXTVERSION).sql: sql/$(EXTENSION)
 sql/$(EXTENSION)--ANY--$(EXTVERSION).sql: $(EXTENSION_UPGRADE_SCRIPTS)
 	cat $(EXTENSION_UPGRADE_SCRIPTS) > $@
 
+sql/$(EXTENSION)_data_us--ANY--$(EXTVERSION).sql: sql/$(EXTENSION)_data_us--$(EXTVERSION).sql
+	mkdir -p sql
+	cat $^ > $@
+
 include ../upgrade-paths-rules.mk
 
+install: install-upgrade-paths-data-us
+install: install-upgrade-paths-data-us
+# address_standardizer is already defined, we have to additionally create
+# the upgrade path scripts for address_standardizer_data_us
+install-upgrade-paths-data-us:
+	tpl='$(EXTENSION)_data_us--ANY--$(EXTVERSION).sql'; \
+	$(INSTALL_DATA) sql/$${tpl} "$(EXTDIR)/$${tpl}"; \
+	ln -fs "$${tpl}" $(EXTDIR)/$(EXTENSION)_data_us--$(EXTVERSION)--$(EXTVERSION)next.sql; \
+	ln -fs "$${tpl}" $(EXTDIR)/$(EXTENSION)_data_us--$(EXTVERSION)next--$(EXTVERSION).sql; \
+	for OLD_VERSION in $(UPGRADEABLE_VERSIONS); do \
+		ln -fs "$${tpl}" $(EXTDIR)/$(EXTENSION)_data_us--$$OLD_VERSION--$(EXTVERSION).sql; \
+	done
+
 mk-st-regexp: mk-st-regexp.pl
 	$(PERL) -c mk-st-regexp.pl
 	rm -f mk-st-regexp
diff --git a/utils/postgis_proc_upgrade.pl b/utils/postgis_proc_upgrade.pl
index 859641b..23cd812 100755
--- a/utils/postgis_proc_upgrade.pl
+++ b/utils/postgis_proc_upgrade.pl
@@ -203,7 +203,7 @@ BEGIN
 EOF
         print "OR version_from_num IN ( ${missing} )" if ($missing);
         print <<"EOF";
-     FROM _postgis_upgrade_info
+     FROM _postgis_upgrade_info()
   THEN
       EXECUTE \$postgis_proc_upgrade_parsed_def\$ $def \$postgis_proc_upgrade_parsed_def\$;
   END IF;
@@ -286,7 +286,7 @@ BEGIN
     EXECUTE \$postgis_proc_upgrade_parsed_def\$ $pg12_def \$postgis_proc_upgrade_parsed_def\$;
   ELSIF $last_updated > version_from_num OR (
       $last_updated = version_from_num AND version_from_isdev
-    ) FROM _postgis_upgrade_info
+    ) FROM _postgis_upgrade_info()
   THEN
     EXECUTE 'DROP AGGREGATE IF EXISTS $aggsig';
     EXECUTE \$postgis_proc_upgrade_parsed_def\$ $def \$postgis_proc_upgrade_parsed_def\$;
@@ -322,7 +322,7 @@ EOF
 DO LANGUAGE 'plpgsql'
 \$postgis_proc_upgrade\$
 BEGIN
-  --IF $last_updated > version_from_num FROM _postgis_upgrade_info
+  --IF $last_updated > version_from_num FROM _postgis_upgrade_info()
     --We trust presence of operator rather than version info
     IF NOT EXISTS (
         SELECT o.oprname
@@ -405,7 +405,7 @@ EOF
 DO LANGUAGE 'plpgsql'
 \$postgis_proc_upgrade\$
 BEGIN
-  IF $last_updated > version_from_num FROM _postgis_upgrade_info THEN
+  IF $last_updated > version_from_num FROM _postgis_upgrade_info() THEN
     EXECUTE \$postgis_proc_upgrade_parsed_def\$ $def \$postgis_proc_upgrade_parsed_def\$;
   END IF;
 END
@@ -477,7 +477,7 @@ DO LANGUAGE 'plpgsql'
 \$postgis_proc_upgrade\$
 BEGIN
 
-  IF $last_updated > version_from_num FROM _postgis_upgrade_info
+  IF $last_updated > version_from_num FROM _postgis_upgrade_info()
   THEN
     EXECUTE \$postgis_proc_upgrade_parsed_def\$
     $def    \$postgis_proc_upgrade_parsed_def\$;
@@ -490,7 +490,7 @@ EOF
             print <<"EOF";
   $ELSE
     -- Last Updated: ${last_updated}
-    IF $last_updated > version_from_num FROM _postgis_upgrade_info THEN
+    IF $last_updated > version_from_num FROM _postgis_upgrade_info() THEN
       EXECUTE \$postgis_proc_upgrade_parsed_def\$
         ALTER OPERATOR FAMILY ${opclassname} USING ${opcidx}
           ADD $def;
@@ -511,7 +511,7 @@ EOF
 
 close(INPUT);
 
-print "DROP TABLE _postgis_upgrade_info;\n";
+print "DROP FUNCTION _postgis_upgrade_info();\n";
 
 #print "COMMIT;\n";
 
@@ -525,6 +525,8 @@ DECLARE
     new_scripts text;
     old_maj text;
     new_maj text;
+    postgis_upgrade_info RECORD;
+    postgis_upgrade_info_func_code TEXT;
 BEGIN
     --
     -- This uses postgis_lib_version() rather then
@@ -557,24 +559,50 @@ BEGIN
     IF old_maj != new_maj THEN
         RAISE EXCEPTION 'Upgrade of MODULE from version % to version % requires a dump/reload. See PostGIS manual for instructions', old_scripts, new_scripts;
     END IF;
+
+    WITH versions AS (
+      SELECT 'NEWVERSION'::text as upgraded,
+      MODULE_scripts_installed() as installed
+    ) SELECT
+      upgraded as scripts_upgraded,
+      installed as scripts_installed,
+      substring(upgraded from '([0-9]+)\.')::int * 100 +
+      substring(upgraded from '[0-9]+\.([0-9]+)(\.|$)')::int
+        as version_to_num,
+      substring(installed from '([0-9]+)\.')::int * 100 +
+      substring(installed from '[0-9]+\.([0-9]+)(\.|$)')::int
+        as version_from_num,
+      installed ~ 'dev|alpha|beta'
+        as version_from_isdev
+      FROM versions INTO postgis_upgrade_info
+    ;
+
+    postgis_upgrade_info_func_code := format($func_code$
+        CREATE FUNCTION _postgis_upgrade_info(OUT scripts_upgraded TEXT,
+                                              OUT scripts_installed TEXT,
+                                              OUT version_to_num INT,
+                                              OUT version_from_num INT,
+                                              OUT version_from_isdev BOOLEAN)
+        AS
+        $postgis_upgrade_info$
+        BEGIN
+            scripts_upgraded := %L :: TEXT;
+            scripts_installed := %L :: TEXT;
+            version_to_num := %L :: INT;
+            version_from_num := %L :: INT;
+            version_from_isdev := %L :: BOOLEAN;
+            RETURN;
+        END
+        $postgis_upgrade_info$ LANGUAGE 'plpgsql' IMMUTABLE;
+        $func_code$,
+        postgis_upgrade_info.scripts_upgraded,
+        postgis_upgrade_info.scripts_installed,
+        postgis_upgrade_info.version_to_num,
+        postgis_upgrade_info.version_from_num,
+        postgis_upgrade_info.version_from_isdev);
+    RAISE DEBUG 'Creating function %', postgis_upgrade_info_func_code;
+    EXECUTE postgis_upgrade_info_func_code;
 END
 $$
 LANGUAGE 'plpgsql';
 
-CREATE TEMPORARY TABLE _postgis_upgrade_info AS WITH versions AS (
-  SELECT 'NEWVERSION'::text as upgraded,
-  MODULE_scripts_installed() as installed
-) SELECT
-  upgraded as scripts_upgraded,
-  installed as scripts_installed,
-  substring(upgraded from '([0-9]*)\.')::int * 100 +
-  substring(upgraded from '[0-9]*\.([0-9]*)\.')::int
-    as version_to_num,
-  substring(installed from '([0-9]*)\.')::int * 100 +
-  substring(installed from '[0-9]*\.([0-9]*)\.')::int
-    as version_from_num,
-  installed ~ 'dev|alpha|beta'
-    as version_from_isdev
-  FROM versions
-;
-

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                        |  3 ++
 extensions/address_standardizer/Makefile.in | 19 +++++++-
 utils/postgis_proc_upgrade.pl               | 76 ++++++++++++++++++++---------
 3 files changed, 73 insertions(+), 25 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list