forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf46bee3
committed
Fix dumps of partitioned tables with table AMs
pg_dump/restore failed to properly set the table access method forpartitioned tables, as it relies on SET queries that would changedefault_table_access_method. However, SET affects only tables andmaterialized views, not partitioned tables which would always berestored with their pg_class.relam set to 0, losing their table AM setby either a CREATE TABLE .. USING or by a ALTER TABLE .. SET ACCESSMETHOD.Appending a USING clause to the definition of CREATE TABLE is notpossible as users may specify --no-table-access-method at restore or fora dump, meaning that the table AM portions may have to be skipped.Rather than SET, the solution used by this commit is to generate anextra ALTER TABLE .. SET ACCESS METHOD when restoring a partitionedtable, based on the table AM set in its TOC entry. The choice of usinga SET query or an ALTER TABLE query for a relation requires the additionof the relkind to the TOC entry to be able to choose between one or theother. Note that using ALTER TABLE SET ACCESS METHOD on a relation withphysical storage would require a full rewrite, which would be costly forone. This also creates problems with binary upgrades where the rewritewould not be able to keep the OID of the relation consistent across theupgrade.This commit would normally require a protocol bump, buta45c78e hasalready done one for this release cycle.Regression tests are adjusted with the new expected output, with sometweaks for the table AMs of the partitions to make the output morereadable.Issue introduced by374c7a2, that has added support for table AMsin partitioned tables.Author: Michael PaquierReviewed-by: Álvaro HerreraDiscussion:https://postgr.es/m/Zh4JLSvvtQgBJZkZ@paquier.xyz1 parenteff6a75 commitf46bee3
File tree
4 files changed
+79
-9
lines changed- src/bin/pg_dump
- t
4 files changed
+79
-9
lines changedLines changed: 68 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
| |||
62 | 63 |
| |
63 | 64 |
| |
64 | 65 |
| |
| 66 | + | |
| 67 | + | |
65 | 68 |
| |
66 | 69 |
| |
67 | 70 |
| |
| |||
1222 | 1225 |
| |
1223 | 1226 |
| |
1224 | 1227 |
| |
| 1228 | + | |
1225 | 1229 |
| |
1226 | 1230 |
| |
1227 | 1231 |
| |
| |||
2602 | 2606 |
| |
2603 | 2607 |
| |
2604 | 2608 |
| |
| 2609 | + | |
2605 | 2610 |
| |
2606 | 2611 |
| |
2607 | 2612 |
| |
| |||
2707 | 2712 |
| |
2708 | 2713 |
| |
2709 | 2714 |
| |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
2710 | 2718 |
| |
2711 | 2719 |
| |
2712 | 2720 |
| |
| |||
3567 | 3575 |
| |
3568 | 3576 |
| |
3569 | 3577 |
| |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
| 3611 | + | |
| 3612 | + | |
| 3613 | + | |
| 3614 | + | |
| 3615 | + | |
| 3616 | + | |
| 3617 | + | |
| 3618 | + | |
| 3619 | + | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
3570 | 3623 |
| |
3571 | 3624 |
| |
3572 | 3625 |
| |
| |||
3673 | 3726 |
| |
3674 | 3727 |
| |
3675 | 3728 |
| |
3676 |
| - | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
3677 | 3735 |
| |
3678 | 3736 |
| |
3679 | 3737 |
| |
3680 |
| - | |
| 3738 | + | |
| 3739 | + | |
3681 | 3740 |
| |
3682 | 3741 |
| |
3683 | 3742 |
| |
| |||
3812 | 3871 |
| |
3813 | 3872 |
| |
3814 | 3873 |
| |
| 3874 | + | |
| 3875 | + | |
| 3876 | + | |
| 3877 | + | |
| 3878 | + | |
| 3879 | + | |
| 3880 | + | |
3815 | 3881 |
| |
3816 | 3882 |
| |
3817 | 3883 |
| |
|
Lines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
72 |
| - | |
| 72 | + | |
| 73 | + | |
73 | 74 |
| |
74 | 75 |
| |
75 | 76 |
| |
| |||
353 | 354 |
| |
354 | 355 |
| |
355 | 356 |
| |
| 357 | + | |
356 | 358 |
| |
357 | 359 |
| |
358 | 360 |
| |
| |||
393 | 395 |
| |
394 | 396 |
| |
395 | 397 |
| |
| 398 | + | |
396 | 399 |
| |
397 | 400 |
| |
398 | 401 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
16758 | 16758 |
| |
16759 | 16759 |
| |
16760 | 16760 |
| |
| 16761 | + | |
16761 | 16762 |
| |
16762 | 16763 |
| |
16763 | 16764 |
| |
|
Lines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4587 | 4587 |
| |
4588 | 4588 |
| |
4589 | 4589 |
| |
4590 |
| - | |
| 4590 | + | |
4591 | 4591 |
| |
4592 |
| - | |
| 4592 | + | |
4593 | 4593 |
| |
4594 |
| - | |
4595 |
| - | |
4596 | 4594 |
| |
| 4595 | + | |
| 4596 | + | |
4597 | 4597 |
| |
4598 |
| - | |
| 4598 | + | |
4599 | 4599 |
| |
4600 | 4600 |
| |
4601 | 4601 |
| |
4602 |
| - | |
| 4602 | + | |
4603 | 4603 |
| |
4604 | 4604 |
| |
4605 | 4605 |
| |
|
0 commit comments
Comments
(0)