forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8391779
Fix ALTER TABLE DETACH for inconsistent indexes
When a partitioned table has an index that doesn't support a constraint,but a partition has an equivalent index that does, then a DETACHoperation would misbehave: a crash in assertion-enabled systems (becausewe fail to find the constraint in the parent that we expect to), or abroken coninhcount value (-1) in production systems (because we blindlybelieve that we've successfully detached the parent).While we should reject an ATTACH of a partition with such an index, wehave failed to do so in existing releases, so adding an error in stablereleases might break the (unlikely) existing applications that rely onthis behavior. At this point I don't even want to reject them inmaster, because it'd break pg_upgrade if such databases exist, and therewould be no easy way to fix existing databases without expensive indexrebuilds.(Later on we could add ALTER TABLE ... ADD CONSTRAINT USING INDEX topartitioned tables, which would allow the user to fix such patterns. Atthat point we could add more restrictions to prevent the problem fromits root.)Also, add a test case that leaves one table in this condition, so thatwe can verify that pg_upgrade continues to work if we later decide tochange the policy on the master branch.Backpatch to all supported branches.Co-authored-by: Tender Wang <tndrwang@gmail.com>Reported-by: Alexander Lakhin <exclusion@gmail.com>Reviewed-by: Tender Wang <tndrwang@gmail.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/18500-62948b6fe5522f56@postgresql.org1 parent734c057 commit8391779
File tree
3 files changed
+95
-4
lines changed- src
- backend/commands
- test/regress
- expected
- sql
3 files changed
+95
-4
lines changedLines changed: 13 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19281 | 19281 |
| |
19282 | 19282 |
| |
19283 | 19283 |
| |
| 19284 | + | |
19284 | 19285 |
| |
19285 | 19286 |
| |
| 19287 | + | |
19286 | 19288 |
| |
19287 | 19289 |
| |
19288 | 19290 |
| |
19289 | 19291 |
| |
19290 |
| - | |
19291 |
| - | |
| 19292 | + | |
| 19293 | + | |
19292 | 19294 |
| |
19293 | 19295 |
| |
19294 | 19296 |
| |
19295 | 19297 |
| |
19296 |
| - | |
| 19298 | + | |
| 19299 | + | |
| 19300 | + | |
| 19301 | + | |
| 19302 | + | |
| 19303 | + | |
19297 | 19304 |
| |
19298 | 19305 |
| |
19299 |
| - | |
| 19306 | + | |
| 19307 | + | |
| 19308 | + | |
19300 | 19309 |
| |
19301 | 19310 |
| |
19302 | 19311 |
| |
|
Lines changed: 42 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
626 | 626 |
| |
627 | 627 |
| |
628 | 628 |
| |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
629 | 671 |
| |
630 | 672 |
| |
631 | 673 |
| |
|
Lines changed: 40 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
449 | 449 |
| |
450 | 450 |
| |
451 | 451 |
| |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
452 | 492 |
| |
453 | 493 |
| |
454 | 494 |
| |
|
0 commit comments
Comments
(0)