]> granicus.if.org Git - postgresql/commit
Allow predicate_refuted_by() to deduce that NOT A refutes A.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Feb 2010 21:00:03 +0000 (21:00 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Feb 2010 21:00:03 +0000 (21:00 +0000)
commita7ac5c64fdeb7824e8033b990503bac159bcff6a
tree2f613314955012b9575405967c69a5b7f6f4678b
parent5ea449e06e78544818716a4342c23934b9e25d5a
Allow predicate_refuted_by() to deduce that NOT A refutes A.

We had originally made the stronger assumption that NOT A refutes any B
if B implies A, but this fails in three-valued logic, because we need to
prove B is false not just that it's not true.  However the logic does
go through if B is equal to A.

Recognizing this limited case is enough to handle examples that arise when
we have simplified "bool_var = true" or "bool_var = false" to just "bool_var"
or "NOT bool_var".  If we had not done that simplification then the
btree-operator proof logic would have been able to prove that the expressions
were contradictory, but only for identical expressions being compared to the
constants; so handling identical A and B covers all the same cases.

The motivation for doing this is to avoid unexpected asymmetrical behavior
when a partitioned table uses a boolean partitioning column, as in today's
gripe from Dominik Sander.

Back-patch to 8.2, which is as far back as predicate_refuted_by attempts to
do anything at all with NOTs.
src/backend/optimizer/util/predtest.c