forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite55a946
committed
Fix two bugs in merging of inherited CHECK constraints.
Historically, we've allowed users to add a CHECK constraint to a childtable and then add an identical CHECK constraint to the parent. Thisresults in "merging" the two constraints so that the pre-existingchild constraint ends up with both conislocal = true and coninhcount > 0.However, if you tried to do it in the other order, you got a duplicateconstraint error. This is problematic for pg_dump, which needs to issueseparated ADD CONSTRAINT commands in some cases, but has no good way toensure that the constraints will be added in the required order.And it's more than a bit arbitrary, too. The goal of complaining aboutduplicated ADD CONSTRAINT commands can be served if we reject the case ofadding a constraint when the existing one already has conislocal = true;but if it has conislocal = false, let's just make the ADD CONSTRAINT setconislocal = true. In this way, either order of adding the constraintshas the same end result.Another problem was that the code allowed creation of a parent constraintmarked convalidated that is merged with a child constraint that is!convalidated. In this case, an inheritance scan of the parent table couldemit some rows violating the constraint condition, which would be anunexpected result given the marking of the parent constraint as validated.Hence, forbid merging of constraints in this case. (Note: valid child andnot-valid parent seems fine, so continue to allow that.)Per report from Benedikt Grundmann. Back-patch to 9.2 where we introducedpossibly-not-valid check constraints. The second bug obviously doesn'tapply before that, and I think the first doesn't either, because pg_dumponly gets into this situation when dealing with not-valid constraints.Report: <CADbMkNPT-Jz5PRSQ4RbUASYAjocV_KHUWapR%2Bg8fNvhUAyRpxA%40mail.gmail.com>Discussion: <22108.1475874586@sss.pgh.pa.us>1 parent8811f5d commite55a946
File tree
5 files changed
+135
-9
lines changed- src
- backend
- catalog
- commands
- test/regress
- expected
- sql
5 files changed
+135
-9
lines changedLines changed: 32 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
105 | 105 |
| |
106 | 106 |
| |
107 | 107 |
| |
| 108 | + | |
108 | 109 |
| |
109 | 110 |
| |
110 | 111 |
| |
| |||
2301 | 2302 |
| |
2302 | 2303 |
| |
2303 | 2304 |
| |
| 2305 | + | |
2304 | 2306 |
| |
2305 | 2307 |
| |
2306 | 2308 |
| |
| |||
2389 | 2391 |
| |
2390 | 2392 |
| |
2391 | 2393 |
| |
| 2394 | + | |
2392 | 2395 |
| |
2393 | 2396 |
| |
2394 | 2397 |
| |
| |||
2436 | 2439 |
| |
2437 | 2440 |
| |
2438 | 2441 |
| |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
2439 | 2452 |
| |
2440 | 2453 |
| |
2441 | 2454 |
| |
2442 | 2455 |
| |
2443 | 2456 |
| |
2444 | 2457 |
| |
2445 |
| - | |
2446 |
| - | |
2447 |
| - | |
2448 |
| - | |
| 2458 | + | |
2449 | 2459 |
| |
2450 | 2460 |
| |
2451 | 2461 |
| |
2452 | 2462 |
| |
2453 | 2463 |
| |
2454 | 2464 |
| |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
2455 | 2483 |
| |
2456 | 2484 |
| |
2457 | 2485 |
| |
| |||
2461 | 2489 |
| |
2462 | 2490 |
| |
2463 | 2491 |
| |
2464 |
| - | |
2465 |
| - | |
2466 |
| - | |
2467 |
| - | |
2468 | 2492 |
| |
2469 | 2493 |
| |
2470 | 2494 |
| |
|
Lines changed: 12 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10373 | 10373 |
| |
10374 | 10374 |
| |
10375 | 10375 |
| |
10376 |
| - | |
| 10376 | + | |
10377 | 10377 |
| |
10378 | 10378 |
| |
10379 | 10379 |
| |
10380 | 10380 |
| |
10381 | 10381 |
| |
10382 | 10382 |
| |
10383 | 10383 |
| |
| 10384 | + | |
| 10385 | + | |
| 10386 | + | |
| 10387 | + | |
| 10388 | + | |
| 10389 | + | |
| 10390 | + | |
| 10391 | + | |
| 10392 | + | |
| 10393 | + | |
| 10394 | + | |
10384 | 10395 |
| |
10385 | 10396 |
| |
10386 | 10397 |
| |
|
Lines changed: 50 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1090 | 1090 |
| |
1091 | 1091 |
| |
1092 | 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 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
1093 | 1143 |
| |
1094 | 1144 |
| |
1095 | 1145 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
| 65 | + | |
| 66 | + | |
65 | 67 |
| |
66 | 68 |
| |
67 | 69 |
| |
|
Lines changed: 39 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
334 | 334 |
| |
335 | 335 |
| |
336 | 336 |
| |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
337 | 376 |
| |
338 | 377 |
| |
339 | 378 |
| |
|
0 commit comments
Comments
(0)