Skip to content

Commit f9cbff4

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 750beed commit f9cbff4

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>
@@ -763,9 +764,11 @@ PostgreSQL documentation
763764
<term><option>--if-exists</option></term>
764765
<listitem>
765766
<para>
766-
Use conditional commands (i.e., add an <literal>IF EXISTS</literal>
767-
clause) when cleaning database objects. This option is not valid
768-
unless <option>--clean</option> is also specified.
767+
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
768+
in <option>--clean</option> mode. This suppresses <quote>does not
769+
exist</quote> errors that might otherwise be reported. This
770+
option is not valid unless <option>--clean</option> is also
771+
specified.
769772
</para>
770773
</listitem>
771774
</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>
@@ -305,9 +308,11 @@ PostgreSQL documentation
305308
<term><option>--if-exists</option></term>
306309
<listitem>
307310
<para>
308-
Use conditional commands (i.e., add an <literal>IF EXISTS</literal>
309-
clause) to drop databases and other objects. This option is not valid
310-
unless <option>--clean</option> is also specified.
311+
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
312+
in <option>--clean</option> mode. This suppresses <quote>does not
313+
exist</quote> errors that might otherwise be reported. This
314+
option is not valid unless <option>--clean</option> is also
315+
specified.
311316
</para>
312317
</listitem>
313318
</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>
@@ -574,9 +576,11 @@ PostgreSQL documentation
574576
<term><option>--if-exists</option></term>
575577
<listitem>
576578
<para>
577-
Use conditional commands (i.e., add an <literal>IF EXISTS</literal>
578-
clause) to drop database objects. This option is not valid
579-
unless <option>--clean</option> is also specified.
579+
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
580+
in <option>--clean</option> mode. This suppresses <quote>does not
581+
exist</quote> errors that might otherwise be reported. This
582+
option is not valid unless <option>--clean</option> is also
583+
specified.
580584
</para>
581585
</listitem>
582586
</varlistentry>

0 commit comments

Comments
 (0)