pg_dump behaves differently for different archive formats

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: pg_dump behaves differently for different archive formats
Date: 2013-12-16 11:30:21
Message-ID: A737B7A37273E048B164557ADEF4A58B17C83B67@ntex2010i.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

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.
On the other hand, each SQL statement in a plain format dump
is executed individually in its own transaction, and TOC entries
are irrelevant (except as comments for documentation).

E.g., if a table has ACL entries for several roles and one of
them is not present in the destination database, a plain format
dump will restore all privileges except the ones that pertain
to the missing user, while a custom format dump will not restore
any privileges even for existing users.
This is because all ACL related statements are in one TOC entry.

Another example is a table that you try to restore into a database
where the original table owner does not exist.
With a plain format dump, the table is created, but will belong
to the user restoring the dump, while a custom format dump will
not create the table at all.
This is because CREATE TABLE and ALTER TABLE ... OWNER TO
are in the same TOC entry.

One can argue for or against each individual behaviour, but I
am surprised by the difference.

Is there a deeper reason why it should remain like this or should
I consider it a bug that should get fixed?

Yours,
Laurenz Albe

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-12-16 13:16:55 Re: pg_dump behaves differently for different archive formats
Previous Message Hungerbühler Philipp (hune) 2013-12-16 10:24:19 Postgres SQL 8.4 regularly craches

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-12-16 12:18:49 Re: [PATCH] Negative Transition Aggregate Functions (WIP)
Previous Message Heikki Linnakangas 2013-12-16 11:30:13 Re: GIN improvements part 1: additional information