]> granicus.if.org Git - postgis/commitdiff
Fixed more null cases.
authorPierre Racine <Pierre.Racine@sbf.ulaval.ca>
Wed, 21 Aug 2013 21:45:18 +0000 (21:45 +0000)
committerPierre Racine <Pierre.Racine@sbf.ulaval.ca>
Wed, 21 Aug 2013 21:45:18 +0000 (21:45 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@11848 b70326c6-7e19-0410-871a-916f4a2858ee

raster/scripts/plpgsql/st_summarystatsagg.sql

index 44c29ffde5dbd9569dc0bb19623fc419349093c7..32fda53e5a27ff2636750be3ff9dcdb537573267 100644 (file)
@@ -25,7 +25,7 @@ CREATE OR REPLACE FUNCTION raster_summarystatsstate(ss summarystats, rast raster
         newstats summarystats;
         ret summarystats;
     BEGIN
-        IF rast IS NULL THEN
+        IF rast IS NULL OR ST_HasNoBand(rast) OR ST_IsEmpty(rast) THEN
             RETURN ss;
         END IF;
         newstats := _ST_SummaryStats(rast, nband, exclude_nodata_value, sample_percent);
@@ -37,7 +37,7 @@ CREATE OR REPLACE FUNCTION raster_summarystatsstate(ss summarystats, rast raster
                     newstats.min, 
                     newstats.max)::summarystats;
         ELSE
-            ret := (ss.count + newstats.count, 
+            ret := (COALESCE(ss.count,0) + COALESCE(newstats.count, 0),
                     COALESCE(ss.sum,0) + COALESCE(newstats.sum, 0),
                     null,
                     null,