pg_dump behaves differently for different archive formats - Mailing list pgsql-general

From Albe Laurenz
Subject pg_dump behaves differently for different archive formats
Date
Msg-id A737B7A37273E048B164557ADEF4A58B17C83B67@ntex2010i.host.magwien.gv.at
Whole thread Raw
Responses Re: pg_dump behaves differently for different archive formats  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
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

pgsql-general by date:

Previous
From: Vincent Veyron
Date:
Subject: Re: Some good news ([info@arin.net: [arin-announce] ARIN Database Migration Completed])
Next
From: Tom Lane
Date:
Subject: Re: pg_dump behaves differently for different archive formats