- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitd45597f
committed
Disallow direct change of NO INHERIT of not-null constraints
We support changing NO INHERIT constraint to INHERIT for constraints inchild relations when adding a constraint to some ancestor relation, andalso during pg_upgrade's schema restore; but other than those specialcases, command ALTER TABLE ADD CONSTRAINT should not be allowed tochange an existing constraint from NO INHERIT to INHERIT, as that wouldrequire to process child relations so that they also acquire anappropriate constraint, which we may not be in a position to do. (It'dalso be surprising behavior.)It is conceivable that we want to allow ALTER TABLE SET NOT NULL to makesuch a change; but in that case some more code is needed to implement itcorrectly, so for now I've made that throw the same error message.Also, during the prep phase of ALTER TABLE ADD CONSTRAINT, acquire lockson all descendant tables; otherwise we might operate on child tables onwhich no locks are held, particularly in the mode where a primary keycauses not-null constraints to be created on children.Reported-by: Alexander Lakhin <exclusion@gmail.com>Discussion:https://postgr.es/m/7d923a66-55f0-3395-cd40-81c142b5448b@gmail.com1 parent42510c0 commitd45597f
File tree
7 files changed
+92
-14
lines changed- doc/src/sgml/ref
- src
- backend
- catalog
- commands
- include/catalog
- test/regress
- expected
- sql
7 files changed
+92
-14
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
105 | 105 |
| |
106 | 106 |
| |
107 | 107 |
| |
108 |
| - | |
| 108 | + | |
109 | 109 |
| |
110 | 110 |
| |
111 | 111 |
| |
|
Lines changed: 15 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2549 | 2549 |
| |
2550 | 2550 |
| |
2551 | 2551 |
| |
2552 |
| - | |
2553 |
| - | |
2554 |
| - | |
2555 |
| - | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
2556 | 2565 |
| |
2557 | 2566 |
| |
2558 |
| - | |
| 2567 | + | |
| 2568 | + | |
2559 | 2569 |
| |
2560 | 2570 |
| |
2561 | 2571 |
| |
|
Lines changed: 11 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
721 | 721 |
| |
722 | 722 |
| |
723 | 723 |
| |
724 |
| - | |
| 724 | + | |
725 | 725 |
| |
726 | 726 |
| |
727 | 727 |
| |
| |||
744 | 744 |
| |
745 | 745 |
| |
746 | 746 |
| |
747 |
| - | |
| 747 | + | |
748 | 748 |
| |
749 | 749 |
| |
750 | 750 |
| |
751 | 751 |
| |
752 |
| - | |
753 |
| - | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
754 | 755 |
| |
755 | 756 |
| |
756 | 757 |
| |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
757 | 764 |
| |
758 | 765 |
| |
759 | 766 |
| |
|
Lines changed: 15 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4980 | 4980 |
| |
4981 | 4981 |
| |
4982 | 4982 |
| |
4983 |
| - | |
4984 |
| - | |
4985 | 4983 |
| |
| 4984 | + | |
| 4985 | + | |
| 4986 | + | |
4986 | 4987 |
| |
| 4988 | + | |
4987 | 4989 |
| |
4988 | 4990 |
| |
4989 | 4991 |
| |
| |||
7892 | 7894 |
| |
7893 | 7895 |
| |
7894 | 7896 |
| |
| 7897 | + | |
| 7898 | + | |
| 7899 | + | |
| 7900 | + | |
| 7901 | + | |
| 7902 | + | |
| 7903 | + | |
| 7904 | + | |
| 7905 | + | |
| 7906 | + | |
| 7907 | + | |
7895 | 7908 |
| |
7896 | 7909 |
| |
7897 | 7910 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
262 | 262 |
| |
263 | 263 |
| |
264 | 264 |
| |
265 |
| - | |
| 265 | + | |
266 | 266 |
| |
267 | 267 |
| |
268 | 268 |
| |
|
Lines changed: 29 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2126 | 2126 |
| |
2127 | 2127 |
| |
2128 | 2128 |
| |
2129 |
| - | |
| 2129 | + | |
2130 | 2130 |
| |
2131 | 2131 |
| |
2132 | 2132 |
| |
| |||
2277 | 2277 |
| |
2278 | 2278 |
| |
2279 | 2279 |
| |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
2280 | 2308 |
| |
2281 | 2309 |
| |
2282 | 2310 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
844 | 844 |
| |
845 | 845 |
| |
846 | 846 |
| |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
847 | 867 |
| |
848 | 868 |
| |
849 | 869 |
| |
|
0 commit comments
Comments
(0)