From 79cebf829c81a6985eff9fdacfdab3a07dbc9e5b Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Mon, 1 Jun 2015 16:15:29 +0000 Subject: [PATCH] Guard against crazy selectivity numbers git-svn-id: http://svn.osgeo.org/postgis/trunk@13600 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/gserialized_estimate.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/postgis/gserialized_estimate.c b/postgis/gserialized_estimate.c index a8829a837..841fffb7e 100644 --- a/postgis/gserialized_estimate.c +++ b/postgis/gserialized_estimate.c @@ -1091,9 +1091,15 @@ estimate_join_selectivity(const ND_STATS *s1, const ND_STATS *s2) */ selectivity = val / ntuples_max; - /* Guard against over-estimates :) */ - if ( selectivity > 1.0 ) - selectivity = 1.0; + /* Guard against over-estimates and crazy numbers :) */ + if ( isnan(selectivity) || ! isfinite(selectivity) || selectivity < 0.0 ) + { + selectivity = DEFAULT_ND_JOINSEL; + } + else if ( selectivity > 1.0 ) + { + selectivity = 1.0; + } return selectivity; } -- 2.40.0