[postgis-tickets] r17384 - Guard against zero'd histo edge, but also avoid arbitrarily inflating edge

Paul Ramsey pramsey at cleverelephant.ca
Fri Apr 12 12:45:33 PDT 2019


Author: pramsey
Date: 2019-04-12 12:45:33 -0700 (Fri, 12 Apr 2019)
New Revision: 17384

Modified:
   trunk/postgis/gserialized_estimate.c
Log:
Guard against zero'd histo edge, but also avoid arbitrarily inflating edge
References #4362


Modified: trunk/postgis/gserialized_estimate.c
===================================================================
--- trunk/postgis/gserialized_estimate.c	2019-04-11 16:48:20 UTC (rev 17383)
+++ trunk/postgis/gserialized_estimate.c	2019-04-12 19:45:33 UTC (rev 17384)
@@ -1632,7 +1632,9 @@
 		histo_cells_new = 1;
 		for ( d = 0; d < ndims; d++ )
 		{
-			histo_size[d] = 1 + (int)pow((double)histo_cells_target, 1/(double)ndims);
+			histo_size[d] = (int)pow((double)histo_cells_target, 1/(double)ndims);
+			if ( ! histo_size[d] )
+				histo_size[d] = 1;
 			POSTGIS_DEBUGF(3, "   histo_size[d]: %d", histo_size[d]);
 			histo_cells_new *= histo_size[d];
 		}



More information about the postgis-tickets mailing list