Re: Adding foreign key constraints without integrity check?

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Wes <wespvp(at)syntegra(dot)com>
Cc: louis gonzales <gonzales(at)linuxlouis(dot)net>, pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Adding foreign key constraints without integrity check?
Date: 2006-06-21 01:17:23
Message-ID: 44989E23.2030802@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Wes wrote:
> On 6/20/06 5:07 AM, "Florian G. Pflug" <fgp(at)phlo(dot)org> wrote:
>
>> My suggestion was to create the fk _before_ loading the data, and disable it
>> similarly to what "--disable-triggers" doest. It turned out, however, that a
>> FK always depends on a unique index (be it a primary key, or not), which
>> prevents
>> my plan from working :-(
>
> That was a great idea - too bad it didn't pan out.
>
> I don't suppose there's any (reasonable) way to directly insert into the
> system tables to create the constraint? I could knock almost 2 days off of
> the almost 4 days to reload if I could solve this.

I believe that it's possible, but it's hard to get right. A foreign key
consists of at least
.) The actual definition in pg_constraints or so
.) A trigger
.) Various reconds in pg_depend

To be on the safe side, you'd need to look at the sourcecode, and miminc
what is done there.

Maybe you could ask at some postgresql support companies how much effort it would
be to add a "without check" flag to "alter table add constraint foreign key", and
how much they'd charge for it...

greetings, Florian Pflug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Qingqing Zhou 2006-06-21 01:49:21 Re: simple query terminated by signal 11
Previous Message Michael Fuhr 2006-06-20 22:32:20 Re: Help requd in writing functions in C and using in Postgres