]> granicus.if.org Git - postgresql/commitdiff
Throw an error when using -C and -1 at the same time in pg_restore.
authorMagnus Hagander <magnus@hagander.net>
Tue, 13 Jan 2009 11:44:56 +0000 (11:44 +0000)
committerMagnus Hagander <magnus@hagander.net>
Tue, 13 Jan 2009 11:44:56 +0000 (11:44 +0000)
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.

src/bin/pg_dump/pg_backup_archiver.c

index 9153604edc63d7b0b8e95b3524c8ba121708f676..9d877cb2d32b42cbcee188825d63cd392ffd4616 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *             $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.160 2009/01/05 16:54:36 tgl Exp $
+ *             $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.161 2009/01/13 11:44:56 mha Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -146,6 +146,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.