Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix division by zero in the new range type histogram creation.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 30 Aug 2012 17:27:19 +0000 (20:27 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 30 Aug 2012 17:29:11 +0000 (20:29 +0300)
Report and analysis by Matthias.

src/backend/utils/adt/rangetypes_typanalyze.c

index e276ad8e18125683c56ba0bd57ca88afd618fe57..5f346834e759c02713ba87675ff0203b6793e9f9 100644 (file)
@@ -158,7 +158,10 @@ compute_range_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
        /* Must copy the target values into anl_context */
        old_cxt = MemoryContextSwitchTo(stats->anl_context);
 
-       if (non_empty_cnt > 0)
+       /*
+        * Generate a histogram slot entry if there are at least two values.
+        */
+       if (non_empty_cnt >= 2)
        {
            /* Sort bound values */
            qsort_arg(lowers, non_empty_cnt, sizeof(RangeBound),