]> granicus.if.org Git - postgis/commitdiff
Fix availability info for "summarystats" type (#3082)
authorSandro Santilli <strk@keybit.net>
Tue, 17 Mar 2015 11:42:08 +0000 (11:42 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 17 Mar 2015 11:42:08 +0000 (11:42 +0000)
Adds support for "Missing in" label in sql comment for handling
cases in which a type was missing from a version.

git-svn-id: http://svn.osgeo.org/postgis/trunk@13349 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rtpostgis.sql.in
utils/postgis_proc_upgrade.pl

index 99aba463011f80f85c514d6e42ae29ce87d95777..cef398fdeee58dffa845d3c9071e95e4e7c69b78 100644 (file)
@@ -425,7 +425,10 @@ CREATE OR REPLACE FUNCTION st_band(rast raster, nbands text, delimiter char DEFA
 -- ST_SummaryStats and ST_ApproxSummaryStats
 -----------------------------------------------------------------------
 
+-- NOTE: existed in 2.0.0 but was removed in 2.1.0.
+-- See http://trac.osgeo.org/postgis/ticket/3082#comment:5
 -- Availability: 2.0.0
+-- Missing in: 2.1.0
 CREATE TYPE summarystats AS (
        count bigint,
        sum double precision,
index 4184c74ad7e454e6f833a65cb658a78b4c762724..d3568c71375cdb715880052d5a182cc85fa86466 100755 (executable)
@@ -107,6 +107,16 @@ sub parse_last_updated
   return 0;
 }
 
+sub parse_missing
+{
+  my $comment = shift;
+  my @missing = ();
+  if ( $comment =~ m/.*(?:Missing in):\s([^\.])\.([^.]*)/s ) {
+    push(@missing, $1*100 + $2);
+  }
+  return join(',',@missing);
+}
+
 
 #
 # Commandline argument handling
@@ -238,13 +248,19 @@ while(<INPUT>)
       print STDERR "WARNING: no last updated info for type '${newtype}'\n";
       $last_updated = find_last_updated("types", $newtype);
     }
+    my $missing = parse_missing($comment);
     print "-- Type ${newtype} -- LastUpdated: ${last_updated}\n";
       print <<"EOF";
 DO LANGUAGE 'plpgsql'
 \$postgis_proc_upgrade\$
 BEGIN
-  IF $last_updated > version_from_num FROM _postgis_upgrade_info THEN
-    EXECUTE \$postgis_proc_upgrade_parsed_def\$ $def \$postgis_proc_upgrade_parsed_def\$;
+  IF $last_updated > version_from_num
+EOF
+      print "OR version_from_num IN ( ${missing} )" if ( $missing );
+      print <<"EOF";
+     FROM _postgis_upgrade_info
+  THEN
+      EXECUTE \$postgis_proc_upgrade_parsed_def\$ $def \$postgis_proc_upgrade_parsed_def\$;
   END IF;
 END
 \$postgis_proc_upgrade\$;