[postgis-tickets] r17873 - Tweak editorconfig for postgis_proc_upgrade.pl and indent it properly

Sandro Santilli strk at kbt.io
Sun Oct 6 11:40:18 PDT 2019


Author: strk
Date: 2019-10-06 23:40:18 -0700 (Sun, 06 Oct 2019)
New Revision: 17873

Modified:
   trunk/.editorconfig
   trunk/utils/postgis_proc_upgrade.pl
Log:
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)

Modified: trunk/.editorconfig
===================================================================
--- trunk/.editorconfig	2019-10-07 06:18:41 UTC (rev 17872)
+++ trunk/.editorconfig	2019-10-07 06:40:18 UTC (rev 17873)
@@ -21,6 +21,11 @@
 [*.pl]
 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,sql.in}]
 indent_style = tab

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



More information about the postgis-tickets mailing list