From: Andrew Dunstan Date: Mon, 15 Jun 2026 19:58:04 +0000 (-0400) Subject: Revert non-text output formats for pg_dumpall X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ca548f23a60887541493b2da47f2b2720c35ee3;p=thirdparty%2Fpostgresql.git Revert non-text output formats for pg_dumpall This reverts the non-text (custom/directory/tar) output format support for pg_dumpall added by 763aaa06f03 and its feature-specific follow-ups, in line with Noah Misch's post-commit review which recommends reverting and finishing the work through the commitfest. Scope is deliberately minimal: only the feature itself is removed. Independent improvements that merely touched the same files, or that were committed alongside the feature but do not depend on its design, are preserved. Reverted (the feature): 763aaa06f03 Add non-text output formats to pg_dumpall d6d9b96b404 Clean up nodes that are no longer of use in 007_pgdumpall.pl 01c729e0c7a Fix casting away const-ness in pg_restore.c c7572cd48d3 Improve writing map.dat preamble 3c19983cc08 pg_restore: add --no-globals option to skip globals abff4492d02 Fix options listing of pg_restore --no-globals bb53b8d359d Fix small memory leak in get_dbname_oid_list_from_mfile() a793677e57b pg_restore: Remove dead code in restore_all_databases() a198c26dede pg_dumpall: simplify coding of dropDBs() ec80215c033 pg_restore: Remove unnecessary strlen() calls in options parsing Preserved (independent of the feature): b2898baaf7e the check_mut_excl_opts() helper in src/fe_utils/option_utils.c and its use in pg_dump 7c8280eeb58 pg_dump's conflicting-option refactor (and tests 002/005) be0d0b457cb pg_dumpall's rejection of --clean together with --data-only (re-expressed directly, since pg_dumpall.c is otherwise returned to its pre-feature state) 74b4438a70b the dangling-grantor-OID GRANT fix (back-patched through 16) 273d26b75e7, d4cb9c37765 independent pg_restore.sgml clarifications Because the feature restructured pg_dumpall.c and pg_restore.c (pg_restore's main() was split into restore_one_database() plus a dispatcher) and interleaved its option checks with the conflicting-option refactor in the same regions, the cosmetic check_mut_excl_opts() reflow of those two files' option blocks is inseparable from the feature and comes out with it; the behavior is unchanged. The reusable helper and pg_dump's use of it are unaffected. Discussion: https://postgr.es/m/20260607000218.96.noahmisch@microsoft.com --- diff --git a/doc/src/sgml/ref/pg_dumpall.sgml b/doc/src/sgml/ref/pg_dumpall.sgml index 51c70198091..8834b7ec141 100644 --- a/doc/src/sgml/ref/pg_dumpall.sgml +++ b/doc/src/sgml/ref/pg_dumpall.sgml @@ -16,10 +16,7 @@ PostgreSQL documentation pg_dumpall - - - export a PostgreSQL database cluster as an SQL script or to other formats - + extract a PostgreSQL database cluster into a script file @@ -36,33 +33,14 @@ PostgreSQL documentation pg_dumpall is a utility for writing out (dumping) all PostgreSQL databases - of a cluster into an SQL script file or an archive. It does this by + of a cluster into one script file. The script file contains + SQL commands that can be used as input to to restore the databases. It does this by calling for each database in the cluster. - The output contains SQL commands that can be used - as input to or - to restore the databases. pg_dumpall also dumps global objects that are common to all databases, namely database roles, tablespaces, and privilege grants for configuration parameters. (pg_dump does not save these objects.) - The only parts of a database cluster's state that - are not included in the default output - of pg_dumpall are the configuration files - and any database parameter setting changes made with - . - - - - If the output format is a - plain text SQL script, it will be written to the standard output. Use the - / option or shell operators to - redirect it into a file. - - - - If another output format is selected, the archive will be placed in a - directory named using the / - option, which is required in this case. @@ -73,6 +51,12 @@ PostgreSQL documentation allowed to add roles and create databases. + + The SQL script will be written to the standard output. Use the + / option or shell operators to + redirect it into a file. + + pg_dumpall needs to connect several times to the PostgreSQL server (once per @@ -147,93 +131,16 @@ PostgreSQL documentation Send output to the specified file. If this is omitted, the standard output is used. - This option can only be omitted when is plain. - - - - - - Specify the format of dump files. In plain format, all the dump data is - sent in a single text stream. This is the default. - - In all other modes, pg_dumpall first creates two files, - toc.glo and map.dat, in the directory - specified by . - The first file contains global data (roles and tablespaces) in custom format. The second - contains a mapping between database OIDs and names. These files are used by - pg_restore. Data for individual databases is placed in - the databases subdirectory, named using the database's OID. - - - - d - directory - - - Output directory-format archives for each database, - suitable for input into pg_restore. The directory - will have database oid as its name. - - - - - - p - plain - - - Output a plain-text SQL script file (the default). - - - - - - c - custom - - - Output a custom-format archive for each database, - suitable for input into pg_restore. The archive - will be named dboid.dmp where dboid is the - oid of the database. - - - - - - t - tar - - - Output a tar-format archive for each database, - suitable for input into pg_restore. The archive - will be named dboid.tar where dboid is the - oid of the database. - - - - - - - See for details on how the - various non-plain-text archive formats work. - - - - - Dump only global objects (roles and tablespaces), no databases. - Note: cannot be used with - with non-text dump format. @@ -1029,18 +936,10 @@ exclude database PATTERN Examples - To dump all databases in plain text format (the default): - -$ pg_dumpall > db.out - - + To dump all databases: - - To dump all databases using other formats: -$ pg_dumpall --format=directory -f db.out -$ pg_dumpall --format=custom -f db.out -$ pg_dumpall --format=tar -f db.out +$ pg_dumpall > db.out @@ -1057,16 +956,6 @@ exclude database PATTERN the script will attempt to drop other databases immediately, and that will fail for the database you are connected to. - - - If the dump was taken in a non-plain-text format, use - pg_restore to restore the databases: - -$ pg_restore db.out -d postgres -C - - This will restore all databases. To restore only some databases, use - the option to skip those not wanted. - diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml index 5e77ddd556f..b6c5299c36e 100644 --- a/doc/src/sgml/ref/pg_restore.sgml +++ b/doc/src/sgml/ref/pg_restore.sgml @@ -18,9 +18,8 @@ PostgreSQL documentation pg_restore - restore PostgreSQL databases from archives - created by pg_dump or - pg_dumpall + restore a PostgreSQL database from an + archive file created by pg_dump @@ -39,14 +38,13 @@ PostgreSQL documentation pg_restore is a utility for restoring a - PostgreSQL database or cluster from an archive - created by or - in one of the non-plain-text + PostgreSQL database from an archive + created by in one of the non-plain-text formats. It will issue the commands necessary to reconstruct the - database or cluster to the state it was in at the time it was saved. The - archives also allow pg_restore to + database to the state it was in at the time it was saved. The + archive files also allow pg_restore to be selective about what is restored, or even to reorder the items - prior to being restored. The archive formats are designed to be + prior to being restored. The archive files are designed to be portable across architectures. @@ -54,34 +52,14 @@ PostgreSQL documentation pg_restore can operate in two modes. If a database name is specified, pg_restore connects to that database and restores archive contents directly into - the database. - When restoring from a dump made by pg_dumpall, - each database will be created and then the restoration will be run in that - database. - - Otherwise, when a database name is not specified, a script containing the SQL - commands necessary to rebuild the database or cluster is created and written + the database. Otherwise, a script containing the SQL + commands necessary to rebuild the database is created and written to a file or standard output. This script output is equivalent to - the plain text output format of pg_dump or - pg_dumpall. - + the plain text output format of pg_dump. Some of the options controlling the output are therefore analogous to pg_dump options. - - A non-plain-text archive made using pg_dumpall - is a directory containing a toc.glo file with global - objects (roles and tablespaces), a map.dat file - listing the databases, and a subdirectory for each database containing - its archive. When restoring such an archive, - pg_restore first restores global objects from - toc.glo, then processes each database listed in - map.dat. Lines in map.dat can - be commented out with # to skip restoring specific - databases. - - Obviously, pg_restore cannot restore information that is not present in the archive file. For instance, if the @@ -152,12 +130,6 @@ PostgreSQL documentation ignorable error messages will be reported, unless is also specified. - - When restoring a pg_dumpall archive, - is implied by , - since global objects such as roles and tablespaces may not exist - in the target cluster. - @@ -180,8 +152,6 @@ PostgreSQL documentation commands that mention this database. Access privileges for the database itself are also restored, unless is specified. - is required when restoring multiple databases - from a non-plain-text archive made using pg_dumpall. @@ -282,29 +252,6 @@ PostgreSQL documentation - - - - - - Restore only global objects (roles and tablespaces), no databases. - - - This option is only relevant when restoring from a non-plain-text archive made using pg_dumpall. - Note: cannot be used with - , - , - , - , - , - , - , - , or - . - - - - @@ -641,28 +588,6 @@ PostgreSQL documentation - - - - - Do not restore databases whose name matches - pattern. - Multiple patterns can be excluded by writing multiple - switches. The - pattern parameter is - interpreted as a pattern according to the same rules used by - psql's \d - commands (see ), - so multiple databases can also be excluded by writing wildcard - characters in the pattern. When using wildcards, be careful to - quote the pattern if needed to prevent shell wildcard expansion. - - - This option is only relevant when restoring from a non-plain-text archive made using pg_dumpall. - - - - @@ -751,9 +676,7 @@ PostgreSQL documentation in mode. This suppresses does not exist errors that might otherwise be reported. This option is not valid unless is also - specified. This option is implied when restoring a - pg_dumpall archive with - . + specified. @@ -800,21 +723,6 @@ PostgreSQL documentation - - - - - Do not restore global objects (roles and tablespaces). When - / is not specified, - databases that do not already exist on the target server are skipped. - - - This option is only relevant when restoring from a non-plain-text - archive made using pg_dumpall. - - - - @@ -1240,21 +1148,6 @@ CREATE DATABASE foo WITH TEMPLATE template0; - - - The following options cannot be used when restoring from a non-plain-text - archive made using pg_dumpall: - , - , - , - , - , and - . - Also, if the option is used, it must - include . - - - diff --git a/doc/src/sgml/release-19.sgml b/doc/src/sgml/release-19.sgml index 35adc534a7b..7c73cba11b7 100644 --- a/doc/src/sgml/release-19.sgml +++ b/doc/src/sgml/release-19.sgml @@ -2688,25 +2688,6 @@ Report nanoseconds instead of microseconds. In addition to histogram output, ou linkend="app-pgrestore">pg_restore - - - - -Allow pg_dumpall to produce output in non-text formats (Mahendra Singh Thalor, Andrew Dunstan) -§ -§ - - - -The new output formats are custom, directory, or tar. - - -