forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit73f1c17
committed
Don't use partial unique indexes for unique proofs in the planner
Here we adjust relation_has_unique_index_for() so that it no longer makesuse of partial unique indexes as uniqueness proofs. It is incorrect touse these as the predicates used by check_index_predicates() to setpredOK makes use of not only baserestrictinfo quals as proofs, but alsoqual from join conditions. For relation_has_unique_index_for()'s case, weneed to know the relation is unique for a given set of columns before anyjoins are evaluated, so if predOK was only set to true due to some joinqual, then it's unsafe to use such indexes inrelation_has_unique_index_for(). The final plan may not even make useof that index, which could result in reading tuples that are not asunique as the planner previously expected them to be.Bug: #17975Reported-by: Tor Erik LinnerudBackpatch-through: 11, all supported versionsDiscussion:https://postgr.es/m/17975-98a90c156f25c952%40postgresql.org1 parent3f157d0 commit73f1c17
File tree
4 files changed
+36
-8
lines changed- src
- backend/optimizer
- path
- plan
- test/regress
- expected
- sql
4 files changed
+36
-8
lines changedLines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3569 | 3569 |
| |
3570 | 3570 |
| |
3571 | 3571 |
| |
3572 |
| - | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
3573 | 3577 |
| |
3574 |
| - | |
3575 |
| - | |
| 3578 | + | |
3576 | 3579 |
| |
3577 | 3580 |
| |
3578 | 3581 |
| |
|
Lines changed: 4 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
592 | 592 |
| |
593 | 593 |
| |
594 | 594 |
| |
595 |
| - | |
596 |
| - | |
597 |
| - | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
598 | 598 |
| |
599 | 599 |
| |
600 | 600 |
| |
601 | 601 |
| |
602 | 602 |
| |
603 | 603 |
| |
604 | 604 |
| |
605 |
| - | |
606 |
| - | |
| 605 | + | |
607 | 606 |
| |
608 | 607 |
| |
609 | 608 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6503 | 6503 |
| |
6504 | 6504 |
| |
6505 | 6505 |
| |
| 6506 | + | |
| 6507 | + | |
| 6508 | + | |
| 6509 | + | |
| 6510 | + | |
| 6511 | + | |
| 6512 | + | |
| 6513 | + | |
| 6514 | + | |
| 6515 | + | |
| 6516 | + | |
| 6517 | + | |
| 6518 | + | |
| 6519 | + | |
| 6520 | + | |
| 6521 | + | |
| 6522 | + | |
6506 | 6523 |
| |
6507 | 6524 |
| |
6508 | 6525 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2263 | 2263 |
| |
2264 | 2264 |
| |
2265 | 2265 |
| |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
2266 | 2275 |
| |
2267 | 2276 |
| |
2268 | 2277 |
| |
|
0 commit comments
Comments
(0)