forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit091e22b
committed
Clean up treatment of missing default and CHECK-constraint records.
Andrew Gierth reported that it's possible to crash the backend if nopg_attrdef record is found to match an attribute that has atthasdef set.AttrDefaultFetch warns about this situation, but then leaves behinda relation tupdesc that has null "adbin" pointer(s), which most placesdon't guard against.We considered promoting the warning to an error, but throwing errorsduring relcache load is pretty drastic: it effectively locks one outof using the relation at all. What seems better is to leave theload-time behavior as a warning, but then throw an error in any codepath that wants to use a default and can't find it. This confinesthe error to a subset of INSERT/UPDATE operations on the table, andin particular will at least allow a pg_dump to succeed.Also, we should fix AttrDefaultFetch to not leave any null pointersin the tupdesc, because that just creates an untested bug hazard.While at it, apply the same philosophy of "warn at load, throw erroronly upon use of the known-missing info" to CHECK constraints.CheckConstraintFetch is very nearly the same logic as AttrDefaultFetch,but for reasons lost in the mists of time, it was throwing ERROR forthe same cases that AttrDefaultFetch treats as WARNING. Make the twofunctions more nearly alike.In passing, get rid of potentially-O(N^2) loops in equalTupleDescby making AttrDefaultFetch sort the entries after fetching them,so that equalTupleDesc can assume that entries in two equal tupdescsmust be in matching order. (CheckConstraintFetch already was sortingCHECK constraints, but equalTupleDesc hadn't been told about it.)There's some argument for back-patching this, but with such a smallnumber of field reports, I'm content to fix it in HEAD.Discussion:https://postgr.es/m/87pmzaq4gx.fsf@news-spur.riddles.org.uk1 parent9de9294 commit091e22b
File tree
6 files changed
+173
-159
lines changed- src/backend
- access/common
- commands
- executor
- parser
- rewrite
- utils/cache
6 files changed
+173
-159
lines changedLines changed: 22 additions & 46 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
174 | 174 |
| |
175 | 175 |
| |
176 | 176 |
| |
177 |
| - | |
178 |
| - | |
179 |
| - | |
180 |
| - | |
| 177 | + | |
181 | 178 |
| |
182 | 179 |
| |
183 | 180 |
| |
| |||
203 | 200 |
| |
204 | 201 |
| |
205 | 202 |
| |
206 |
| - | |
207 |
| - | |
208 |
| - | |
209 |
| - | |
| 203 | + | |
| 204 | + | |
210 | 205 |
| |
211 | 206 |
| |
212 | 207 |
| |
| |||
328 | 323 |
| |
329 | 324 |
| |
330 | 325 |
| |
331 |
| - | |
332 |
| - | |
333 |
| - | |
334 |
| - | |
| 326 | + | |
335 | 327 |
| |
336 | 328 |
| |
337 | 329 |
| |
| |||
352 | 344 |
| |
353 | 345 |
| |
354 | 346 |
| |
355 |
| - | |
356 |
| - | |
357 |
| - | |
358 |
| - | |
| 347 | + | |
| 348 | + | |
359 | 349 |
| |
360 | 350 |
| |
361 | 351 |
| |
| |||
412 | 402 |
| |
413 | 403 |
| |
414 | 404 |
| |
415 |
| - | |
416 | 405 |
| |
417 | 406 |
| |
418 | 407 |
| |
| |||
488 | 477 |
| |
489 | 478 |
| |
490 | 479 |
| |
| 480 | + | |
491 | 481 |
| |
492 | 482 |
| |
493 | 483 |
| |
494 |
| - | |
495 |
| - | |
496 |
| - | |
497 |
| - | |
498 |
| - | |
499 |
| - | |
500 |
| - | |
501 |
| - | |
502 |
| - | |
503 |
| - | |
504 |
| - | |
505 |
| - | |
506 |
| - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
507 | 487 |
| |
508 | 488 |
| |
509 | 489 |
| |
| |||
534 | 514 |
| |
535 | 515 |
| |
536 | 516 |
| |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
537 | 523 |
| |
538 | 524 |
| |
539 | 525 |
| |
540 |
| - | |
541 |
| - | |
542 |
| - | |
543 |
| - | |
544 |
| - | |
545 |
| - | |
546 |
| - | |
547 |
| - | |
548 |
| - | |
549 |
| - | |
550 |
| - | |
551 |
| - | |
552 |
| - | |
553 |
| - | |
554 |
| - | |
555 |
| - | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
556 | 532 |
| |
557 | 533 |
| |
558 | 534 |
| |
|
Lines changed: 12 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2501 | 2501 |
| |
2502 | 2502 |
| |
2503 | 2503 |
| |
2504 |
| - | |
2505 |
| - | |
2506 | 2504 |
| |
2507 | 2505 |
| |
2508 |
| - | |
2509 |
| - | |
2510 |
| - | |
| 2506 | + | |
2511 | 2507 |
| |
2512 |
| - | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
2513 | 2511 |
| |
2514 |
| - | |
2515 |
| - | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
2516 | 2517 |
| |
2517 | 2518 |
| |
2518 |
| - | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
2519 | 2522 |
| |
2520 | 2523 |
| |
2521 | 2524 |
| |
|
Lines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1609 | 1609 |
| |
1610 | 1610 |
| |
1611 | 1611 |
| |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
1612 | 1621 |
| |
1613 | 1622 |
| |
1614 | 1623 |
| |
| |||
1862 | 1871 |
| |
1863 | 1872 |
| |
1864 | 1873 |
| |
1865 |
| - | |
| 1874 | + | |
1866 | 1875 |
| |
1867 | 1876 |
| |
1868 | 1877 |
| |
|
Lines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1239 | 1239 |
| |
1240 | 1240 |
| |
1241 | 1241 |
| |
1242 |
| - | |
1243 |
| - | |
1244 | 1242 |
| |
1245 | 1243 |
| |
1246 | 1244 |
| |
| |||
1264 | 1262 |
| |
1265 | 1263 |
| |
1266 | 1264 |
| |
| 1265 | + | |
1267 | 1266 |
| |
1268 | 1267 |
| |
1269 | 1268 |
| |
| |||
1276 | 1275 |
| |
1277 | 1276 |
| |
1278 | 1277 |
| |
1279 |
| - | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
1280 | 1281 |
| |
1281 | 1282 |
| |
1282 | 1283 |
| |
|
Lines changed: 16 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1228 | 1228 |
| |
1229 | 1229 |
| |
1230 | 1230 |
| |
1231 |
| - | |
| 1231 | + | |
1232 | 1232 |
| |
1233 |
| - | |
1234 |
| - | |
| 1233 | + | |
1235 | 1234 |
| |
1236 |
| - | |
1237 |
| - | |
1238 |
| - | |
1239 |
| - | |
| 1235 | + | |
1240 | 1236 |
| |
1241 |
| - | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
1242 | 1241 |
| |
1243 |
| - | |
1244 |
| - | |
1245 |
| - | |
1246 |
| - | |
1247 |
| - | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
1248 | 1248 |
| |
1249 | 1249 |
| |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
1250 | 1253 |
| |
1251 | 1254 |
| |
1252 | 1255 |
| |
|
0 commit comments
Comments
(0)