From: Sandro Santilli Date: Tue, 17 Mar 2015 11:42:08 +0000 (+0000) Subject: Fix availability info for "summarystats" type (#3082) X-Git-Tag: 2.2.0rc1~587 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=346b19845dd0d626bb1cc10869cbef90d2a5c08e;p=postgis Fix availability info for "summarystats" type (#3082) 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 --- diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in index 99aba4630..cef398fde 100644 --- a/raster/rt_pg/rtpostgis.sql.in +++ b/raster/rt_pg/rtpostgis.sql.in @@ -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, diff --git a/utils/postgis_proc_upgrade.pl b/utils/postgis_proc_upgrade.pl index 4184c74ad..d3568c713 100755 --- a/utils/postgis_proc_upgrade.pl +++ b/utils/postgis_proc_upgrade.pl @@ -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() 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\$;