Re: BUG #6632: "before delete" triggers that delete rows from the same table can invalidate constraints

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ignas(at)pow(dot)lt
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6632: "before delete" triggers that delete rows from the same table can invalidate constraints
Date: 2012-05-07 15:06:10
Message-ID: 26030.1336403170@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

ignas(at)pow(dot)lt writes:
> [ you can sabotage foreign key constraints with triggers ]

This is not a bug, it's a "don't do that" issue. The only way to
prevent it would be to not fire triggers during FK operations, or
to somehow restrict what triggers are allowed to do, and either of
those cures would be worse than the disease.

In general, it's bad design to use a BEFORE trigger to propagate changes
to other rows; you should do that in AFTER triggers. See the
documentation.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Ignas Mikalajunas 2012-05-07 15:09:40 Re: BUG #6632: "before delete" triggers that delete rows from the same table can invalidate constraints
Previous Message ignas 2012-05-07 13:49:05 BUG #6632: "before delete" triggers that delete rows from the same table can invalidate constraints