Re: pg_restore and create FK without verification check - Mailing list pgsql-hackers

From Greg Stark
Subject Re: pg_restore and create FK without verification check
Date
Msg-id 87ptffvy95.fsf@stark.dyndns.tv
Whole thread Raw
In response to Re: pg_restore and create FK without verification check  (ow <oneway_111@yahoo.com>)
Responses Re: pg_restore and create FK without verification check  (Andreas Pflug <pgadmin@pse-consulting.de>)
List pgsql-hackers
ow <oneway_111@yahoo.com> writes:

> --- Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Quite honestly, I think they should check their foreign keys.

What should I do if I *know* there will be a FK failure but I want to correct
it manually. Perhaps by creating all the necessary target records, perhaps by
deleting or updating the dead references. Perhaps with a mix of these.

As it stands I have to delete the FK constraint, load the table, and fix the
data. Then recreate the FK constraint -- with the danger that I'll get the
definition wrong -- and wait for the constraint to be verified.

If I could disable and reenable the constraint the danger that I would get the
definition wrong would be eliminated. And if I had already done the work to
ensure there were no broken relationships I would optionally be able to skip
the redundant automatic check. I could even have done the verification myself
while the data wasn't live for example.

The database is a tool. It's annoying to have a tool that tries to outsmart
the user.

-- 
greg



pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: Materialized views proposal
Next
From: Andreas Pflug
Date:
Subject: Re: pg_restore and create FK without verification check