forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit97390fe
committed
Further fixes for CREATE TABLE LIKE: cope with self-referential FKs.
Commit5028981 was too careless about the order of execution of theadditional ALTER TABLE operations generated by expandTableLikeClause.It just stuck them all at the end, which seems okay for most purposes.But it falls down in the case where LIKE is importing a primary keyor unique index and the outer CREATE TABLE includes a FOREIGN KEYconstraint that needs to depend on that index. Weird as that is,it used to work, so we ought to keep it working.To fix, make parse_utilcmd.c insert LIKE clauses between index-creationand FK-creation commands in the transformed list of commands, and changeutility.c so that the commands generated by expandTableLikeClause areexecuted immediately not at the end. One could imagine scenarios wherethis wouldn't work either; but currently expandTableLikeClause onlymakes column default expressions, CHECK constraints, and indexes, andthis ordering seems fine for those.Per bug #16730 from Sofoklis Papasofokli. Like the previous patch,back-patch to all supported branches.Discussion:https://postgr.es/m/16730-b902f7e6e0276b30@postgresql.org1 parentafaccbb commit97390fe
File tree
4 files changed
+56
-20
lines changed- src
- backend
- parser
- tcop
- test/regress
- expected
- sql
4 files changed
+56
-20
lines changedLines changed: 22 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
86 | 86 |
| |
87 | 87 |
| |
88 | 88 |
| |
| 89 | + | |
89 | 90 |
| |
90 | 91 |
| |
91 | 92 |
| |
| |||
243 | 244 |
| |
244 | 245 |
| |
245 | 246 |
| |
| 247 | + | |
246 | 248 |
| |
247 | 249 |
| |
248 | 250 |
| |
| |||
309 | 311 |
| |
310 | 312 |
| |
311 | 313 |
| |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
312 | 328 |
| |
313 | 329 |
| |
314 | 330 |
| |
| |||
923 | 939 |
| |
924 | 940 |
| |
925 | 941 |
| |
926 |
| - | |
| 942 | + | |
927 | 943 |
| |
928 | 944 |
| |
929 | 945 |
| |
| |||
1088 | 1104 |
| |
1089 | 1105 |
| |
1090 | 1106 |
| |
1091 |
| - | |
1092 |
| - | |
| 1107 | + | |
| 1108 | + | |
1093 | 1109 |
| |
1094 | 1110 |
| |
1095 | 1111 |
| |
1096 | 1112 |
| |
1097 | 1113 |
| |
1098 | 1114 |
| |
1099 |
| - | |
| 1115 | + | |
1100 | 1116 |
| |
1101 | 1117 |
| |
1102 | 1118 |
| |
| |||
2692 | 2708 |
| |
2693 | 2709 |
| |
2694 | 2710 |
| |
2695 |
| - | |
| 2711 | + | |
2696 | 2712 |
| |
2697 | 2713 |
| |
2698 | 2714 |
| |
| |||
3205 | 3221 |
| |
3206 | 3222 |
| |
3207 | 3223 |
| |
| 3224 | + | |
3208 | 3225 |
| |
3209 | 3226 |
| |
3210 | 3227 |
| |
|
Lines changed: 13 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1138 | 1138 |
| |
1139 | 1139 |
| |
1140 | 1140 |
| |
1141 |
| - | |
1142 | 1141 |
| |
1143 | 1142 |
| |
1144 | 1143 |
| |
1145 | 1144 |
| |
1146 | 1145 |
| |
1147 | 1146 |
| |
1148 |
| - | |
1149 |
| - | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
1150 | 1153 |
| |
1151 |
| - | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
1152 | 1157 |
| |
1153 | 1158 |
| |
1154 | 1159 |
| |
| |||
1214 | 1219 |
| |
1215 | 1220 |
| |
1216 | 1221 |
| |
1217 |
| - | |
1218 |
| - | |
| 1222 | + | |
| 1223 | + | |
1219 | 1224 |
| |
1220 | 1225 |
| |
1221 | 1226 |
| |
1222 | 1227 |
| |
1223 | 1228 |
| |
1224 | 1229 |
| |
1225 | 1230 |
| |
1226 |
| - | |
1227 |
| - | |
1228 |
| - | |
1229 |
| - | |
1230 |
| - | |
1231 |
| - | |
1232 |
| - | |
1233 |
| - | |
| 1231 | + | |
1234 | 1232 |
| |
1235 | 1233 |
| |
1236 | 1234 |
| |
| |||
1258 | 1256 |
| |
1259 | 1257 |
| |
1260 | 1258 |
| |
1261 |
| - | |
| 1259 | + | |
1262 | 1260 |
| |
1263 | 1261 |
| |
1264 | 1262 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
282 | 282 |
| |
283 | 283 |
| |
284 | 284 |
| |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
285 | 301 |
| |
286 | 302 |
| |
287 | 303 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
114 | 114 |
| |
115 | 115 |
| |
116 | 116 |
| |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
117 | 122 |
| |
118 | 123 |
| |
119 | 124 |
| |
|
0 commit comments
Comments
(0)