postgresql/src/backend
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
..
access Fix incorrect format placeholders 2023-04-12 10:05:50 +02:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Support long distance matching for zstd compression 2023-04-06 17:18:42 +02:00
bootstrap Fix CREATE INDEX progress reporting for multi-level partitioning. 2023-03-25 15:34:03 -04:00
catalog De-Revert "Add support for Kerberos credential delegation" 2023-04-13 08:55:07 -04:00
commands Revert "Catalog NOT NULL constraints" and fallout 2023-04-12 19:29:21 +02:00
executor Fix PHJ match bit initialization. 2023-04-14 11:02:38 +12:00
foreign De-Revert "Add support for Kerberos credential delegation" 2023-04-13 08:55:07 -04:00
jit SQL/JSON: support the IS JSON predicate 2023-03-31 22:34:04 +02:00
lib Fix ILIST_DEBUG build 2023-01-18 10:26:15 -08:00
libpq Remove code in charge of freeing regexps generation by Lab.c 2023-04-14 07:27:44 +09:00
main Mark options as deprecated in usage output 2023-03-02 14:36:37 +01:00
nodes Revert "Catalog NOT NULL constraints" and fallout 2023-04-12 19:29:21 +02:00
optimizer Revert "Catalog NOT NULL constraints" and fallout 2023-04-12 19:29:21 +02:00
parser Harmonize some more function parameter names. 2023-04-13 10:15:20 -07:00
partitioning Fix incorrect partition pruning logic for boolean partitioned tables 2023-04-14 16:20:27 +12:00
po meson: add install-{quiet, world} targets 2023-03-23 21:20:18 -07:00
port Update copyright for 2023 2023-01-02 15:00:37 -05:00
postmaster Add VACUUM/ANALYZE BUFFER_USAGE_LIMIT option 2023-04-07 11:40:31 +12:00
regex Redesign interrupt/cancel API for regex engine. 2023-04-08 22:10:39 +12:00
replication Improve error messages introduced in be87200efd and 0fdab27ad6 2023-04-12 11:00:37 -07:00
rewrite Fix more bugs caused by adding columns to the end of a view. 2023-03-07 18:21:53 -05:00
snowball Update copyright for 2023 2023-01-02 15:00:37 -05:00
statistics Add SysCacheGetAttrNotNull for guaranteed not-null attrs 2023-03-25 22:49:33 +01:00
storage Harmonize some more function parameter names. 2023-04-13 10:15:20 -07:00
tcop Handle logical slot conflicts on standby 2023-04-08 00:05:44 -07:00
tsearch Update tsearch regex memory management. 2023-04-08 22:09:17 +12:00
utils Remove old GUC name mapping for "force_parallel_mode" 2023-04-14 10:19:45 +12:00
.gitignore
Makefile Redesign archive modules 2023-02-17 14:26:42 +09:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
meson.build meson: Prevent installation of test files during main install 2023-03-03 07:45:52 +01:00
nls.mk NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00