]> granicus.if.org Git - postgis/commitdiff
Add fallback method of getting maximum extent for extent constraint.
authorBborie Park <bkpark at ucdavis.edu>
Wed, 17 Oct 2012 14:29:42 +0000 (14:29 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Wed, 17 Oct 2012 14:29:42 +0000 (14:29 +0000)
Ticket is #2050

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

raster/rt_pg/rtpostgis.sql.in.c

index 1d496a557f087ee88ea14ac97cd6acbd4f9d4f11..23fe8b188b7693dd01c8e14566a2d58b1b37d6b1 100644 (file)
@@ -5896,8 +5896,18 @@ CREATE OR REPLACE FUNCTION _add_raster_constraint_extent(rastschema name, rastta
                BEGIN
                        EXECUTE sql INTO attr;
                EXCEPTION WHEN OTHERS THEN
-                       RAISE NOTICE 'Unable to get the extent of a sample raster';
-                       RETURN FALSE;
+                       RAISE NOTICE 'Unable to get the extent of a sample raster. Attempting memory efficient (slower) approach';
+
+                       sql := 'SELECT st_ashexewkb(st_convexhull(st_memunion(st_convexhull('
+                               || quote_ident($3)
+                               || ')))) FROM '
+                               || fqtn;
+                       BEGIN
+                               EXECUTE sql INTO attr;
+                       EXCEPTION WHEN OTHERS THEN
+                               RAISE NOTICE 'Still unable to get the extent of a sample raster. Cannot add extent constraint';
+                               RETURN FALSE;
+                       END;
                END;
 
                sql := 'ALTER TABLE ' || fqtn