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

Commit 3a819b0

Browse files
committed
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.
1 parent 6458022 commit 3a819b0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.160 2009/01/05 16:54:36 tgl Exp $
18+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.161 2009/01/13 11:44:56 mha Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -146,6 +146,12 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
146146
*/
147147
if (ropt->create && ropt->dropSchema)
148148
die_horribly(AH, modulename, "-C and -c are incompatible options\n");
149+
/*
150+
* -1 is not compatible with -C, because we can't create a database
151+
* inside a transaction block.
152+
*/
153+
if (ropt->create && ropt->single_txn)
154+
die_horribly(AH, modulename, "-C and -1 are incompatible options\n");
149155

150156
/*
151157
* If we're using a DB connection, then connect it.

0 commit comments

Comments
 (0)