| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Mahendra Singh Thalor <mahi6run(at)gmail(dot)com> |
| Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>, Vaibhav Dalvi <vaibhav(dot)dalvi(at)enterprisedb(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Non-text mode for pg_dumpall |
| Date: | 2026-02-21 02:15:44 |
| Message-ID: | CACJufxFs9NXXTeb78i2MD+pnZootayAtiGcNHNeU35SmQgMjbA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi.
RestoreOptions *tmpopts = (RestoreOptions *)
pg_malloc0(sizeof(RestoreOptions));
need change to
RestoreOptions *tmpopts = pg_malloc0_object(RestoreOptions);
+ <para>
+ If the dump was taken in a non-plain-text format, use
+ <application>pg_restore</application> to restore the databases:
+<screen>
+<prompt>$</prompt> <userinput>pg_restore db.out -d postgres -C</userinput>
+</screen>
+ This will restore all databases. To restore only some databases, use
+ the <option>--exclude-database</option> option to skip those not wanted.
+ </para>
The change above was added to pg_dumpall.sgml, which seems inappropriate;
it would be more correct to place it in pg_restore.sgml.
+ <varlistentry>
+ <term><option>-g</option></term>
+ <term><option>--globals-only</option></term>
+ <listitem>
+ <para>
+ Restore only global objects (roles and tablespaces), no databases.
+ </para>
+ <para>
+ This option is only relevant when restoring from an archive
made using <application>pg_dumpall</application>.
+ Note: <option>--globals-only</option> cannot be used with
<option>--exit-on-error</option>,
+ <option>--single-transaction</option>,
<option>--clean</option>, or <option>--transaction-size</option>.
+ </para>
+ </listitem>
+ </varlistentry>
+
<option>--globals-only</option> cannot be used with --data-only,
--schema-only, --statistics-only, --statistics.
We should also mention that.
In doc/src/sgml/ref/pg_restore.sgml
"when restoring from an archive made using pg_dumpall."
It would be better using
"when restoring from a non-plain-text archive made using pg_dumpall."
that would be aligned with pg_dumpall.sgml.
<varlistentry>
<term><option>-g</option></term>
<term><option>--globals-only</option></term>
<listitem>
<para>
Dump only global objects (roles and tablespaces), no databases.
+ Note: <option>--globals-only</option> cannot be used with
+ <option>--clean</option> with non-text dump format.
</para>
Elsewhere, we use the term “non-plain-text,” so we should use
“non-plain-text” here as well instead of “non-text,” for consistency.
In doc/src/sgml/ref/pg_restore.sgml, We did not mention that many
options cannot be used with pg_restore when performing a
non-plain-text restore.
Like:
"-l/--list"
"-L/--use-list"
"--strict-names"
"--no-schema"
"-a/--data-only"
"--statistics-only"
--section does not include "--pre-data"
pg_restore --clean --format=directory will produce DROP DATABASE will
process global objects,
it will also produce DROP DATABASE when processing each individual database.
To prevent errors during a subsequent restore, we can require
pg_restore --clean option must be used together with --if-exists when
restoring a non-plain-text dump.
| Attachment | Content-Type | Size |
|---|---|---|
| v17-0001-misc-review-for-v17.patch | text/x-patch | 7.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bertrand Drouvot | 2026-02-21 09:42:13 | Re: PGPROC alignment (was Re: pgsql: Separate RecoveryConflictReasons from procsignals) |
| Previous Message | John Naylor | 2026-02-21 01:49:32 | Re: refactor architecture-specific popcount code |