forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc9f7f92
committed
Allow REPLICA IDENTITY to be set on an index that's not (yet) valid.
The motivation for this change is that when pg_dump dumps apartitioned index that's marked REPLICA IDENTITY, it generates acommand sequence that applies REPLICA IDENTITY before the partitionedindex has been marked valid, causing restore to fail. We couldperhaps change pg_dump to not do it like that, but that would bedifficult and would not fix existing dump files with the problem.There seems to be very little reason for the backend to disallowthis anyway --- the code ignores indisreplident when the indexisn't valid --- so instead let's fix it by allowing the case.Commit9511fb3 previously expressed a concern that allowingindisreplident to be set on invalid indexes might allow us towind up in a situation where a table could have indisreplidentset on multiple indexes. I'm not sure I follow that concernexactly, but in any case the only way that could happen is becauserelation_mark_replica_identity is too trusting about the existing setof markings being valid. Let's just rip out its early-exit code path(which sure looks like premature optimization anyway; what are wedoing expending code to make redundant ALTER TABLE ... REPLICAIDENTITY commands marginally faster and not-redundant ones marginallyslower?) and fix it to positively guarantee that no more than oneindex is marked indisreplident.The pg_dump failure can be demonstrated in all supported branches,so back-patch all the way. I chose to back-patch9511fb3 as well,just to keep indisreplident handling the same in all branches.Per bug #17756 from Sergey Belyashov.Discussion:https://postgr.es/m/17756-dd50e8e0c8dd4a40@postgresql.org1 parente52daaa commitc9f7f92
File tree
4 files changed
+81
-45
lines changed- src
- backend
- catalog
- commands
- test/regress
- expected
- sql
4 files changed
+81
-45
lines changedLines changed: 2 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3482 | 3482 |
| |
3483 | 3483 |
| |
3484 | 3484 |
| |
3485 |
| - | |
3486 |
| - | |
3487 |
| - | |
| 3485 | + | |
| 3486 | + | |
3488 | 3487 |
| |
3489 | 3488 |
| |
3490 | 3489 |
| |
|
Lines changed: 22 additions & 42 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15773 | 15773 |
| |
15774 | 15774 |
| |
15775 | 15775 |
| |
15776 |
| - | |
| 15776 | + | |
| 15777 | + | |
| 15778 | + | |
| 15779 | + | |
15777 | 15780 |
| |
15778 | 15781 |
| |
15779 | 15782 |
| |
| |||
15785 | 15788 |
| |
15786 | 15789 |
| |
15787 | 15790 |
| |
15788 |
| - | |
15789 | 15791 |
| |
15790 | 15792 |
| |
15791 | 15793 |
| |
| |||
15807 | 15809 |
| |
15808 | 15810 |
| |
15809 | 15811 |
| |
15810 |
| - | |
15811 |
| - | |
15812 |
| - | |
15813 |
| - | |
15814 |
| - | |
15815 |
| - | |
15816 |
| - | |
15817 |
| - | |
15818 |
| - | |
15819 |
| - | |
15820 |
| - | |
15821 |
| - | |
15822 |
| - | |
15823 |
| - | |
15824 |
| - | |
15825 |
| - | |
15826 |
| - | |
15827 |
| - | |
15828 |
| - | |
15829 |
| - | |
15830 |
| - | |
15831 |
| - | |
15832 |
| - | |
| 15812 | + | |
15833 | 15813 |
| |
15834 | 15814 |
| |
15835 | 15815 |
| |
| |||
15843 | 15823 |
| |
15844 | 15824 |
| |
15845 | 15825 |
| |
15846 |
| - | |
15847 |
| - | |
15848 |
| - | |
15849 |
| - | |
15850 |
| - | |
| 15826 | + | |
15851 | 15827 |
| |
15852 |
| - | |
15853 |
| - | |
| 15828 | + | |
| 15829 | + | |
| 15830 | + | |
| 15831 | + | |
| 15832 | + | |
| 15833 | + | |
15854 | 15834 |
| |
15855 |
| - | |
| 15835 | + | |
15856 | 15836 |
| |
15857 |
| - | |
15858 |
| - | |
| 15837 | + | |
| 15838 | + | |
| 15839 | + | |
| 15840 | + | |
| 15841 | + | |
| 15842 | + | |
15859 | 15843 |
| |
15860 | 15844 |
| |
15861 | 15845 |
| |
| |||
15867 | 15851 |
| |
15868 | 15852 |
| |
15869 | 15853 |
| |
15870 |
| - | |
| 15854 | + | |
| 15855 | + | |
| 15856 | + | |
15871 | 15857 |
| |
15872 | 15858 |
| |
15873 | 15859 |
| |
| |||
15952 | 15938 |
| |
15953 | 15939 |
| |
15954 | 15940 |
| |
15955 |
| - | |
15956 |
| - | |
15957 |
| - | |
15958 |
| - | |
15959 |
| - | |
15960 |
| - | |
15961 | 15941 |
| |
15962 | 15942 |
| |
15963 | 15943 |
| |
|
Lines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
227 | 227 |
| |
228 | 228 |
| |
229 | 229 |
| |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
230 | 266 |
| |
231 | 267 |
| |
232 | 268 |
| |
| 269 | + | |
233 | 270 |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
98 | 98 |
| |
99 | 99 |
| |
100 | 100 |
| |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
101 | 120 |
| |
102 | 121 |
| |
103 | 122 |
| |
| 123 | + | |
104 | 124 |
|
0 commit comments
Comments
(0)