Proposed patch: make pg_dump --data-only consider FK constraints

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Proposed patch: make pg_dump --data-only consider FK constraints
Date: 2008-09-07 18:06:40
Message-ID: 17451.1220810800@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Okay, I got tired of seeing people complain about foreign-key constraint
violations in data-only dumps. While it's true that the problem can't
be solved in the general case (because of potentially circular
references), we could certainly make pg_dump at least *try* to order the
tables according to foreign key relationships. It turns out not to even
require a whole lot of new code. Accordingly I propose the attached
patch. It will order the tables safely if it can, and otherwise
complain like this:

pg_dump: WARNING: circular foreign-key constraints among these table(s):
pg_dump: master
pg_dump: child
pg_dump: You may not be able to restore the dump without using --disable-triggers or temporarily dropping the constraints.

Comments?

regards, tom lane

Attachment Content-Type Size
unknown_filename text/plain 8.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2008-09-07 18:50:56 Re: Proposed patch: make pg_dump --data-only consider FK constraints
Previous Message Dimitri Fontaine 2008-09-07 18:02:51 Re: reducing statistics write overhead