[postgis-tickets] [SCM] PostGIS branch stable-3.2 updated. 3.2.0-16-gab601a090

git at osgeo.org git at osgeo.org
Mon Jan 17 06:12:38 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, stable-3.2 has been updated
       via  ab601a09099e12f2763e0f27a86134f9d644fdb2 (commit)
       via  82e080b2a0fe7814bdcdccfde0416f663f63ad1a (commit)
       via  5082e5f40d842b1a6d966b1dbdcd99c8fbcd4155 (commit)
      from  5e567ee145cec652ad1c1276cb9a2bf7898447b6 (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 ab601a09099e12f2763e0f27a86134f9d644fdb2
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Jan 13 23:57:36 2022 +0100

    Rewrite _postgis_drop_if_needed to avoid expanding DEFAULT values
    
    This prevents the function to fail when geometry canonical output
    function is non-functional (maybe due to lack of library on system).
    
    References #5046 in 3.2 branch (3.2.1dev)
    
    Includes test ugprades in absence of old library
    Includes NEWS item

diff --git a/NEWS b/NEWS
index 75332c299..a11f163fa 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ YYYY/MM/DD
 * Bug Fixes *
   - #5033, #5035, allow upgrades in presence of views using deprecated
            functions (Sandro Santilli)
+  - #5046, Fix upgrades in absence of old library (Sandro Santilli)
 
 PostGIS 3.2.0 (Olivier Courtin Edition)
 2021/12/17
diff --git a/postgis/postgis_before_upgrade.sql b/postgis/postgis_before_upgrade.sql
index ea84c524f..437476be0 100644
--- a/postgis/postgis_before_upgrade.sql
+++ b/postgis/postgis_before_upgrade.sql
@@ -37,34 +37,29 @@ CREATE OR REPLACE FUNCTION _postgis_drop_function_if_needed(
 	function_name text,
 	function_arguments text) RETURNS void AS $$
 DECLARE
-	frec RECORD;
 	sql_drop text;
+	postgis_namespace OID;
+	matching_function REGPROCEDURE;
 BEGIN
-	FOR frec IN
-		SELECT  p.oid as oid,
-				n.nspname as schema,
-				n.oid as schema_oid,
-				p.proname as name,
-				pg_catalog.pg_get_function_arguments(p.oid) as arguments,
-				pg_catalog.pg_get_function_identity_arguments(p.oid) as identity_arguments
-			FROM pg_catalog.pg_proc p
-			LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
-			WHERE
-				n.oid = (
-					SELECT n.oid
-					FROM pg_proc p
-					JOIN pg_namespace n ON p.pronamespace = n.oid
-					WHERE proname = 'postgis_full_version'
-					) AND
-				LOWER(p.proname) = LOWER(function_name) AND
-				LOWER(pg_catalog.pg_get_function_arguments(p.oid)) ~ LOWER(function_arguments) AND
-				pg_catalog.pg_function_is_visible(p.oid)
-			ORDER BY 1, 2, 4
-	LOOP
-		sql_drop := 'DROP FUNCTION ' || quote_ident(frec.schema) || '.' || quote_ident(frec.name) || ' ( ' || frec.identity_arguments || ' ) ';
-		RAISE DEBUG 'Name (%): %', frec.oid, frec.name;
-		RAISE DEBUG 'Arguments: %', frec.arguments;
-		RAISE DEBUG 'Identity arguments: %', frec.identity_arguments;
+
+	-- Fetch install namespace for PostGIS
+	SELECT n.oid
+	FROM pg_catalog.pg_proc p
+	JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid
+	WHERE proname = 'postgis_full_version'
+	INTO postgis_namespace;
+
+	-- Find a function matching the given signature
+	SELECT oid
+	FROM pg_catalog.pg_proc p
+	WHERE pronamespace = postgis_namespace
+	AND LOWER(p.proname) = LOWER(function_name)
+	AND pg_catalog.pg_function_is_visible(p.oid)
+	AND LOWER(pg_catalog.pg_get_function_identity_arguments(p.oid)) ~ LOWER(function_arguments)
+	INTO matching_function;
+
+	IF matching_function IS NOT NULL THEN
+		sql_drop := 'DROP FUNCTION ' || matching_function;
 		RAISE DEBUG 'SQL query: %', sql_drop;
 		BEGIN
 			EXECUTE sql_drop;
@@ -72,7 +67,8 @@ BEGIN
 			WHEN OTHERS THEN
 				RAISE EXCEPTION 'Could not drop function %. You might need to drop dependant objects. Postgres error: %', function_name, SQLERRM;
 		END;
-	END LOOP;
+	END IF;
+
 END;
 $$ LANGUAGE plpgsql;
 
diff --git a/regress/hooks/hook-before-upgrade.sql b/regress/hooks/hook-before-upgrade.sql
index 5f4678446..7185b56bc 100644
--- a/regress/hooks/hook-before-upgrade.sql
+++ b/regress/hooks/hook-before-upgrade.sql
@@ -74,3 +74,8 @@ SELECT
 	ST_DWithin(g1::text, g1::text, 1) as text_dwithin,
 	ST_DWithin(g2, g2, 1) as geography_dwithin
 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'
+WHERE probin like '%postgis%';

commit 82e080b2a0fe7814bdcdccfde0416f663f63ad1a
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Jan 17 15:06:59 2022 +0100

    Various improvements in run_test.pl (matches master branch)

diff --git a/regress/run_test.pl b/regress/run_test.pl
index 5322e5e95..9810a81d7 100755
--- a/regress/run_test.pl
+++ b/regress/run_test.pl
@@ -1538,62 +1538,29 @@ sub upgrade_spatial
 {
     print "Upgrading PostGIS in '${DB}' \n" ;
 
-    my $script = `ls ${STAGED_SCRIPTS_DIR}/postgis_upgrade.sql`;
-    chomp($script);
-
-    if ( -e $script )
-    {
-        print "Upgrading core\n";
-        load_sql_file($script);
-    }
-    else
-    {
-        die "$script not found\n";
-    }
+    my $script = "${STAGED_SCRIPTS_DIR}/postgis_upgrade.sql";
+    print "Upgrading core\n";
+    die unless load_sql_file($script, 1);
 
     if ( $OPT_WITH_TOPO )
     {
-        my $script = `ls ${STAGED_SCRIPTS_DIR}/topology_upgrade.sql`;
-        chomp($script);
-        if ( -e $script )
-        {
-            print "Upgrading topology\n";
-            load_sql_file($script);
-        }
-        else
-        {
-            die "$script not found\n";
-        }
+        $script = "${STAGED_SCRIPTS_DIR}/topology_upgrade.sql";
+        print "Upgrading topology\n";
+        die unless load_sql_file($script, 1);
     }
 
     if ( $OPT_WITH_RASTER )
     {
-        my $script = `ls ${STAGED_SCRIPTS_DIR}/rtpostgis_upgrade.sql`;
-        chomp($script);
-        if ( -e $script )
-        {
-            print "Upgrading raster\n";
-            load_sql_file($script);
-        }
-        else
-        {
-            die "$script not found\n";
-        }
+        $script = "${STAGED_SCRIPTS_DIR}/rtpostgis_upgrade.sql";
+        print "Upgrading raster\n";
+        die unless load_sql_file($script, 1);
     }
 
     if ( $OPT_WITH_SFCGAL )
     {
-        my $script = `ls ${STAGED_SCRIPTS_DIR}/sfcgal_upgrade.sql`;
-        chomp($script);
-        if ( -e $script )
-        {
-            print "Upgrading sfcgal\n";
-            load_sql_file($script);
-        }
-        else
-        {
-            die "$script not found\n";
-        }
+        $script = "${STAGED_SCRIPTS_DIR}/sfcgal_upgrade.sql";
+        print "Upgrading sfcgal\n";
+        die unless load_sql_file($script, 1);
     }
 
     return 1;

commit 5082e5f40d842b1a6d966b1dbdcd99c8fbcd4155
Author: Sandro Santilli <strk at kbt.io>
Date:   Sun Jan 16 21:52:25 2022 +0100

    Include internal RUNTESTFLAGS when testing upgrades
    
    Fixes #5054 in 3.2 branch (3.2.1dev)

diff --git a/regress/runtest.mk b/regress/runtest.mk
index 5df1a3968..4d8edc8b3 100644
--- a/regress/runtest.mk
+++ b/regress/runtest.mk
@@ -19,6 +19,7 @@ check-regress:
 		$(PERL) $(topsrcdir)/regress/run_test.pl \
       --upgrade \
       $(RUNTESTFLAGS) \
+      $(RUNTESTFLAGS_INTERNAL) \
       $(TESTS); \
 	fi
 

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

Summary of changes:
 NEWS                                  |  1 +
 postgis/postgis_before_upgrade.sql    | 50 ++++++++++++++----------------
 regress/hooks/hook-before-upgrade.sql |  5 +++
 regress/run_test.pl                   | 57 ++++++++---------------------------
 regress/runtest.mk                    |  1 +
 5 files changed, 42 insertions(+), 72 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list