Re: BUG #2308: pg_dump -a does not respect referential dependencies - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #2308: pg_dump -a does not respect referential dependencies
Date
Msg-id 17723.1141851690@sss.pgh.pa.us
Whole thread Raw
In response to BUG #2308: pg_dump -a does not respect referential dependencies  ("Matthew George" <georgema@corp.earthlink.net>)
Responses Re: BUG #2308: pg_dump -a does not respect referential dependencies  (Jim Nasby <decibel@decibel.org>)
List pgsql-bugs
"Matthew George" <georgema@corp.earthlink.net> writes:
> Since the logic obviously exists within pg_dump already to arrange the data
> in the correct order of reference dependencies, can this be added to the
> code path for `pg_dump -a` as well?

No.  In a data-only restore there may not be *any* ordering that works
--- consider circular dependencies.

The best practice is to do standard schema+data dumps, wherein the
ordering problem can be handled properly by not creating the FK
constraints until after the data is loaded.  If you really want to
do a data-only restore, I'd suggest dropping the FK constraints
and re-adding them afterwards (which will be a lot faster than
row-by-row retail checks would be, anyway).

Another possibility is the --disable-triggers option, but I can't
really recommend that, because if there are any referential problems
in the data you load, that way will fail to catch it.

            regards, tom lane

pgsql-bugs by date:

Previous
From: John R Pierce
Date:
Subject: Re: BUG #2305: "No bufferspace available" error on large insert
Next
From: Tom Lane
Date:
Subject: Re: BUG #2307: Buckup and sequences in DEFAULT part