Re: ALTER TABLE ... ADD FOREIGN KEY ... NOT ENFORCED

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <simon(at)2ndQuadrant(dot)com>,<tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <cbbrowne(at)acm(dot)org>,<pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER TABLE ... ADD FOREIGN KEY ... NOT ENFORCED
Date: 2011-01-24 01:16:00
Message-ID: 4D3C7E700200002500039A94@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:

> I seem to recall pointing out upthread that the FK check triggers
> are designed on the assumption that the constraint does hold
> currently. Has any analysis been done on exactly how badly they'll
> fail when it doesn't hold? I remain unconvinced that this behavior
> is desirable.

I saw your upstream comment, and it took a quick look at it. On the
face of it, I couldn't see where checking that the parent exists on
the insert of a child would be broken by the existence of other
orphan children, nor could I see where checking for the absence of
children on the delete of a parent would be broken by orphan children
not related to the parent. With other things on my plate I didn't
have time to do a rigorous check, but it was enough to make me wonder
what you think depends on existing consistency or what could break.
Even a vague hint of what sort of thing you think might go wrong
might help people find problem code, if it actually exists.

Now, I understand that a broken index, like one based on a function
declared immutable which really isn't, could cause problems, but that
seems orthogonal.

-Kevin

Browse pgsql-hackers by date

  From Date Subject
Next Message Itagaki Takahiro 2011-01-24 01:42:35 add __attribute__((noreturn)) to suppress a waring
Previous Message Nate C 2011-01-24 01:01:09 Bug? Unexpected argument handling in pl-python variadic argument function