aboutsummaryrefslogtreecommitdiff
path: root/src/common/jsonapi.c
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2024-04-12 20:07:53 +1200
committerDavid Rowley <drowley@postgresql.org>2024-04-12 20:07:53 +1200
commit3af7040985b6df504a72cd307aad5d69ac5f5384 (patch)
treefece479e802969e5377b670dc6c33efc05780070 /src/common/jsonapi.c
parent6d4f062714953ed0ec865ff96d5af122b8c3e77f (diff)
downloadpostgresql-3af7040985b6df504a72cd307aad5d69ac5f5384.tar.gz
postgresql-3af7040985b6df504a72cd307aad5d69ac5f5384.zip
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
Diffstat (limited to 'src/common/jsonapi.c')
0 files changed, 0 insertions, 0 deletions