pg_dump et al: Add --if-exists option

Enterprise / PostgreSQL - Alvaro Herrera [alvh.no-ip.org] - 3 March 2014 12:02 UTC

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

9067310 pg_dump et al: Add --if-exists option
doc/src/sgml/ref/pg_dump.sgml | 14 ++++++-
doc/src/sgml/ref/pg_dumpall.sgml | 11 +++++
doc/src/sgml/ref/pg_restore.sgml | 14 ++++++-
src/bin/pg_dump/pg_backup.h | 1 +
src/bin/pg_dump/pg_backup_archiver.c | 73 +++++++++++++++++++++++++++++++++-
src/bin/pg_dump/pg_dump.c | 7 ++++
src/bin/pg_dump/pg_dumpall.c | 22 ++++++++--
src/bin/pg_dump/pg_restore.c | 11 +++++
8 files changed, 146 insertions(+), 7 deletions(-)

Upstream: git.postgresql.org


  • Share