]> granicus.if.org Git - postgis/commitdiff
Have ST_Estimated_Extent return NULL when no stats are found for a table.
authorSandro Santilli <strk@keybit.net>
Thu, 8 Dec 2011 11:29:00 +0000 (11:29 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 8 Dec 2011 11:29:00 +0000 (11:29 +0000)
No stats means empty table or no run of analyze. Warn about that.
These Fixes bug #877. Includes regress test.

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

postgis/geometry_estimate.c
regress/tickets.sql
regress/tickets_expected

index a323f4b4fb37798cf9972f4b878261689efa8586..a0ea962073ae13219a8615e835fefa09eac63a6e 100644 (file)
@@ -1450,7 +1450,12 @@ Datum geometry_estimated_extent(PG_FUNCTION_ARGS)
 
                POSTGIS_DEBUGF(3, " %d stat rows", SPI_processed);
 
-               elog(ERROR, "geometry_estimated_extent: couldn't locate table within current schema");
+               /* 
+                * TODO: distinguish between empty and not analyzed ?
+                */
+               elog(WARNING, "No stats for \"%s\".\"%s\".\"%s\" "
+                       "(empty or not analyzed)",
+                       ( nsp ? nsp : "<current>" ), tbl, col);
 
                PG_RETURN_NULL() ;
        }
@@ -1465,7 +1470,7 @@ Datum geometry_estimated_extent(PG_FUNCTION_ARGS)
 
                POSTGIS_DEBUG(3, " stats are NULL");
 
-               elog(ERROR, "geometry_estimated_extent: couldn't locate statistics for table");
+               elog(ERROR, "geometry_estimated_extent: null statistics for table");
 
                PG_RETURN_NULL();
        }
index 9f0e8265ea58ae386d4211450b560cbd2399a9c8..2dc7feeb43bff5b879c577b9382c3f12736fdc50 100644 (file)
@@ -409,6 +409,17 @@ SELECT '#1273', st_equals(p.g, postgis_addbbox(p.g)) from p;
 WITH p AS ( SELECT 'MULTIPOINT((832694.188 816254.625))'::geometry as g ) 
 SELECT '#1273.1', st_equals(p.g, postgis_dropbbox(p.g)) from p;
 
+-- #877
+create table t(g geometry);
+select '#877.1', st_estimated_extent('t','g');
+analyze t;
+select '#877.2', st_estimated_extent('public', 't','g');
+insert into t(g) values ('LINESTRING(-10 -50, 20 30)');
+select '#877.3', st_estimated_extent('t','g');
+analyze t;
+select '#877.4', st_estimated_extent('t','g');
+drop table t;
+
 -- Clean up
 DELETE FROM spatial_ref_sys;
 
index 1f6ebbe713227f093e2d48153d8815c6c28eb552..e40b973b2e6793ab1374d5ea57ca5972962f6fc3 100644 (file)
@@ -120,3 +120,10 @@ ERROR:  First argument must be a LINESTRING
 #1060|FFFFFFFF2
 #1273|t
 #1273.1|t
+WARNING:  No stats for "<current>"."t"."g" (empty or not analyzed)
+#877.1|
+WARNING:  No stats for "public"."t"."g" (empty or not analyzed)
+#877.2|
+WARNING:  No stats for "<current>"."t"."g" (empty or not analyzed)
+#877.3|
+#877.4|BOX(-10 -50,20 30)