[postgis-tickets] r16788 - Handle almost-infinite features when building table statistics in ANALYZE
Paul Ramsey
pramsey at cleverelephant.ca
Thu Sep 13 01:41:00 PDT 2018
Author: pramsey
Date: 2018-09-13 13:41:00 -0700 (Thu, 13 Sep 2018)
New Revision: 16788
Modified:
trunk/postgis/gserialized_estimate.c
trunk/regress/tickets.sql
trunk/regress/tickets_expected
Log:
Handle almost-infinite features when building table statistics in ANALYZE
Closes #4144
Modified: trunk/postgis/gserialized_estimate.c
===================================================================
--- trunk/postgis/gserialized_estimate.c 2018-09-13 20:38:01 UTC (rev 16787)
+++ trunk/postgis/gserialized_estimate.c 2018-09-13 20:41:00 UTC (rev 16788)
@@ -202,6 +202,12 @@
#define MIN_DIMENSION_WIDTH 0.000000001
/**
+* Maximum width of a dimension that we'll bother trying to
+* compute statistics on.
+*/
+#define MAX_DIMENSION_WIDTH 1.0E+20
+
+/**
* Default geometry selectivity factor
*/
#define DEFAULT_ND_SEL 0.0001
@@ -781,8 +787,12 @@
smax = extent->max[d];
swidth = smax - smin;
- /* Don't try and calculate distribution of overly narrow dimensions */
- if ( swidth < MIN_DIMENSION_WIDTH )
+ /* Don't try and calculate distribution of overly narrow */
+ /* or overly wide dimensions. Here we're being pretty geographical, */
+ /* expecting "normal" planar or geographic coordinates. */
+ /* Otherwise we have to "handle" +/- Inf bounded features and */
+ /* the assumptions needed for that are as bad as this hack. */
+ if ( swidth < MIN_DIMENSION_WIDTH || swidth > MAX_DIMENSION_WIDTH )
{
distribution[d] = 0;
continue;
@@ -1386,6 +1396,9 @@
/* Initialize sum and stddev */
nd_box_init(&sum);
nd_box_init(&stddev);
+ nd_box_init(&avg);
+ nd_box_init(&histo_extent);
+ nd_box_init(&histo_extent_new);
/*
* This is where gserialized_analyze_nd
Modified: trunk/regress/tickets.sql
===================================================================
--- trunk/regress/tickets.sql 2018-09-13 20:38:01 UTC (rev 16787)
+++ trunk/regress/tickets.sql 2018-09-13 20:41:00 UTC (rev 16788)
@@ -1101,6 +1101,18 @@
-- #4164
SELECT ST_AsText(ST_GeomFromGeoJSON('{"type": "Polygon", "coordinates": [[0,0],[0,5],[5, 5],[5,0],[0,0]]}'));
+-- #4144
+DROP TABLE IF EXISTS bug_4144_table;
+CREATE TABLE bug_4144_table (
+ geom geometry NOT NULL DEFAULT NULL
+);
+
+INSERT INTO bug_4144_table (geom)
+ VALUES ('GEOMETRYCOLLECTION(POINT(-3.385894e+38 0 0),POINT(0 0 0))');
+
+ANALYZE bug_4144_table;
+DROP TABLE IF EXISTS bug_4144_table;
+
-- Clean up
DELETE FROM spatial_ref_sys;
Modified: trunk/regress/tickets_expected
===================================================================
--- trunk/regress/tickets_expected 2018-09-13 20:38:01 UTC (rev 16787)
+++ trunk/regress/tickets_expected 2018-09-13 20:41:00 UTC (rev 16788)
@@ -336,4 +336,5 @@
ERROR: lwgeom_pointonsurface: GEOS Error: TopologyException: Input geom 1 is invalid: Self-intersection
#4081|f|t
ERROR: The 'coordinates' in GeoJSON polygon are not sufficiently nested
+NOTICE: table "bug_4144_table" does not exist, skipping
#4176|t
More information about the postgis-tickets
mailing list