[postgis-tickets] r15971 - Add option to always upgrade a dev version to default dev version even if already at the default version.

Regina Obe lr at pcorp.us
Wed Oct 11 23:50:32 PDT 2017


Author: robe
Date: 2017-10-11 23:50:32 -0700 (Wed, 11 Oct 2017)
New Revision: 15971

Modified:
   trunk/postgis/postgis.sql.in
Log:
Add option to always upgrade a dev version to default dev version even if already at the default version.
References #3898 for PostGIS 2.5.0 (trunk)

Modified: trunk/postgis/postgis.sql.in
===================================================================
--- trunk/postgis/postgis.sql.in	2017-10-11 17:11:50 UTC (rev 15970)
+++ trunk/postgis/postgis.sql.in	2017-10-12 06:50:32 UTC (rev 15971)
@@ -2793,19 +2793,31 @@
 -- Availability: 2.5.0
 CREATE OR REPLACE FUNCTION postgis_extensions_upgrade() RETURNS text
 AS $$
-DECLARE rec record;
+DECLARE rec record; sql text;
 BEGIN
- FOR rec in SELECT 'ALTER EXTENSION ' || name || ' UPDATE TO ' || quote_ident(default_version)   || ';' AS sql
-	FROM pg_available_extensions
-	WHERE installed_version > '' AND name IN('postgis', 'postgis_sfcgal', 'postgis_tiger_geocoder', 'postgis_topology')
-	AND ( default_version <> installed_version ) LOOP
+	-- if at a version different from default version or we are at a dev version,
+	-- then do an upgrade to default version
 
-    EXECUTE rec.sql;
-    RAISE NOTICE '%', rec.sql;
-END LOOP;
+	FOR rec in SELECT  name, default_version, installed_version
+		FROM pg_available_extensions
+		WHERE installed_version > '' AND name IN('postgis', 'postgis_sfcgal', 'postgis_tiger_geocoder', 'postgis_topology')
+		AND ( default_version <> installed_version  OR
+			( default_version = installed_version AND default_version ILIKE '%dev%' AND  installed_version ILIKE '%dev%'  )  ) LOOP
 
-RETURN @extschema at .postgis_full_version();
+		-- we need to upgrade to next so our installed is different from current
+		-- and then we can upgrade to default_version
+		IF rec.installed_version = rec.default_version THEN
+			sql = 'ALTER EXTENSION ' || rec.name || ' UPDATE TO ' || quote_ident(rec.default_version || 'next')   || ';';
+			EXECUTE sql;
+			RAISE NOTICE '%', sql;
+		END IF;
 
+		sql = 'ALTER EXTENSION ' || rec.name || ' UPDATE TO ' || quote_ident(rec.default_version || 'next')   || ';';
+		RAISE NOTICE '%', sql;
+	END LOOP;
+
+	RETURN @extschema at .postgis_full_version();
+
 END
 $$ language plpgsql;
 



More information about the postgis-tickets mailing list