[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-480-g0ffe2870e

git at osgeo.org git at osgeo.org
Thu Feb 3 15:43:54 PST 2022


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  0ffe2870eade1a26a1573eb11e7540eacc207783 (commit)
       via  d59be353157fd3944779c7291cf1fb2d5334453e (commit)
       via  8cc96d62a72f7356a9dbf90e412c0a5705cc1c9c (commit)
      from  98f05d524ca0b2a59d208ad1e643479ad8c48b37 (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 0ffe2870eade1a26a1573eb11e7540eacc207783
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Feb 3 19:46:44 2022 +0100

    Add script based upgrade testing in check_all_upgrades

diff --git a/utils/check_all_upgrades.sh b/utils/check_all_upgrades.sh
index 20e96f8ee..ace5ad351 100755
--- a/utils/check_all_upgrades.sh
+++ b/utils/check_all_upgrades.sh
@@ -1,7 +1,6 @@
 #!/bin/sh
 
 EXIT_ON_FIRST_FAILURE=0
-BUILDDIR=$PWD
 EXTDIR=`pg_config --sharedir`/extension/
 CTBDIR=`pg_config --sharedir`/contrib/
 TMPDIR=/tmp/check_all_upgrades-$$-tmp
@@ -9,6 +8,12 @@ PGVER=`pg_config --version | awk '{print $2}'`
 PGVER_MAJOR=$(echo "${PGVER}" | sed 's/\.[^\.]*//')
 echo "INFO: PostgreSQL version: ${PGVER} [${PGVER_MAJOR}]"
 
+BUILDDIR=$PWD # TODO: allow override ?
+
+cd $(dirname $0)/..
+SRCDIR=$PWD # TODO: allow override ?
+cd -
+
 
 if test "$1" = "-s"; then
   EXIT_ON_FIRST_FAILURE=1
@@ -208,6 +213,30 @@ for EXT in ${INSTALLED_EXTENSIONS}; do
     }
   done
 
+  # Check unpackaged->unpackaged upgrades
+  CURRENTVERSION=`grep '^POSTGIS_' ${SRCDIR}/Version.config | cut -d= -f2 | paste -sd '.'`
+  if test ${to_version} = "${CURRENTVERSION}"; then
+    for majmin in `'ls' -d ${CTBDIR}/postgis-* | sed 's/.*postgis-//'`
+    do #{
+      UPGRADE_PATH="unpackaged${majmin}--:auto"
+      test_label="${EXT} script-based upgrade ${UPGRADE_PATH}"
+      if expr $to_version_param : ':auto' >/dev/null; then
+        test_label="${test_label} ($to_version)"
+      fi
+      compatible_upgrade "${test_label}" ${majmin} ${to_version} || continue
+      echo "Testing ${test_label}"
+      RUNTESTFLAGS="-v --upgrade-path=${UPGRADE_PATH} ${USERTESTFLAGS}" \
+      make -C ${REGDIR} check && {
+        echo "PASS: ${EXT} script-based upgrade $UPGRADE_PATH"
+      } || {
+        echo "FAIL: ${EXT} script-based upgrade $UPGRADE_PATH"
+        failed
+      }
+    done #}
+  else #}{
+    echo "SKIP: ${EXT} script-based upgrades (${to_version_param} [${to_version}] does not match built version ${CURRENTVERSION})"
+  fi #}
+
 done
 
 exit $failures

commit d59be353157fd3944779c7291cf1fb2d5334453e
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Feb 3 14:40:59 2022 +0100

    Add test for views using ST_ClusterKMeans on upgrade
    
    References #5080

diff --git a/regress/hooks/hook-after-upgrade.sql b/regress/hooks/hook-after-upgrade.sql
index 0ca56e675..7f95eb762 100644
--- a/regress/hooks/hook-after-upgrade.sql
+++ b/regress/hooks/hook-after-upgrade.sql
@@ -5,6 +5,7 @@ DROP VIEW IF EXISTS upgrade_view_test_union;
 DROP VIEW IF EXISTS upgrade_view_test_force_dims;
 DROP VIEW IF EXISTS upgrade_view_test_askml;
 DROP VIEW IF EXISTS upgrade_view_test_dwithin;
+DROP VIEW IF EXISTS upgrade_view_test_clusterkmeans;
 DROP TABLE upgrade_test;
 
 -- Drop functions deprecated on upgrade
@@ -21,3 +22,4 @@ DROP FUNCTION IF EXISTS st_askml_deprecated_by_postgis_200(geometry,integer);
 DROP FUNCTION IF EXISTS st_askml_deprecated_by_postgis_200(geography,integer);
 DROP FUNCTION IF EXISTS st_dwithin_deprecated_by_postgis_300(geography,geography,float8);
 DROP FUNCTION IF EXISTS st_dwithin_deprecated_by_postgis_300(text,text,float8);
+DROP FUNCTION IF EXISTS st_clusterkmeans_deprecated_by_postgis_302(geometry,integer);
diff --git a/regress/hooks/hook-before-upgrade.sql b/regress/hooks/hook-before-upgrade.sql
index 7185b56bc..f15b71111 100644
--- a/regress/hooks/hook-before-upgrade.sql
+++ b/regress/hooks/hook-before-upgrade.sql
@@ -75,6 +75,13 @@ SELECT
 	ST_DWithin(g2, g2, 1) as geography_dwithin
 FROM upgrade_test;
 
+-- Add view using ST_ClusterKMeans windowing function
+-- NOTE: 3.2.0 changed it to add max_radius parameter
+CREATE VIEW upgrade_view_test_clusterkmeans AS
+SELECT
+	ST_ClusterKMeans(g1, 1) OVER ()
+FROM upgrade_test;
+
 -- Break probin of all postgis functions, as we expect
 -- the upgrade procedure to replace them all
 UPDATE pg_proc SET probin = probin || '-uninstalled'

commit 8cc96d62a72f7356a9dbf90e412c0a5705cc1c9c
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Feb 3 15:52:18 2022 +0100

    Handle exception upon attempts to rewrite deprecated functions
    
    Closes #5080
    
    Also rewrite deprecated as wrappers only after trying to drop them

diff --git a/utils/postgis_proc_upgrade.pl b/utils/postgis_proc_upgrade.pl
index 62c28022e..a7fd59061 100755
--- a/utils/postgis_proc_upgrade.pl
+++ b/utils/postgis_proc_upgrade.pl
@@ -586,6 +586,8 @@ DO LANGUAGE 'plpgsql'
 \$postgis_proc_upgrade\$
 DECLARE
     deprecated_functions regprocedure[];
+    new_name TEXT;
+    rewrote_as_wrapper BOOLEAN;
     rec RECORD;
     extrec RECORD;
     procrec RECORD;
@@ -600,6 +602,8 @@ BEGIN
     WHERE proname = ANY ('${deprecated_names}'::name[])
     INTO deprecated_functions;
 
+    RAISE DEBUG 'Handling deprecated functions: %', deprecated_functions;
+
 --    -- Rewrite views using deprecated functions
 --    -- to improve the odds of being able to drop them
 --
@@ -641,42 +645,13 @@ BEGIN
     FOR rec IN SELECT unnest(deprecated_functions) as proc
     LOOP --{
 
-        -- Rewrite the function as an SQL WRAPPER
-
-        SELECT pg_get_functiondef(oid) def, pronargs
-        FROM pg_proc WHERE oid = rec.proc
-        INTO procrec;
-
-        -- Force LANGUAGE to be SQL
-        sql := regexp_replace(procrec.def, 'LANGUAGE [^ \n]*', 'LANGUAGE sql');
-
-        --RAISE DEBUG 'SQL (LANGUAGE): %', sql;
-
-        -- Change body to be a wrapper
-        sql := regexp_replace(
-            sql,
-			-- Find a stricted match here ?
-            'AS .*',
-            format(
-                -- TODO: have the function raise a warning too ?
-                'AS \$\$ SELECT %s(%s) \$\$',
-                regexp_replace(
-                    rec.proc::text,
-                    '_deprecated_by_postgis[^(]*\\(.*',
-                    ''
-                ),
-                (
-                    SELECT array_to_string(
-                        array_agg('\$' || x),
-                        ','
-                    )
-                    FROM generate_series(1, procrec.pronargs) x
-                )
-            )
-        );
+        RAISE DEBUG 'Handling deprecated function %', rec.proc;
 
-        RAISE DEBUG 'SQL: %', sql;
-        EXECUTE sql;
+        new_name := regexp_replace(
+            rec.proc::text,
+            '_deprecated_by_postgis[^(]*\\(.*',
+            ''
+        );
 
         sql := format('DROP FUNCTION %s', rec.proc);
         --RAISE DEBUG 'SQL: %', sql;
@@ -690,13 +665,63 @@ BEGIN
                 hint = format(
                     'Replace the view changing all occurrences of %s in its definition with %s',
                     rec.proc,
-                    regexp_replace(rec.proc::text, '_deprecated_by_postgis[^(]*', '')
+                    new_name
                 );
             END IF;
             hint = hint || ' and upgrade again';
-            RAISE WARNING 'Deprecated function % left behind as a wrapper: %', rec.proc, SQLERRM
+
+            RAISE WARNING 'Deprecated function % left behind: %',
+                rec.proc, SQLERRM
             USING DETAIL = detail, HINT = hint;
 
+            --
+            -- Try to rewrite the function as an SQL WRAPPER
+            -- {
+            SELECT pg_get_functiondef(oid) def, pronargs
+            FROM pg_proc WHERE oid = rec.proc
+            INTO procrec;
+            --
+            -- TODO: don't even try if it's an aggregate or windowing
+            --       function (procrec.prokind)
+            -- TODO: don't even try if it's a scripting language function
+            --       function (procrec.prokind)
+            --
+            -- Force LANGUAGE to be SQL
+            sql := regexp_replace(procrec.def, 'LANGUAGE [^ \n]*', 'LANGUAGE sql');
+            --RAISE DEBUG 'SQL (LANGUAGE): %', sql;
+            -- Change body to be a wrapper
+            sql := regexp_replace(
+                sql,
+                -- Find a stricted match here ?
+                'AS .*',
+                format(
+                    -- TODO: have the function raise a warning too ?
+                    'AS \$\$ SELECT %s(%s) \$\$',
+                    new_name,
+                    (
+                        SELECT array_to_string(
+                            array_agg('\$' || x),
+                            ','
+                        )
+                        FROM generate_series(1, procrec.pronargs) x
+                    )
+                )
+            );
+            RAISE DEBUG 'SQL: %', sql;
+            rewrote_as_wrapper := false;
+            BEGIN
+                EXECUTE sql;
+                rewrote_as_wrapper := true;
+            EXCEPTION
+            WHEN OTHERS THEN
+                RAISE WARNING
+                    'Deprecated function % could not be rewritten as a wrapper: % (%)',
+                    rec.proc, SQLERRM, SQLSTATE;
+            END;
+            --
+            --}
+
+
             -- Drop the function from any extension it is part of
             -- so dump/reloads still work
             FOR extrec IN

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

Summary of changes:
 regress/hooks/hook-after-upgrade.sql  |  2 +
 regress/hooks/hook-before-upgrade.sql |  7 +++
 utils/check_all_upgrades.sh           | 31 ++++++++++-
 utils/postgis_proc_upgrade.pl         | 99 ++++++++++++++++++++++-------------
 4 files changed, 101 insertions(+), 38 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list