forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0cd7112
Better handle indirect constraint drops
It is possible for certain cases to remove not-null constraints withoutmaintaining the attnotnull in its correct state; for example if you dropa column that's part of the primary key, and the other columns of the PK don'thave not-null constraints, then we should reset the attnotnull flags forthose other columns; up to this commit, we didn't. Handle those casesbetter by doing the attnotnull reset in RemoveConstraintById() insteadof in dropconstraint_internal().However, there are some cases where we must not do so. For example ifthose other columns are in replica identity indexes or are generatedidentity columns, we must keep attnotnull set, even though it results inthe catalog inconsistency that no not-null constraint supports that.Because the attnotnull reset now happens in more places than before, forinstance when a column of the primary key changes type, we need anadditional trick to reinstate it as necessary. Introduce a newalter-table pass that does this, which needs simply reschedule someAT_SetAttNotNull subcommands that were already being generated andignored.Because of the exceptions in which attnotnull is not reset noted above,we also include a pg_dump hack to include a not-null constraint when theattnotnull flag is set even if no pg_constraint row exists. This partis undesirable but necessary, because failing to handle the case canresult in unrestorable dumps.Reported-by: Tender Wang <tndrwang@gmail.com>Co-authored-by: Tender Wang <tndrwang@gmail.com>Reviewed-by: jian he <jian.universality@gmail.com>Discussion:https://postgr.es/m/CAHewXN=hMbNa3d43NOR=OCgdgpTt18S-1fmueCoEGesyeK4bqw@mail.gmail.com1 parent2e068db commit0cd7112
File tree
5 files changed
+323
-76
lines changed- src
- backend
- catalog
- commands
- bin/pg_dump
- test/regress
- expected
- sql
5 files changed
+323
-76
lines changedLines changed: 116 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
| 22 | + | |
22 | 23 |
| |
23 | 24 |
| |
24 | 25 |
| |
| |||
933 | 934 |
| |
934 | 935 |
| |
935 | 936 |
| |
| 937 | + | |
| 938 | + | |
936 | 939 |
| |
937 | 940 |
| |
938 | 941 |
| |
| |||
957 | 960 |
| |
958 | 961 |
| |
959 | 962 |
| |
960 |
| - | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
961 | 966 |
| |
962 | 967 |
| |
963 | 968 |
| |
| |||
984 | 989 |
| |
985 | 990 |
| |
986 | 991 |
| |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
987 | 1022 |
| |
988 | 1023 |
| |
989 | 1024 |
| |
| |||
1003 | 1038 |
| |
1004 | 1039 |
| |
1005 | 1040 |
| |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
1006 | 1121 |
| |
1007 | 1122 |
| |
1008 | 1123 |
| |
|
0 commit comments
Comments
(0)