From: Sandro Santilli Date: Sat, 22 Feb 2014 16:16:51 +0000 (+0000) Subject: Extract "last updated" info of aggregates from sql X-Git-Tag: 2.2.0rc1~1248 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0922830a3372760e4439add51d83f73391754c90;p=postgis Extract "last updated" info of aggregates from sql See #2560 git-svn-id: http://svn.osgeo.org/postgis/trunk@12244 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/utils/postgis_proc_upgrade.pl b/utils/postgis_proc_upgrade.pl index 4a49862e8..3ee5dc1ec 100755 --- a/utils/postgis_proc_upgrade.pl +++ b/utils/postgis_proc_upgrade.pl @@ -196,11 +196,15 @@ while() # applied to an existing, loaded database: types and operators # and operator classes that have already been defined. # +my $comment = ''; open( INPUT, $sql_file ) || die "Couldn't open file: $sql_file\n"; while() { - next if ( /^\-\-/ ); + if ( /^\-\-/ ) { + $comment .= $_; + next; + } # # Allow through deprecations from postgis_drop.sql @@ -285,17 +289,28 @@ while() last if /\);/; } my $aggsig = "$aggname($aggtype)"; - my $ver = $version_from_num + 1; - #print "-- Checking ${aggsig} -- From: ${version_from_num} -- To: ${version_to_num}\n"; - while( $version_from_num < $version_to_num && $ver <= $version_to_num ) - { - if( $objs->{$ver}->{"aggregates"}->{$aggsig} ) - { - print "DROP AGGREGATE IF EXISTS $aggsig;\n"; - print $def; - } - $ver++; - } + + #print "-- Checking comment $comment\n"; + $comment =~ m/(?:Availability|Changed):\s([^\.])\.([^.]*)/; + my $last_updated = $1*100 + $2; + + if ( ! $last_updated ) { + my $ver = $version_from_num + 1; + while( $version_from_num < $version_to_num && $ver <= $version_to_num ) + { + if( $objs->{$ver}->{"aggregates"}->{$aggsig} ) + { + $last_updated = ${ver}; + last; + } + $ver++; + } + } + print "-- Checking ${aggsig} -- LastUpdated: ${last_updated} -- From: ${version_from_num} -- To: ${version_to_num}\n"; + if ( $last_updated > $version_from_num ) { + print "DROP AGGREGATE IF EXISTS $aggsig;\n"; + print $def; + } } # This code handles operators by creating them if we are doing a major upgrade @@ -372,6 +387,8 @@ while() $ver++; } } + + $comment = ''; } close( INPUT );