Re: Postgres Dump out of order

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: silly8888 <silly8888(at)gmail(dot)com>, Helio Campos Mello de Andrade <helio(dot)campos(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Postgres Dump out of order
Date: 2009-12-02 14:52:41
Message-ID: 12482.1259765561@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Craig Ringer <craig(at)postnewspapers(dot)com(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-12-02 15:04:42 Re: Roles with passwords; SET ROLE ... WITH PASSWORD ?
Previous Message Sam Jas 2009-12-02 14:51:29 Re: READ ONLY & I/O ERROR