[postgis-tickets] [SCM] PostGIS branch master updated. 3.3.0rc2-893-g46ebbe834

git at osgeo.org git at osgeo.org
Mon May 15 11:11:45 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  46ebbe834632b320c75c9743795d7c3c0bad7c77 (commit)
      from  0c39e21d947dceac6cf304a4cd3ce04e0069281f (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 46ebbe834632b320c75c9743795d7c3c0bad7c77
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon May 15 20:06:42 2023 +0200

    Add sql script to check downgrade protections

diff --git a/utils/check_extension_downgrades.sql b/utils/check_extension_downgrades.sql
new file mode 100644
index 000000000..53d9dc878
--- /dev/null
+++ b/utils/check_extension_downgrades.sql
@@ -0,0 +1,47 @@
+DO $SQL$
+DECLARE
+	rec RECORD;
+	sql TEXT;
+	test_ext TEXT;
+	from_version TEXT;
+BEGIN
+
+	-- TODO: test all extensions ?
+	test_ext := 'postgis';
+
+	FOR rec IN
+		SELECT * FROM pg_available_extension_versions
+		WHERE name = test_ext
+		AND version NOT LIKE '%next'
+		AND version NOT IN ( 'unpackaged', 'ANY')
+		ORDER BY string_to_array(
+			regexp_replace(version, '[^0-9.]', '', 'g'), '.'
+		)::int[] DESC
+	LOOP
+		IF from_version IS NULL THEN
+			from_version := rec.version;
+			sql := format('CREATE EXTENSION %I VERSION %L', test_ext, from_version);
+			EXECUTE sql;
+		ELSE
+			sql := format('ALTER EXTENSION %I UPDATE TO %L', test_ext, rec.version);
+			BEGIN
+				EXECUTE sql;
+				-- expect error like Downgrade of postgis from version 3.4.0dev 3.3.0rc2-808-g6080076af to version 3.3.3dev is forbidden
+			EXCEPTION WHEN OTHERS THEN
+				IF SQLERRM LIKE 'Downgrade % is forbidden' THEN
+					RAISE NOTICE 'PASS: %', SQLERRM;
+				ELSE
+					RAISE EXCEPTION 'FAIL: % to % downgrade was not handled: %',
+						from_version, rec.version, SQLERRM;
+				END IF;
+			END;
+		END IF;
+	END LOOP;
+
+	sql := format('DROP EXTENSION IF EXISTS %I', test_ext);
+	EXECUTE sql;
+
+END
+
+$SQL$ LANGUAGE 'plpgsql';
+

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

Summary of changes:
 utils/check_extension_downgrades.sql | 47 ++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 utils/check_extension_downgrades.sql


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list