Tweak editorconfig for postgis_proc_upgrade.pl and indent it properly

It looks like most lines are using 4-spaces indent, make that official
and tweak the non-conforming lines (53 lines over 580 total lines)

git-svn-id: http://svn.osgeo.org/postgis/trunk@17873 b70326c6-7e19-0410-871a-916f4a2858ee
svn-3.0
Sandro Santilli 2019-10-07 06:40:18 +00:00
parent 7e7a2ec19f
commit da1ea27f20
2 changed files with 56 additions and 52 deletions

View File

@ -21,6 +21,11 @@ indent_style = tab
[*.pl] [*.pl]
indent_style = tab indent_style = tab
# Exception: utils/postgis_proc_upgrade.pl uses 4-spaces indent
[utils/postgis_proc_upgrade.pl]
indent_style = space
indent_size = 4
# SQL files want tab indentation # SQL files want tab indentation
[*.{sql,sql.in}] [*.{sql,sql.in}]
indent_style = tab indent_style = tab

View File

@ -270,9 +270,8 @@ EOF
die "ERROR: no last updated info for aggregate '${aggsig}'\n"; die "ERROR: no last updated info for aggregate '${aggsig}'\n";
} }
my $pg12_def = $def; my $pg12_def = $def;
$pg12_def =~ s/CREATE AGGREGATE/CREATE OR REPLACE AGGREGATE/; $pg12_def =~ s/CREATE AGGREGATE/CREATE OR REPLACE AGGREGATE/;
if ($pg12_def eq "") if ($pg12_def eq "")
{ {
$pg12_def = "RAISE EXCEPTION 'Could not parse AGGREGATE'"; $pg12_def = "RAISE EXCEPTION 'Could not parse AGGREGATE'";
@ -324,22 +323,22 @@ DO LANGUAGE 'plpgsql'
\$postgis_proc_upgrade\$ \$postgis_proc_upgrade\$
BEGIN BEGIN
--IF $last_updated > version_from_num FROM _postgis_upgrade_info --IF $last_updated > version_from_num FROM _postgis_upgrade_info
--We trust presence of operator rather than version info --We trust presence of operator rather than version info
IF NOT EXISTS ( IF NOT EXISTS (
SELECT o.oprname SELECT o.oprname
FROM FROM
pg_catalog.pg_operator o, pg_catalog.pg_operator o,
pg_catalog.pg_type tl, pg_catalog.pg_type tl,
pg_catalog.pg_type tr pg_catalog.pg_type tr
WHERE WHERE
o.oprleft = tl.oid AND o.oprleft = tl.oid AND
o.oprright = tr.oid AND o.oprright = tr.oid AND
o.oprcode != 0 AND o.oprcode != 0 AND
o.oprname = '$opname' AND o.oprname = '$opname' AND
tl.typname = '$opleft' AND tl.typname = '$opleft' AND
tr.typname = '$opright' tr.typname = '$opright'
) )
THEN THEN
EXECUTE \$postgis_proc_upgrade_parsed_def\$ $def \$postgis_proc_upgrade_parsed_def\$; EXECUTE \$postgis_proc_upgrade_parsed_def\$ $def \$postgis_proc_upgrade_parsed_def\$;
END IF; END IF;
END END
@ -522,42 +521,42 @@ __END__
DO $$ DO $$
DECLARE DECLARE
old_scripts text; old_scripts text;
new_scripts text; new_scripts text;
old_maj text; old_maj text;
new_maj text; new_maj text;
BEGIN BEGIN
-- --
-- This uses postgis_lib_version() rather then -- This uses postgis_lib_version() rather then
-- MODULE_scripts_installed() as in 1.0 because -- MODULE_scripts_installed() as in 1.0 because
-- in the 1.0 => 1.1 transition that would result -- in the 1.0 => 1.1 transition that would result
-- in an impossible upgrade: -- in an impossible upgrade:
-- --
-- from 0.3.0 to 1.1.0 -- from 0.3.0 to 1.1.0
-- --
-- Next releases will still be ok as -- Next releases will still be ok as
-- postgis_lib_version() and MODULE_scripts_installed() -- postgis_lib_version() and MODULE_scripts_installed()
-- would both return actual PostGIS release number. -- would both return actual PostGIS release number.
-- --
BEGIN BEGIN
SELECT into old_scripts MODULE_lib_version(); SELECT into old_scripts MODULE_lib_version();
EXCEPTION WHEN OTHERS THEN EXCEPTION WHEN OTHERS THEN
RAISE DEBUG 'Got %', SQLERRM; RAISE DEBUG 'Got %', SQLERRM;
SELECT into old_scripts MODULE_scripts_installed(); SELECT into old_scripts MODULE_scripts_installed();
END; END;
SELECT into new_scripts 'NEWVERSION'; SELECT into new_scripts 'NEWVERSION';
SELECT into old_maj substring(old_scripts from 1 for 1); SELECT into old_maj substring(old_scripts from 1 for 1);
SELECT into new_maj substring(new_scripts from 1 for 1); SELECT into new_maj substring(new_scripts from 1 for 1);
-- 2.x to 3.x was upgrade-compatible, see -- 2.x to 3.x was upgrade-compatible, see
-- https://trac.osgeo.org/postgis/ticket/4170#comment:1 -- https://trac.osgeo.org/postgis/ticket/4170#comment:1
IF new_maj = '3' AND old_maj = '2' THEN IF new_maj = '3' AND old_maj = '2' THEN
old_maj = '3'; -- let's pretend old major = new major old_maj = '3'; -- let's pretend old major = new major
END IF; END IF;
IF old_maj != new_maj THEN 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; 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 IF;
END END
$$ $$
LANGUAGE 'plpgsql'; LANGUAGE 'plpgsql';