Re: Postgres Dump out of order - Mailing list pgsql-general

From Tom Lane
Subject Re: Postgres Dump out of order
Date
Msg-id 12482.1259765561@sss.pgh.pa.us
Whole thread Raw
In response to Re: Postgres Dump out of order  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
Craig Ringer <craig@postnewspapers.com.au> writes:
> On 2/12/2009 3:41 PM, silly8888 wrote:
>> pg_dump dumps data first and then the constraints (including FK) so
>> there shouldn't be any problems when you import the dump.

> ... assuming you're using a sufficiently recent version of pg_dump.
> Wasn't that added fairly recently?

Depends on context, which the OP provided none of.

pg_dump has handled FK dependencies -- even circular ones -- correctly
for a long time, given that you're doing a full schema+data dump.

If you ask it for a data-only dump, there is no way to handle circular
dependencies, so until recently it just threw up its hands and dumped
the tables in an arbitrary order.  Recent versions (I think probably
only 8.4.x) will order a data-only dump correctly for FK considerations
so long as there are no circular dependencies.

If you must use a data-only dump pre-8.4, I'd suggest using pg_restore's
-L switch to manually control the restore order.

            regards, tom lane

pgsql-general by date:

Previous
From: Sam Jas
Date:
Subject: Re: READ ONLY & I/O ERROR
Next
From: Tom Lane
Date:
Subject: Re: Roles with passwords; SET ROLE ... WITH PASSWORD ?