~ubuntu-branches/ubuntu/lucid/postgresql-8.4/lucid-proposed

« back to all changes in this revision

Viewing changes to src/backend/utils/adt/selfuncs.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-10-09 10:28:08 UTC
  • mfrom: (1.4.1) (12.1.8 lucid-security)
  • Revision ID: package-import@ubuntu.com-20131009102808-zrhonpfn94r34fho
Tags: 8.4.18-0ubuntu10.04
New upstream bug fix release (LP: #1237248). No security issues or
critical issues this time; see HISTORY/changelog.gz for details about bug
fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1430
1430
                        /*
1431
1431
                         * No most-common-value info available. Still have null fraction
1432
1432
                         * information, so use it for IS [NOT] UNKNOWN. Otherwise adjust
1433
 
                         * for null fraction and assume an even split for boolean tests.
 
1433
                         * for null fraction and assume a 50-50 split of TRUE and FALSE.
1434
1434
                         */
1435
1435
                        switch (booltesttype)
1436
1436
                        {
1437
1437
                                case IS_UNKNOWN:
1438
 
 
1439
 
                                        /*
1440
 
                                         * Use freq_null directly.
1441
 
                                         */
 
1438
                                        /* select only NULL values */
1442
1439
                                        selec = freq_null;
1443
1440
                                        break;
1444
1441
                                case IS_NOT_UNKNOWN:
1445
 
 
1446
 
                                        /*
1447
 
                                         * Select not unknown (not null) values. Calculate from
1448
 
                                         * freq_null.
1449
 
                                         */
 
1442
                                        /* select non-NULL values */
1450
1443
                                        selec = 1.0 - freq_null;
1451
1444
                                        break;
1452
1445
                                case IS_TRUE:
1453
 
                                case IS_NOT_TRUE:
1454
1446
                                case IS_FALSE:
1455
 
                                case IS_NOT_FALSE:
 
1447
                                        /* Assume we select half of the non-NULL values */
1456
1448
                                        selec = (1.0 - freq_null) / 2.0;
1457
1449
                                        break;
 
1450
                                case IS_NOT_TRUE:
 
1451
                                case IS_NOT_FALSE:
 
1452
                                        /* Assume we select NULLs plus half of the non-NULLs */
 
1453
                                        /* equiv. to freq_null + (1.0 - freq_null) / 2.0 */
 
1454
                                        selec = (freq_null + 1.0) / 2.0;
 
1455
                                        break;
1458
1456
                                default:
1459
1457
                                        elog(ERROR, "unrecognized booltesttype: %d",
1460
1458
                                                 (int) booltesttype);
2988
2986
        ListCell   *l;
2989
2987
 
2990
2988
        /*
 
2989
         * We don't ever want to return an estimate of zero groups, as that tends
 
2990
         * to lead to division-by-zero and other unpleasantness.  The input_rows
 
2991
         * estimate is usually already at least 1, but clamp it just in case it
 
2992
         * isn't.
 
2993
         */
 
2994
        input_rows = clamp_row_est(input_rows);
 
2995
 
 
2996
        /*
2991
2997
         * If no grouping columns, there's exactly one group.  (This can't happen
2992
2998
         * for normal cases with GROUP BY or DISTINCT, but it is possible for
2993
2999
         * corner cases with set operations.)