pg_restore -1 vs -C and -c

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_restore -1 vs -C and -c
Date: 2009-01-12 16:09:36
Message-ID: 496B6B40.1010909@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

As I think has been previously noted, using pg_restore with -1 (single
transaction) is fundamentally incompatible with -C (we can't CREATE
DATABASE inside a transaction) and often incompatible with -c (we don't
do DROP IF EXISTS, so if the objects don't exist the entire restore will
fail). It does work with -c *sometimes*.

It should be possible to make it compatible with -C by moving the CREATE
DATABASE command to outside of the transaction. I have only had a quick
look at the code wrt how much work this would be. One thing that hit me
quickly: do we support multiple CREATE DATABASE statements in a single
dump file? I think not, but the format seems to allow it? If not, it
should be "fairly simple" to do.

As for -c, the solution would be to issue DROP IF EXISTS statements. Is
there any particular reason why we don't?

Finally, attached is a patch that throws a nicer error message when -C
and -1 is used together, since they're fundamentally incompatible. This
one would also be backpatchable even if we fix the above.

Comments?

//Magnus

Attachment Content-Type Size
pg_restore.diff text/x-diff 608 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2009-01-12 16:11:20 Re: Recovery Test Framework
Previous Message Guillaume Smet 2009-01-12 16:07:08 Re: Recovery Test Framework