Commit 9d21654
authored
Fix Incorrect Plan Constraints Generated for Join Predicates (#3971)
Plan constraints are used to ensure that cached query plans can be
safely reused when parameter values change. These constraints validate
that a cached plan remains valid for a given set of parameter bindings
and are designed to work with constant-bound comparands where a field is
compared against a constant or parameter (e.g., `field = ?`, `field >
5`).
However, when a query contains both join predicates with non-constant
comparands (e.g., `game.score_id = score.id`) and static predicates
without constant-bound comparands (e.g., `game.score_id IS NOT NULL`),
the plan constraint generation logic could incorrectly attempt to create
constraints for the join predicate. This occurs because the static IS
NOT NULL predicate acts as a filter that allows the query to proceed,
but has no constant literals to capture in the constraint. Without
proper filtering, the planner might try to create a plan constraint for
the join predicate, which is semantically invalid since join predicates
establish correlations between fields rather than between fields and
constants.
This fixes #3973.1 parent 0116b7c commit 9d21654
7 files changed
Lines changed: 344 additions & 271 deletions
File tree
- fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/predicates
- fdb-relational-core/src
- testFixtures/java/com/apple/foundationdb/relational/utils
- test/java/com/apple/foundationdb/relational/recordlayer/query/cache
- yaml-tests/src/test/resources
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
534 | 540 | | |
535 | 541 | | |
536 | 542 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| |||
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
| |||
156 | 159 | | |
157 | 160 | | |
158 | 161 | | |
159 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
160 | 165 | | |
161 | 166 | | |
162 | 167 | | |
| |||
341 | 346 | | |
342 | 347 | | |
343 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
344 | 358 | | |
fdb-relational-core/src/testFixtures/java/com/apple/foundationdb/relational/utils/TestSchemas.java
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
94 | | - | |
| 95 | + | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
0 commit comments