1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-22 17:42:17 +03:00

pg_dump et al: Add --if-exists option

This option makes pg_dump, pg_dumpall and pg_restore inject an IF EXISTS
clause to each DROP command they emit.  (In pg_dumpall, the clause is
not added to individual objects drops, but rather to the CREATE DATABASE
commands, as well as CREATE ROLE and CREATE TABLESPACE.)

This allows for a better user dump experience when using --clean in case
some objects do not already exist.  Per bug #7873 by Dave Rolsky.

Author: Pavel Stěhule
Reviewed-by: Jeevan Chalke, Álvaro Herrera, Josh Kupershmidt
This commit is contained in:
Alvaro Herrera
2014-03-03 15:02:18 -03:00
parent 34c6d9611d
commit 9067310cc5
8 changed files with 146 additions and 7 deletions

View File

@@ -145,7 +145,8 @@ PostgreSQL documentation
<para>
Output commands to clean (drop)
database objects prior to outputting the commands for creating them.
(Restore might generate some harmless error messages, if any objects
(Unless <option>--if-exists</> is also specified,
restore might generate some harmless error messages, if any objects
were not present in the destination database.)
</para>
@@ -649,6 +650,17 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>--if-exists</option></term>
<listitem>
<para>
Use conditional commands (i.e. add an <literal>IF EXISTS</literal>
clause) when cleaning database objects. This option is not valid
unless <option>--clean</> is also specified.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--disable-dollar-quoting</></term>
<listitem>

View File

@@ -300,6 +300,17 @@ PostgreSQL documentation
</listitem>
</varlistentry>
<varlistentry>
<term><option>--if-exists</option></term>
<listitem>
<para>
Use conditional commands (i.e. add an <literal>IF EXISTS</literal>
clause) to clean databases and other objects. This option is not valid
unless <option>--clean</> is also specified.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--inserts</option></term>
<listitem>

View File

@@ -109,7 +109,8 @@
<listitem>
<para>
Clean (drop) database objects before recreating them.
(This might generate some harmless error messages, if any objects
(Unless <option>--if-exists</> is used,
this might generate some harmless error messages, if any objects
were not present in the destination database.)
</para>
</listitem>
@@ -489,6 +490,17 @@
</listitem>
</varlistentry>
<varlistentry>
<term><option>--if-exists</option></term>
<listitem>
<para>
Use conditional commands (i.e. add an <literal>IF EXISTS</literal>
clause) when cleaning database objects. This option is not valid
unless <option>--clean</> is also specified.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--no-data-for-failed-tables</option></term>
<listitem>