]> granicus.if.org Git - postgis/commitdiff
Guard against crazy selectivity numbers
authorPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 1 Jun 2015 16:15:29 +0000 (16:15 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 1 Jun 2015 16:15:29 +0000 (16:15 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13600 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/gserialized_estimate.c

index a8829a837b1ebf8c015d7187f7d50d9b84d593a7..841fffb7ee8cae087da7629c4482ef74db34e3f9 100644 (file)
@@ -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;
 }