Re: BUG #10856: Delete trigger corrupts foreign key integrity

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <stark(at)mit(dot)edu>
Cc: m(dot)fritz(at)wisutec(dot)de, PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #10856: Delete trigger corrupts foreign key integrity
Date: 2014-07-05 14:46:06
Message-ID: 1815.1404571566@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Greg Stark <stark(at)mit(dot)edu> writes:
> On 5 Jul 2014 06:58, <m(dot)fritz(at)wisutec(dot)de> wrote:
>> A "before delete" trigger on a child table returning "NULL" prevents records
>> from deletion, which violates against the FOREIGN KEY constraint.

> Yup, don't do that. I bellringer there are warnings to this effect in the
> documentation.

> We could implement them internally without using triggers but there are
> other advantages to using triggers and so far the feeling is that the
> development effort is better spent elsewhere.

More to the point, if FK actions did not fire triggers, that would be a
significant loss of functionality. There are plenty of applications
wherein you'd like to have that, for example for logging purposes.
So our choice is that user-written triggers are fired and it's up to
you that they not break FK changes.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message rameshparnanditech 2014-07-05 15:04:43 BUG #10870: digest crypto function
Previous Message Greg Stark 2014-07-05 10:36:51 Re: BUG #10856: Delete trigger corrupts foreign key integrity