forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf1fcf2d
committed
Fix timing issue with ALTER TABLE's validate constraint
An ALTER TABLE to validate a foreign key in which another subcommandalready caused a pending table rewrite could fail due to ALTER TABLEattempting to validate the foreign key before the actual table rewritetakes place. This situation could result in an error such as:ERROR: could not read block 0 in file "base/nnnnn/nnnnn": read only 0 of 8192 bytesThe failure here was due to the SPI call which validates the foreign keytrying to access an index which is yet to be rebuilt.Similarly, we also incorrectly tried to validate CHECK constraints beforethe heap had been rewritten.The fix for both is to delay constraint validation until phase 3, afterthe table has been rewritten. For CHECK constraints this means a slightbehavioral change. Previously ALTER TABLE VALIDATE CONSTRAINT oninheritance tables would be validated from the bottom up. This wasdifferent from the order of evaluation when a new CHECK constraint wasadded. The changes made here aligns the VALIDATE CONSTRAINT evaluationorder for inheritance tables to be the same as ADD CONSTRAINT, which isgenerally top-down.Reported-by: Nazli Ugur Koyluoglu, using SQLancerDiscussion:https://postgr.es/m/CAApHDvp%3DZXv8wiRyk_0rWr00skhGkt8vXDrHJYXRMft3TjkxCA%40mail.gmail.comBackpatch-through: 9.5 (all supported versions)1 parentb8401c3 commitf1fcf2d
File tree
3 files changed
+93
-106
lines changed- src
- backend/commands
- test/regress
- expected
- sql
3 files changed
+93
-106
lines changedLines changed: 50 additions & 105 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
328 | 328 |
| |
329 | 329 |
| |
330 | 330 |
| |
331 |
| - | |
| 331 | + | |
| 332 | + | |
332 | 333 |
| |
333 | 334 |
| |
334 | 335 |
| |
| |||
342 | 343 |
| |
343 | 344 |
| |
344 | 345 |
| |
345 |
| - | |
346 | 346 |
| |
347 | 347 |
| |
348 | 348 |
| |
| |||
4500 | 4500 |
| |
4501 | 4501 |
| |
4502 | 4502 |
| |
4503 |
| - | |
4504 |
| - | |
| 4503 | + | |
| 4504 | + | |
4505 | 4505 |
| |
4506 | 4506 |
| |
4507 | 4507 |
| |
4508 |
| - | |
4509 |
| - | |
| 4508 | + | |
| 4509 | + | |
4510 | 4510 |
| |
4511 | 4511 |
| |
4512 | 4512 |
| |
| |||
9727 | 9727 |
| |
9728 | 9728 |
| |
9729 | 9729 |
| |
9730 |
| - | |
9731 |
| - | |
| 9730 | + | |
| 9731 | + | |
9732 | 9732 |
| |
9733 | 9733 |
| |
9734 | 9734 |
| |
| |||
9774 | 9774 |
| |
9775 | 9775 |
| |
9776 | 9776 |
| |
| 9777 | + | |
9777 | 9778 |
| |
9778 | 9779 |
| |
9779 | 9780 |
| |
9780 | 9781 |
| |
9781 | 9782 |
| |
9782 |
| - | |
| 9783 | + | |
| 9784 | + | |
9783 | 9785 |
| |
9784 |
| - | |
9785 |
| - | |
9786 |
| - | |
9787 |
| - | |
9788 |
| - | |
9789 |
| - | |
9790 |
| - | |
9791 |
| - | |
9792 |
| - | |
| 9786 | + | |
| 9787 | + | |
| 9788 | + | |
| 9789 | + | |
9793 | 9790 |
| |
9794 |
| - | |
9795 |
| - | |
9796 |
| - | |
9797 |
| - | |
| 9791 | + | |
| 9792 | + | |
| 9793 | + | |
| 9794 | + | |
| 9795 | + | |
| 9796 | + | |
| 9797 | + | |
| 9798 | + | |
| 9799 | + | |
| 9800 | + | |
| 9801 | + | |
9798 | 9802 |
| |
9799 | 9803 |
| |
9800 | 9804 |
| |
| |||
9805 | 9809 |
| |
9806 | 9810 |
| |
9807 | 9811 |
| |
| 9812 | + | |
| 9813 | + | |
| 9814 | + | |
| 9815 | + | |
9808 | 9816 |
| |
9809 | 9817 |
| |
9810 | 9818 |
| |
| |||
9844 | 9852 |
| |
9845 | 9853 |
| |
9846 | 9854 |
| |
9847 |
| - | |
| 9855 | + | |
9848 | 9856 |
| |
9849 | 9857 |
| |
9850 | 9858 |
| |
9851 | 9859 |
| |
9852 |
| - | |
| 9860 | + | |
| 9861 | + | |
| 9862 | + | |
| 9863 | + | |
| 9864 | + | |
| 9865 | + | |
| 9866 | + | |
| 9867 | + | |
| 9868 | + | |
| 9869 | + | |
| 9870 | + | |
| 9871 | + | |
| 9872 | + | |
| 9873 | + | |
| 9874 | + | |
| 9875 | + | |
| 9876 | + | |
| 9877 | + | |
| 9878 | + | |
9853 | 9879 |
| |
9854 | 9880 |
| |
9855 | 9881 |
| |
| |||
10223 | 10249 |
| |
10224 | 10250 |
| |
10225 | 10251 |
| |
10226 |
| - | |
10227 |
| - | |
10228 |
| - | |
10229 |
| - | |
10230 |
| - | |
10231 |
| - | |
10232 |
| - | |
10233 |
| - | |
10234 |
| - | |
10235 |
| - | |
10236 |
| - | |
10237 |
| - | |
10238 |
| - | |
10239 |
| - | |
10240 |
| - | |
10241 |
| - | |
10242 |
| - | |
10243 |
| - | |
10244 |
| - | |
10245 |
| - | |
10246 |
| - | |
10247 |
| - | |
10248 |
| - | |
10249 |
| - | |
10250 |
| - | |
10251 |
| - | |
10252 |
| - | |
10253 |
| - | |
10254 |
| - | |
10255 |
| - | |
10256 |
| - | |
10257 |
| - | |
10258 |
| - | |
10259 |
| - | |
10260 |
| - | |
10261 |
| - | |
10262 |
| - | |
10263 |
| - | |
10264 |
| - | |
10265 |
| - | |
10266 |
| - | |
10267 |
| - | |
10268 |
| - | |
10269 |
| - | |
10270 |
| - | |
10271 |
| - | |
10272 |
| - | |
10273 |
| - | |
10274 |
| - | |
10275 |
| - | |
10276 |
| - | |
10277 |
| - | |
10278 |
| - | |
10279 |
| - | |
10280 |
| - | |
10281 |
| - | |
10282 |
| - | |
10283 |
| - | |
10284 |
| - | |
10285 |
| - | |
10286 |
| - | |
10287 |
| - | |
10288 |
| - | |
10289 |
| - | |
10290 |
| - | |
10291 |
| - | |
10292 |
| - | |
10293 |
| - | |
10294 |
| - | |
10295 |
| - | |
10296 |
| - | |
10297 |
| - | |
10298 |
| - | |
10299 |
| - | |
10300 |
| - | |
10301 |
| - | |
10302 |
| - | |
10303 |
| - | |
10304 |
| - | |
10305 |
| - | |
10306 |
| - | |
10307 | 10252 |
| |
10308 | 10253 |
| |
10309 | 10254 |
| |
|
Lines changed: 21 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
487 | 487 |
| |
488 | 488 |
| |
489 | 489 |
| |
490 |
| - | |
491 | 490 |
| |
| 491 | + | |
492 | 492 |
| |
493 | 493 |
| |
494 | 494 |
| |
| |||
997 | 997 |
| |
998 | 998 |
| |
999 | 999 |
| |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
1000 | 1020 |
| |
1001 | 1021 |
| |
1002 | 1022 |
| |
|
Lines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
757 | 757 |
| |
758 | 758 |
| |
759 | 759 |
| |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
760 | 782 |
| |
761 | 783 |
| |
762 | 784 |
| |
|
0 commit comments
Comments
(0)