Skip to content

Commit 7478766

Browse files
committed
Doc: improve description of dump/restore's --clean and --if-exists.
Try to make these option descriptions a little clearer for novices. Per gripe from Attila Gulyás. Discussion: https://postgr.es/m/169590536647.3727336.11070254203649648453@wrigleys.postgresql.org
1 parent 5db3c06 commit 7478766

File tree

3 files changed

+32
-20
lines changed

3 files changed

+32
-20
lines changed

doc/src/sgml/ref/pg_dump.sgml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,12 @@ PostgreSQL documentation
170170
<term><option>--clean</option></term>
171171
<listitem>
172172
<para>
173-
Output commands to clean (drop)
173+
Output commands to <command>DROP</command> all the dumped
174174
database objects prior to outputting the commands for creating them.
175-
(Unless <option>--if-exists</option> is also specified,
176-
restore might generate some harmless error messages, if any objects
177-
were not present in the destination database.)
175+
This option is useful when the restore is to overwrite an existing
176+
database. If any of the objects do not exist in the destination
177+
database, ignorable error messages will be reported during
178+
restore, unless <option>--if-exists</option> is also specified.
178179
</para>
179180

180181
<para>
@@ -760,9 +761,11 @@ PostgreSQL documentation
760761
<term><option>--if-exists</option></term>
761762
<listitem>
762763
<para>
763-
Use conditional commands (i.e., add an <literal>IF EXISTS</literal>
764-
clause) when cleaning database objects. This option is not valid
765-
unless <option>--clean</option> is also specified.
764+
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
765+
in <option>--clean</option> mode. This suppresses <quote>does not
766+
exist</quote> errors that might otherwise be reported. This
767+
option is not valid unless <option>--clean</option> is also
768+
specified.
766769
</para>
767770
</listitem>
768771
</varlistentry>

doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ PostgreSQL documentation
9090
<term><option>--clean</option></term>
9191
<listitem>
9292
<para>
93-
Include SQL commands to clean (drop) databases before
94-
recreating them. <command>DROP</command> commands for roles and
95-
tablespaces are added as well.
93+
Emit SQL commands to <command>DROP</command> all the dumped
94+
databases, roles, and tablespaces before recreating them.
95+
This option is useful when the restore is to overwrite an existing
96+
cluster. If any of the objects do not exist in the destination
97+
cluster, ignorable error messages will be reported during
98+
restore, unless <option>--if-exists</option> is also specified.
9699
</para>
97100
</listitem>
98101
</varlistentry>
@@ -323,9 +326,11 @@ PostgreSQL documentation
323326
<term><option>--if-exists</option></term>
324327
<listitem>
325328
<para>
326-
Use conditional commands (i.e., add an <literal>IF EXISTS</literal>
327-
clause) to drop databases and other objects. This option is not valid
328-
unless <option>--clean</option> is also specified.
329+
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
330+
in <option>--clean</option> mode. This suppresses <quote>does not
331+
exist</quote> errors that might otherwise be reported. This
332+
option is not valid unless <option>--clean</option> is also
333+
specified.
329334
</para>
330335
</listitem>
331336
</varlistentry>

doc/src/sgml/ref/pg_restore.sgml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ PostgreSQL documentation
111111
<term><option>--clean</option></term>
112112
<listitem>
113113
<para>
114-
Clean (drop) database objects before recreating them.
115-
(Unless <option>--if-exists</option> is used,
116-
this might generate some harmless error messages, if any objects
117-
were not present in the destination database.)
114+
Before restoring database objects, issue commands
115+
to <command>DROP</command> all the objects that will be restored.
116+
This option is useful for overwriting an existing database.
117+
If any of the objects do not exist in the destination database,
118+
ignorable error messages will be reported,
119+
unless <option>--if-exists</option> is also specified.
118120
</para>
119121
</listitem>
120122
</varlistentry>
@@ -575,9 +577,11 @@ PostgreSQL documentation
575577
<term><option>--if-exists</option></term>
576578
<listitem>
577579
<para>
578-
Use conditional commands (i.e., add an <literal>IF EXISTS</literal>
579-
clause) to drop database objects. This option is not valid
580-
unless <option>--clean</option> is also specified.
580+
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
581+
in <option>--clean</option> mode. This suppresses <quote>does not
582+
exist</quote> errors that might otherwise be reported. This
583+
option is not valid unless <option>--clean</option> is also
584+
specified.
581585
</para>
582586
</listitem>
583587
</varlistentry>

0 commit comments

Comments
 (0)