forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitfbbf680
committed
Disallow non-default collation in ADD PRIMARY KEY/UNIQUE USING INDEX.
When creating a uniqueness constraint using a pre-existing index,we have always required that the index have the same properties you'dget if you just let a new index get built. However, when collationswere added, we forgot to add the index's collation to that check.It's hard to trip over this without intentionally trying to break it:you'd have to explicitly specify a different collation in CREATEINDEX, then convert it to a pkey or unique constraint. Still, if youdid that, pg_dump would emit a script that fails to reproduce theindex's collation. The main practical problem is that after apg_upgrade the index would be corrupt, because its actual physicalorder wouldn't match what pg_index says. A more theoretical issue,which is new as of v12, is that if you create the index with anondeterministic collation then it wouldn't be enforcing the normalnotion of uniqueness, causing the constraint to mean somethingdifferent from a normally-created constraint.To fix, just add collation to the conditions checked for indexacceptability in ADD PRIMARY KEY/UNIQUE USING INDEX. We won't tryto clean up after anybody who's already created such a situation;it seems improbable enough to not be worth the effort involved.(If you do get into trouble, a REINDEX should be enough to fix it.)In principle this is a long-standing bug, but I chose not toback-patch --- the odds of causing trouble seem about as greatas the odds of preventing it, and both risks are very low anyway.Per report from Alexey Bashtanov, though this is not his preferredfix.Discussion:https://postgr.es/m/b05ce36a-cefb-ca5e-b386-a400535b1c0b@imap.cc1 parent7d0bcb0 commitfbbf680
File tree
3 files changed
+26
-5
lines changed- src
- backend/parser
- test/regress
- expected
- sql
3 files changed
+26
-5
lines changedLines changed: 7 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2147 | 2147 |
| |
2148 | 2148 |
| |
2149 | 2149 |
| |
2150 |
| - | |
2151 |
| - | |
2152 |
| - | |
2153 |
| - | |
2154 |
| - | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
2155 | 2156 |
| |
2156 | 2157 |
| |
2157 | 2158 |
| |
2158 | 2159 |
| |
| 2160 | + | |
2159 | 2161 |
| |
2160 | 2162 |
| |
2161 | 2163 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1479 | 1479 |
| |
1480 | 1480 |
| |
1481 | 1481 |
| |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
1482 | 1495 |
| |
1483 | 1496 |
| |
1484 | 1497 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
538 | 538 |
| |
539 | 539 |
| |
540 | 540 |
| |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
541 | 547 |
| |
542 | 548 |
| |
543 | 549 |
| |
|
0 commit comments
Comments
(0)