From: Magnus Hagander Date: Tue, 13 Jan 2009 11:45:01 +0000 (+0000) Subject: Throw an error when using -C and -1 at the same time in pg_restore. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=5b5f062f0c46dca28f4b51fc760e831a4c8ae467;p=users%2Fbernd%2Fpostgres.git Throw an error when using -C and -1 at the same time in pg_restore. It's not possible to do CREATE DATABASE inside a transaction, so previously we just got a server error instead. Backpatch to 8.2, which is where the -1 feature appeared. --- diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index f86faed6aa..304fde076e 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -147,6 +147,12 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) */ if (ropt->create && ropt->dropSchema) die_horribly(AH, modulename, "-C and -c are incompatible options\n"); + /* + * -1 is not compatible with -C, because we can't create a database + * inside a transaction block. + */ + if (ropt->create && ropt->single_txn) + die_horribly(AH, modulename, "-C and -1 are incompatible options\n"); /* * If we're using a DB connection, then connect it.