Re: Non-text mode for pg_dumpall - Mailing list pgsql-hackers

From jian he
Subject Re: Non-text mode for pg_dumpall
Date
Msg-id CACJufxFs9NXXTeb78i2MD+pnZootayAtiGcNHNeU35SmQgMjbA@mail.gmail.com
Whole thread Raw
In response to Re: Non-text mode for pg_dumpall  (Mahendra Singh Thalor <mahi6run@gmail.com>)
Responses Re: Non-text mode for pg_dumpall
List 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.



--
jian
https://www.enterprisedb.com

Attachment

pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: refactor architecture-specific popcount code
Next
From: Bertrand Drouvot
Date:
Subject: Re: PGPROC alignment (was Re: pgsql: Separate RecoveryConflictReasons from procsignals)