From: Sandro Santilli Date: Wed, 5 Sep 2018 16:24:34 +0000 (+0000) Subject: Consider 3.x upgrade-compatible with 2.x X-Git-Tag: 3.0.0alpha1~469 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b66a983c2f73cec9905261c6e030d46f0b56859a;p=postgis Consider 3.x upgrade-compatible with 2.x Closes #4170 As I was at it, I also replaced the use of a temporary function with a DO block. git-svn-id: http://svn.osgeo.org/postgis/trunk@16713 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/utils/postgis_proc_upgrade.pl b/utils/postgis_proc_upgrade.pl index a83af4282..148ec535f 100755 --- a/utils/postgis_proc_upgrade.pl +++ b/utils/postgis_proc_upgrade.pl @@ -467,9 +467,7 @@ print "DROP TABLE _postgis_upgrade_info;\n"; __END__ -CREATE OR REPLACE FUNCTION postgis_major_version_check() -RETURNS text -AS ' +DO $$ DECLARE old_scripts text; new_scripts text; @@ -491,26 +489,26 @@ BEGIN BEGIN SELECT into old_scripts MODULE_lib_version(); EXCEPTION WHEN OTHERS THEN - RAISE DEBUG ''Got %'', SQLERRM; + RAISE DEBUG 'Got %', SQLERRM; SELECT into old_scripts MODULE_scripts_installed(); END; - SELECT into new_scripts ''NEWVERSION''; + SELECT into new_scripts 'NEWVERSION'; SELECT into old_maj substring(old_scripts from 1 for 2); SELECT into new_maj substring(new_scripts from 1 for 2); + -- 2.x to 3.x was upgrade-compatible, see + -- https://trac.osgeo.org/postgis/ticket/4170#comment:1 + IF new_maj = '3' AND old_maj = '2' THEN + old_maj = '3'; -- let's pretend old major = new major + END IF; + IF old_maj != new_maj THEN - RAISE EXCEPTION ''Upgrade of MODULE from version % to version % requires a dump/reload. See PostGIS manual for instructions'', old_scripts, new_scripts; - ELSE - RETURN ''Scripts versions checked for upgrade: ok''; + RAISE EXCEPTION 'Upgrade of MODULE from version % to version % requires a dump/reload. See PostGIS manual for instructions', old_scripts, new_scripts; END IF; END -' +$$ LANGUAGE 'plpgsql'; -SELECT postgis_major_version_check(); - -DROP FUNCTION postgis_major_version_check(); - CREATE TEMPORARY TABLE _postgis_upgrade_info AS WITH versions AS ( SELECT 'NEWVERSION'::text as upgraded, MODULE_scripts_installed() as installed