pgsql: Fix booltestsel() for case where we have NULL stats but not MCV

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix booltestsel() for case where we have NULL stats but not MCV
Date: 2013-07-24 04:45:45
Message-ID: E1V1qxN-0004Rj-CH@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix booltestsel() for case where we have NULL stats but not MCV stats.

In a boolean column that contains mostly nulls, ANALYZE might not find
enough non-null values to populate the most-common-values stats,
but it would still create a pg_statistic entry with stanullfrac set.
The logic in booltestsel() for this situation did the wrong thing for
"col IS NOT TRUE" and "col IS NOT FALSE" tests, forgetting that null
values would satisfy these tests (so that the true selectivity would
be close to one, not close to zero). Per bug #8274.

Fix by Andrew Gierth, some comment-smithing by me.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/8e992b01864198af954111ffee9b05635c0ae4c0

Modified Files
--------------
src/backend/utils/adt/selfuncs.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2013-07-24 14:01:23 pgsql: pg_upgrade: fix parallel/-j crash on Windows
Previous Message Tom Lane 2013-07-23 22:21:35 pgsql: Move strip_implicit_coercions() from optimizer to nodeFuncs.c.