postgresql/src
David Rowley e0693faf79 Fix incorrect partition pruning logic for boolean partitioned tables
The partition pruning logic assumed that "b IS NOT true" was exactly the
same as "b IS FALSE".  This is not the case when considering NULL values.
Fix this so we correctly include any partition which could hold NULL
values for the NOT case.

Additionally, this fixes a bug in the partition pruning code which handles
partitioned tables partitioned like ((NOT boolcol)).  This is a seemingly
unlikely schema design, and it was untested and also broken.

Here we add tests for the ((NOT boolcol)) case and insert some actual data
into those tables and verify we do get the correct rows back when running
queries.  I've also adjusted the existing boolpart tests to include some
data and verify we get the correct results too.

Both the bugs being fixed here could lead to incorrect query results with
fewer rows being returned than expected.  No additional rows could have
been returned accidentally.

In passing, remove needless ternary expression.  It's more simple just to
pass !is_not_clause to makeBoolConst().  It makes sense to do this so the
code is consistent with the bug fix in the "else if" condition just below.

David Kimura did submit a patch to fix the first of the issues here, but
that's not what's being committed here.

Reported-by: David Kimura
Reviewed-by: Richard Guo, David Kimura
Discussion: https://postgr.es/m/CAHnPFjQ5qxs6J_p+g8=ww7GQvfn71_JE+Tygj0S7RdRci1uwPw@mail.gmail.com
Backpatch-through: 11, all supported versions
2023-04-14 16:20:27 +12:00
..
backend Fix incorrect partition pruning logic for boolean partitioned tables 2023-04-14 16:20:27 +12:00
bin Harmonize some more function parameter names. 2023-04-13 10:15:20 -07:00
common Introduce PG_IO_ALIGN_SIZE and align all I/O buffers. 2023-04-08 16:34:50 +12:00
fe_utils Revert refactoring of restore command code to shell_restore.c 2023-02-06 08:28:42 +09:00
include Harmonize some more function parameter names. 2023-04-13 10:15:20 -07:00
interfaces De-Revert "Add support for Kerberos credential delegation" 2023-04-13 08:55:07 -04:00
makefiles meson: Make auto the default of the ssl option 2023-03-13 07:04:11 +01:00
pl Harmonize some more function parameter names. 2023-04-13 10:15:20 -07:00
port Fix detection of unseekable files for fseek() and ftello() with MSVC 2023-04-12 09:09:38 +09:00
template Use unnamed POSIX semaphores on Cygwin. 2023-01-06 10:33:28 +13:00
test Fix incorrect partition pruning logic for boolean partitioned tables 2023-04-14 16:20:27 +12:00
timezone Fix outdated references to guc.c 2023-03-02 13:49:39 +01:00
tools Fix detection of unseekable files for fseek() and ftello() with MSVC 2023-04-12 09:09:38 +09:00
tutorial Remove useless casts to (void *) in arguments of some system functions 2023-02-07 06:57:59 +01:00
.gitignore
DEVELOPERS
Makefile Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
Makefile.global.in Update Unicode data to CLDR 43 2023-04-13 22:10:08 +02:00
Makefile.shlib
meson.build Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
nls-global.mk