- Notifications
You must be signed in to change notification settings - Fork28
Commitb3f8401
committed
Move handling of database properties from pg_dumpall into pg_dump.
This patch rearranges the division of labor between pg_dump and pg_dumpallso that pg_dump itself handles all properties attached to a singledatabase. Notably, a database's ACL (GRANT/REVOKE status) and local GUCsettings established by ALTER DATABASE SET and ALTER ROLE IN DATABASE SETcan be dumped and restored by pg_dump. This is a long-requestedimprovement."pg_dumpall -g" will now produce only role- and tablespace-related output,nothing about individual databases. The total output of a regularpg_dumpall run remains the same.pg_dump (or pg_restore) will restore database-level properties only whencreating the target database with --create. This applies not only toACLs and GUCs but to the other database properties it already handled,that is database comments and security labels. This is more consistentand useful, but does represent an incompatibility in the behavior seenwithout --create.(This change makes the proposed patch to have pg_dump use "COMMENT ONDATABASE CURRENT_DATABASE" unnecessary, since there is no case wherethe command is issued that we won't know the true name of the database.We might still want that patch as a feature in its own right, but pg_dumpno longer needs it.)pg_dumpall with --clean will now drop and recreate the "postgres" and"template1" databases in the target cluster, allowing their locale andencoding settings to be changed if necessary, and providing a cleanerway to set nondefault tablespaces for them than we had before. Thismeans that such a script must now always be started in the "postgres"database; the order of drops and reconnects will not work otherwise.Without --clean, the script will not adjust any database-level propertiesof those two databases (including their comments, ACLs, and securitylabels, which it formerly would try to set).Another minor incompatibility is that the CREATE DATABASE commands in apg_dumpall script will now always specify locale and encoding settings.Formerly those would be omitted if they matched the cluster's default.While that behavior had some usefulness in some migration scenarios,it also posed a significant hazard of unwanted locale/encoding changes.To migrate to another locale/encoding, it's now necessary to use pg_dumpwithout --create to restore into a database with the desired settings.Commit4bd371f's hack to emit "SET default_transaction_read_only = off"is gone: we now dodge that problem by the expedient of not issuing ALTERDATABASE SET commands until after reconnecting to the target database.Therefore, such settings won't apply during the restore session.In passing, improve some shaky grammar in the docs, and add a note pointingout that pg_dumpall's output can't be expected to load without any errors.(Someday we might want to fix that, but this is not that patch.)Haribabu Kommi, reviewed at various times by Andreas Karlsson,Vaishnavi Prabakaran, and Robert Haas; further hacking by me.Discussion:https://postgr.es/m/CAJrrPGcUurV0eWTeXODwsOYFN=Ekq36t1s0YnFYUNzsmRfdAyA@mail.gmail.com1 parentd6c8466 commitb3f8401
File tree
10 files changed
+470
-537
lines changed- doc/src/sgml/ref
- src/bin
- pg_dump
- t
- pg_upgrade
10 files changed
+470
-537
lines changedLines changed: 26 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
49 |
| - | |
50 |
| - | |
51 |
| - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
52 | 53 |
| |
53 | 54 |
| |
54 | 55 |
| |
| |||
142 | 143 |
| |
143 | 144 |
| |
144 | 145 |
| |
145 |
| - | |
| 146 | + | |
| 147 | + | |
146 | 148 |
| |
147 | 149 |
| |
148 | 150 |
| |
| |||
196 | 198 |
| |
197 | 199 |
| |
198 | 200 |
| |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
199 | 212 |
| |
200 | 213 |
| |
201 | 214 |
| |
| |||
1231 | 1244 |
| |
1232 | 1245 |
| |
1233 | 1246 |
| |
1234 |
| - | |
1235 |
| - | |
1236 |
| - | |
1237 |
| - | |
1238 | 1247 |
| |
1239 | 1248 |
| |
1240 | 1249 |
| |
| |||
1325 | 1334 |
| |
1326 | 1335 |
| |
1327 | 1336 |
| |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1328 | 1346 |
| |
1329 | 1347 |
| |
1330 | 1348 |
| |
|
Lines changed: 37 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
36 | 36 |
| |
37 | 37 |
| |
38 | 38 |
| |
39 |
| - | |
| 39 | + | |
40 | 40 |
| |
41 |
| - | |
| 41 | + | |
42 | 42 |
| |
43 |
| - | |
44 |
| - | |
45 |
| - | |
46 | 43 |
| |
47 | 44 |
| |
48 | 45 |
| |
49 | 46 |
| |
50 | 47 |
| |
51 | 48 |
| |
52 | 49 |
| |
53 |
| - | |
| 50 | + | |
54 | 51 |
| |
55 | 52 |
| |
56 | 53 |
| |
| |||
308 | 305 |
| |
309 | 306 |
| |
310 | 307 |
| |
311 |
| - | |
| 308 | + | |
312 | 309 |
| |
313 | 310 |
| |
314 | 311 |
| |
| |||
500 | 497 |
| |
501 | 498 |
| |
502 | 499 |
| |
503 |
| - | |
504 |
| - | |
505 |
| - | |
506 |
| - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
507 | 505 |
| |
508 | 506 |
| |
509 | 507 |
| |
| |||
657 | 655 |
| |
658 | 656 |
| |
659 | 657 |
| |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
660 | 669 |
| |
661 | 670 |
| |
662 | 671 |
| |
663 | 672 |
| |
664 | 673 |
| |
665 | 674 |
| |
666 | 675 |
| |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
667 | 688 |
| |
668 | 689 |
| |
669 | 690 |
| |
| |||
688 | 709 |
| |
689 | 710 |
| |
690 | 711 |
| |
691 |
| - | |
| 712 | + | |
692 | 713 |
| |
693 | 714 |
| |
694 |
| - | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
695 | 719 |
| |
696 | 720 |
| |
697 | 721 |
| |
|
Lines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
126 | 126 |
| |
127 | 127 |
| |
128 | 128 |
| |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
129 | 140 |
| |
130 | 141 |
| |
131 | 142 |
| |
|
Lines changed: 51 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
807 | 807 |
| |
808 | 808 |
| |
809 | 809 |
| |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + |
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 |
|
Lines changed: 24 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
489 | 489 |
| |
490 | 490 |
| |
491 | 491 |
| |
492 |
| - | |
| 492 | + | |
| 493 | + | |
493 | 494 |
| |
494 | 495 |
| |
495 | 496 |
| |
496 |
| - | |
| 497 | + | |
| 498 | + | |
497 | 499 |
| |
498 | 500 |
| |
499 | 501 |
| |
500 | 502 |
| |
501 |
| - | |
| 503 | + | |
| 504 | + | |
502 | 505 |
| |
503 | 506 |
| |
504 | 507 |
| |
| |||
558 | 561 |
| |
559 | 562 |
| |
560 | 563 |
| |
| 564 | + | |
| 565 | + | |
561 | 566 |
| |
562 | 567 |
| |
563 | 568 |
| |
| |||
570 | 575 |
| |
571 | 576 |
| |
572 | 577 |
| |
| 578 | + | |
573 | 579 |
| |
574 | 580 |
| |
575 | 581 |
| |
| |||
750 | 756 |
| |
751 | 757 |
| |
752 | 758 |
| |
753 |
| - | |
754 |
| - | |
755 |
| - | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
756 | 762 |
| |
757 |
| - | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
758 | 772 |
| |
759 | 773 |
| |
760 | 774 |
| |
| |||
2917 | 2931 |
| |
2918 | 2932 |
| |
2919 | 2933 |
| |
2920 |
| - | |
2921 |
| - | |
| 2934 | + | |
| 2935 | + | |
2922 | 2936 |
| |
2923 | 2937 |
| |
2924 | 2938 |
| |
| |||
3598 | 3612 |
| |
3599 | 3613 |
| |
3600 | 3614 |
| |
| 3615 | + | |
3601 | 3616 |
| |
3602 | 3617 |
| |
3603 | 3618 |
| |
|
0 commit comments
Comments
(0)