postgresql/src/backend
David Rowley 3af7040985 Fix IS [NOT] NULL qual optimization for inheritance tables
b262ad440 added code to have the planner remove redundant IS NOT NULL
quals and eliminate needless scans for IS NULL quals on tables where the
qual's column has a NOT NULL constraint.

That commit failed to consider that an inheritance parent table could
have differing NOT NULL constraints between the parent and the child.
This caused issues as if we eliminated a qual on the parent, when
applying the quals to child tables in apply_child_basequals(), the qual
might not have been added to the parent's baserestrictinfo.

Here we fix this by not applying the optimization to remove redundant
quals to RelOptInfos belonging to inheritance parents and applying the
optimization again in apply_child_basequals().  Effectively, this means
that the parent and child are considered independently as the parent has
both an inh=true and inh=false RTE and we still apply the optimization
to the RelOptInfo corresponding to the inh=false RTE.

We're able to still apply the optimization in add_base_clause_to_rel()
for partitioned tables as the NULLability of partitions must match that
of their parent.  And, if we ever expand restriction_is_always_false()
and restriction_is_always_true() to handle partition constraints then we
can apply the same logic as, even in multi-level partitioned tables,
there's no way to route values to a partition when the qual does not
match the partition qual of the partitioned table's parent partition.
The same is true for CHECK constraints as those must also match between
arent partitioned tables and their partitions.

Author: Richard Guo, David Rowley
Discussion: https://postgr.es/m/CAMbWs4930gQSZmjR7aANzEapdy61gCg6z8dT-kAEYD0sYWKPdQ@mail.gmail.com
2024-04-12 20:07:53 +12:00
..
access Revert: Implement pg_wal_replay_wait() stored procedure 2024-04-11 17:28:15 +03:00
archive Add built-in ERROR handling for archive callbacks. 2024-04-02 22:28:11 -05:00
backup Fix grammar. 2024-04-11 14:35:42 +12:00
bootstrap Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
catalog Revert: Implement pg_wal_replay_wait() stored procedure 2024-04-11 17:28:15 +03:00
commands Revert: Implement pg_wal_replay_wait() stored procedure 2024-04-11 17:28:15 +03:00
executor Revert: Allow table AM tuple_insert() method to return the different slot 2024-04-11 16:02:45 +03:00
foreign Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
jit Fix illegal attribute propagation in LLVM JIT. 2024-04-10 12:13:46 +12:00
lib Revert: Implement pg_wal_replay_wait() stored procedure 2024-04-11 17:28:15 +03:00
libpq Fix check for 'outlen' return from SSL_select_next_proto() 2024-04-08 05:03:17 +03:00
main Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
nodes revert: Transform OR clauses to ANY expression 2024-04-10 02:28:09 +03:00
optimizer Fix IS [NOT] NULL qual optimization for inheritance tables 2024-04-12 20:07:53 +12:00
parser Checks for ALTER TABLE ... SPLIT/MERGE PARTITIONS ... commands 2024-04-10 01:47:21 +03:00
partitioning Fix some grammer errors from error messages and codes comments 2024-04-08 14:39:41 +03:00
po Update copyright for 2024 2024-01-03 20:49:05 -05:00
port Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
postmaster Revert: Custom reloptions for table AM 2024-04-11 15:46:35 +03:00
regex Support C.UTF-8 locale in the new builtin collation provider. 2024-03-19 15:24:41 -07:00
replication Use correct datatype for xmin variables in slot.c 2024-04-11 17:19:20 +09:00
rewrite Add RETURNING support to MERGE. 2024-03-17 13:58:59 +00:00
snowball Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
statistics Make stxstattarget nullable 2024-03-17 12:26:26 +01:00
storage Revert: Implement pg_wal_replay_wait() stored procedure 2024-04-11 17:28:15 +03:00
tcop Revert: Custom reloptions for table AM 2024-04-11 15:46:35 +03:00
tsearch Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
utils Revert: Implement pg_wal_replay_wait() stored procedure 2024-04-11 17:28:15 +03:00
.gitignore
Makefile Rework lwlocknames.txt to become lwlocklist.h 2024-03-20 11:55:20 +01:00
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
meson.build Remove AIX support 2024-02-28 15:17:23 +04:00
nls.mk Remove distprep 2023-11-06 15:18:04 +01:00