[postgis-tickets] [SCM] PostGIS branch fix-upgrades-in-absence-of-old-library updated. 3.2.0-265-g85e6c3b57

git at osgeo.org git at osgeo.org
Mon Jan 17 05:28:36 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, fix-upgrades-in-absence-of-old-library has been updated
  discards  23d2064b8c3b61c78bda4a0d69195b6154b305bb (commit)
       via  85e6c3b57c7e9e264b71964e4e4fd2aab014aae3 (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (23d2064b8c3b61c78bda4a0d69195b6154b305bb)
            \
             N -- N -- N (85e6c3b57c7e9e264b71964e4e4fd2aab014aae3)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

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 85e6c3b57c7e9e264b71964e4e4fd2aab014aae3
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Jan 17 14:27:59 2022 +0100

    Rewrite _postgis_drop_if_needed to avoid expanding DEFAULT values
    
    Should fix 5046

diff --git a/postgis/postgis_before_upgrade.sql b/postgis/postgis_before_upgrade.sql
index ea84c524f..fee0bbc44 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 REGCLASS;
 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 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;
 

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

Summary of changes:
 postgis/postgis_after_upgrade.sql  | 140 -------------------------------------
 postgis/postgis_before_upgrade.sql | 135 +++++++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+), 140 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list