Skip to content

Commit cff0103

Browse files
committed
Have postgis_extensions_upgrade set extversion to ANY prior to update
This allows upgrading from any version of PostGIS even if no specific upgrade script exists on disk (which often happens as we support multiple stable branches).
1 parent 5f8782f commit cff0103

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PostGIS 3.3.0dev
55
- ...
66

77
* Enhancements *
8+
- postgis_extensions_upgrade() support for upgrades from any PostGIS
9+
version, including yet to be released ones (Sandro Santilli)
810
- #5037, add convexhull 3D (Loïc Bartoletti)
911
- #5040, add postgis_sfcgal_full_version (Loïc Bartoletti)
1012
- GH655, GiST: balance the tree splits better in recursive calls (Darafei Praliaskouski)

postgis/postgis.sql.in

+6-18
Original file line numberDiff line numberDiff line change
@@ -3034,28 +3034,16 @@ BEGIN
30343034
ELSE
30353035
RAISE DEBUG 'Skipping % (not in use)', rec.name;
30363036
END IF;
3037-
ELSIF target_version != rec.installed_version
3038-
THEN --}{
3039-
sql = 'ALTER EXTENSION ' || rec.name || ' UPDATE TO ' ||
3040-
quote_ident(target_version) || ';';
3037+
ELSE -- IF target_version != rec.installed_version THEN --}{
3038+
sql = format(
3039+
'UPDATE pg_catalog.pg_extension SET extversion = ''ANY'' WHERE extname = %1$L;'
3040+
'ALTER EXTENSION %1$I UPDATE TO %2$I',
3041+
rec.name, target_version
3042+
);
30413043
RAISE NOTICE 'Updating extension % %',
30423044
rec.name, rec.installed_version;
30433045
RAISE DEBUG '%', sql;
30443046
EXECUTE sql;
3045-
ELSIF (target_version = rec.installed_version AND rec.installed_version ILIKE '%dev') OR
3046-
(@extschema@._postgis_pgsql_version() != @extschema@._postgis_scripts_pgsql_version())
3047-
THEN --}{
3048-
-- we need to upgrade to next and back
3049-
RAISE NOTICE 'Updating extension % % (self refresh)',
3050-
rec.name, rec.installed_version;
3051-
sql = 'ALTER EXTENSION ' || rec.name || ' UPDATE TO ' ||
3052-
quote_ident(target_version || 'next') || ';';
3053-
RAISE DEBUG '%', sql;
3054-
EXECUTE sql;
3055-
sql = 'ALTER EXTENSION ' || rec.name || ' UPDATE TO ' ||
3056-
quote_ident(target_version) || ';';
3057-
RAISE DEBUG '%', sql;
3058-
EXECUTE sql;
30593047
END IF; --}
30603048

30613049
END LOOP; --}

0 commit comments

Comments
 (0)