From: Tom Lane Date: Tue, 23 Oct 2001 21:26:44 +0000 (+0000) Subject: Forbid the switch combination --clean --create, which is pointless X-Git-Tag: REL7_2_BETA1~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b662e321c5e4e4ac71a252895948a057f8356776;p=postgresql Forbid the switch combination --clean --create, which is pointless (why bother dropping individual objects in a just-created database?) as well as dangerous (as the code stands, the drops will be issued in the wrong database, namely the one you were originally connected to). --- diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 0e7cba50a1..55bbddec9b 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.33 2001/09/21 21:58:30 petere Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.34 2001/10/23 21:26:44 tgl Exp $ * * Modifications - 28-Jun-2000 - pjw@rhyme.com.au * @@ -162,9 +162,20 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) AH->ropt = ropt; + /* + * Check for nonsensical option combinations. + * + * NB: create+dropSchema is useless because if you're creating the DB, + * there's no need to drop individual items in it. Moreover, if we + * tried to do that then we'd issue the drops in the database initially + * connected to, not the one we will create, which is very bad... + */ if (ropt->create && ropt->noReconnect) die_horribly(AH, modulename, "-C and -R are incompatible options\n"); + if (ropt->create && ropt->dropSchema) + die_horribly(AH, modulename, "-C and -c are incompatible options\n"); + /* * If we're using a DB connection, then connect it. */