Fix logical errors in constraint exclusion: we cannot assume that a CHECK
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 12 Jan 2008 00:11:45 +0000 (00:11 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 12 Jan 2008 00:11:45 +0000 (00:11 +0000)
commitdcc3299f0edad69ede0410dc58c41f24153bda88
treed1ff91cf5d24a46317163010717423f918155966
parent789f1c96e7b21d3731eacddc97a0a5f87290b20f
Fix logical errors in constraint exclusion: we cannot assume that a CHECK
constraint yields TRUE for every row of its table, only that it does not
yield FALSE (a NULL result isn't disallowed).  This breaks a couple of
implications that would be true in two-valued logic.  I had put in one such
mistake in an 8.2.5 patch: foo IS NULL doesn't refute a strict operator
on foo.  But there was another in the original 8.2 release: NOT foo doesn't
refute an expression whose truth would imply the truth of foo.
Per report from Rajesh Kumar Mallah.

To preserve the ability to do constraint exclusion with one partition
holding NULL values, extend relation_excluded_by_constraints() to check
for attnotnull flags, and add col IS NOT NULL expressions to the set of
constraints we hope to refute.
src/backend/optimizer/util/plancat.c
src/backend/optimizer/util/predtest.c