forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdcef5b0
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 parent2f6e826 commitdcef5b0
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 | |
---|---|---|---|
| |||
3593 | 3593 |
| |
3594 | 3594 |
| |
3595 | 3595 |
| |
3596 |
| - | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
3597 | 3601 |
| |
3598 |
| - | |
3599 |
| - | |
| 3602 | + | |
3600 | 3603 |
| |
3601 | 3604 |
| |
3602 | 3605 |
| |
|
Lines changed: 4 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
602 | 602 |
| |
603 | 603 |
| |
604 | 604 |
| |
605 |
| - | |
606 |
| - | |
607 |
| - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
608 | 608 |
| |
609 | 609 |
| |
610 | 610 |
| |
611 | 611 |
| |
612 | 612 |
| |
613 | 613 |
| |
614 | 614 |
| |
615 |
| - | |
616 |
| - | |
| 615 | + | |
617 | 616 |
| |
618 | 617 |
| |
619 | 618 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6176 | 6176 |
| |
6177 | 6177 |
| |
6178 | 6178 |
| |
| 6179 | + | |
| 6180 | + | |
| 6181 | + | |
| 6182 | + | |
| 6183 | + | |
| 6184 | + | |
| 6185 | + | |
| 6186 | + | |
| 6187 | + | |
| 6188 | + | |
| 6189 | + | |
| 6190 | + | |
| 6191 | + | |
| 6192 | + | |
| 6193 | + | |
| 6194 | + | |
| 6195 | + | |
6179 | 6196 |
| |
6180 | 6197 |
| |
6181 | 6198 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2125 | 2125 |
| |
2126 | 2126 |
| |
2127 | 2127 |
| |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
2128 | 2137 |
| |
2129 | 2138 |
| |
2130 | 2139 |
| |
|
0 commit comments
Comments
(0)