Re: BUG #14114: FK on-delete-cascade trouble

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: zha-vova(at)yandex(dot)ru
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14114: FK on-delete-cascade trouble
Date: 2016-04-26 14:18:47
Message-ID: 27918.1461680327@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

zha-vova(at)yandex(dot)ru writes:
> After creating a FK constraint with "on delete cascade" option I got a
> problem with before-delete-trigger on a dependent table. This short listing
> below will make it clear:

This is not a bug, this is expected behavior. If you have a trigger that
interferes with the updates commanded by a foreign key cascade query,
you'll break the integrity of the FK. The only way we could prevent that
is to not run triggers for FK cascade updates; which is a cure worse than
the disease, since there are plenty of legitimate reasons why you'd want
a table's triggers to fire.

Write your triggers more carefully.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message andreas.schmidt1982 2016-04-26 15:27:31 BUG #14115: PostgreSQL stopped listening to ip address
Previous Message John Lumby 2016-04-26 13:37:38 Re: BUG #14109: pg_rewind fails to update target control file in one scenario