Re: pg_dump behaves differently for different archive formats

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg_dump behaves differently for different archive formats
Date: 2013-12-16 13:16:55
Message-ID: 12902.1387199815@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> writes:
> Restoring a "plain format" dump and a "custom format" dump of
> the same database can lead to different results:

> pg_dump organizes the SQL statements it creates in "TOC entries".
> If a custom format dump is restored with pg_restore, all
> SQL statements in a TOC entry will be executed as a single command
> and thus in a single transaction.

Yeah, this is a bug I think. pg_dump was designed around the idea
that the output would be executed as a simple script, and in a
number of places there's an expectation that one SQL statement
can fail without affecting following ones. So if pg_restore can't
provide that behavior it's not good.

On the other hand, I'm not sure how much enthusiasm there'd be for
complex or fragile changes to fix this. A lot of people invariably
run restores in single-transaction mode and don't really care about
fault-tolerant restores. Also, it's easy enough to dodge the problem
if you must: just pipe the output into psql rather than
direct-to-database.

So to me the question is can we fix this without doing something like
duplicating psql's lexer? If we have to parse out the statements
contained in each text blob, it's probably going to be too painful.
Some cautionary history about this sort of thing can be read at
http://www.postgresql.org/message-id/flat/18006(dot)1325700782(at)sss(dot)pgh(dot)pa(dot)us

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eliott 2013-12-16 13:18:31 Re: Constantly increasing per connection memory usage on pg 9.2
Previous Message Albe Laurenz 2013-12-16 11:30:21 pg_dump behaves differently for different archive formats

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2013-12-16 13:21:56 Re: Heavily modified big table bloat even in auto vacuum is running
Previous Message Andres Freund 2013-12-16 12:25:52 Re: Useless "Replica Identity: NOTHING" noise from psql \d