forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit06286f8
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 parentd5300bc commit06286f8
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 | |
---|---|---|---|
| |||
3574 | 3574 |
| |
3575 | 3575 |
| |
3576 | 3576 |
| |
3577 |
| - | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
3578 | 3582 |
| |
3579 |
| - | |
3580 |
| - | |
| 3583 | + | |
3581 | 3584 |
| |
3582 | 3585 |
| |
3583 | 3586 |
| |
|
Lines changed: 4 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
595 | 595 |
| |
596 | 596 |
| |
597 | 597 |
| |
598 |
| - | |
599 |
| - | |
600 |
| - | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
601 | 601 |
| |
602 | 602 |
| |
603 | 603 |
| |
604 | 604 |
| |
605 | 605 |
| |
606 | 606 |
| |
607 | 607 |
| |
608 |
| - | |
609 |
| - | |
| 608 | + | |
610 | 609 |
| |
611 | 610 |
| |
612 | 611 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6346 | 6346 |
| |
6347 | 6347 |
| |
6348 | 6348 |
| |
| 6349 | + | |
| 6350 | + | |
| 6351 | + | |
| 6352 | + | |
| 6353 | + | |
| 6354 | + | |
| 6355 | + | |
| 6356 | + | |
| 6357 | + | |
| 6358 | + | |
| 6359 | + | |
| 6360 | + | |
| 6361 | + | |
| 6362 | + | |
| 6363 | + | |
| 6364 | + | |
| 6365 | + | |
6349 | 6366 |
| |
6350 | 6367 |
| |
6351 | 6368 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2204 | 2204 |
| |
2205 | 2205 |
| |
2206 | 2206 |
| |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
2207 | 2216 |
| |
2208 | 2217 |
| |
2209 | 2218 |
| |
|
0 commit comments
Comments
(0)