Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 75af0f4

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 ccd42ca commit 75af0f4

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>
@@ -839,9 +840,11 @@ PostgreSQL documentation
839840
<term><option>--if-exists</option></term>
840841
<listitem>
841842
<para>
842-
Use conditional commands (i.e., add an <literal>IF EXISTS</literal>
843-
clause) when cleaning database objects. This option is not valid
844-
unless <option>--clean</option> is also specified.
843+
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
844+
in <option>--clean</option> mode. This suppresses <quote>does not
845+
exist</quote> errors that might otherwise be reported. This
846+
option is not valid unless <option>--clean</option> is also
847+
specified.
845848
</para>
846849
</listitem>
847850
</varlistentry>

doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,12 @@ PostgreSQL documentation
9191
<term><option>--clean</option></term>
9292
<listitem>
9393
<para>
94-
Include SQL commands to clean (drop) databases before
95-
recreating them. <command>DROP</command> commands for roles and
96-
tablespaces are added as well.
94+
Emit SQL commands to <command>DROP</command> all the dumped
95+
databases, roles, and tablespaces before recreating them.
96+
This option is useful when the restore is to overwrite an existing
97+
cluster. If any of the objects do not exist in the destination
98+
cluster, ignorable error messages will be reported during
99+
restore, unless <option>--if-exists</option> is also specified.
97100
</para>
98101
</listitem>
99102
</varlistentry>
@@ -324,9 +327,11 @@ PostgreSQL documentation
324327
<term><option>--if-exists</option></term>
325328
<listitem>
326329
<para>
327-
Use conditional commands (i.e., add an <literal>IF EXISTS</literal>
328-
clause) to drop databases and other objects. This option is not valid
329-
unless <option>--clean</option> is also specified.
330+
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
331+
in <option>--clean</option> mode. This suppresses <quote>does not
332+
exist</quote> errors that might otherwise be reported. This
333+
option is not valid unless <option>--clean</option> is also
334+
specified.
330335
</para>
331336
</listitem>
332337
</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>
@@ -580,9 +582,11 @@ PostgreSQL documentation
580582
<term><option>--if-exists</option></term>
581583
<listitem>
582584
<para>
583-
Use conditional commands (i.e., add an <literal>IF EXISTS</literal>
584-
clause) to drop database objects. This option is not valid
585-
unless <option>--clean</option> is also specified.
585+
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
586+
in <option>--clean</option> mode. This suppresses <quote>does not
587+
exist</quote> errors that might otherwise be reported. This
588+
option is not valid unless <option>--clean</option> is also
589+
specified.
586590
</para>
587591
</listitem>
588592
</varlistentry>

0 commit comments

Comments
 (0)