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

From: Greg Stark <stark(at)mit(dot)edu>
To: m(dot)fritz(at)wisutec(dot)de
Cc: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #10856: Delete trigger corrupts foreign key integrity
Date: 2014-07-05 10:36:51
Message-ID: CAM-w4HOCxde9LV_j8ipvLSwojQQ-6Mf0Fy0U=J=CZqCOYxs13w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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. Child
> records are still present, master record is deleted but FOREIGN KEY is
still
> "VALID".

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

PostgreSQL's referential integrity is handled by triggers so it's possible
to escape their effects with other triggers.

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.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-07-05 14:46:06 Re: BUG #10856: Delete trigger corrupts foreign key integrity
Previous Message mysti 2014-07-04 13:50:33 Re: [BUG] Streaming replica sees the old max_connections value