Re: BUG #4396: Trigger event fired "UPDATE" when "DELETE" happening via foreign key - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #4396: Trigger event fired "UPDATE" when "DELETE" happening via foreign key
Date
Msg-id 26811.1220461733@sss.pgh.pa.us
Whole thread Raw
In response to BUG #4396: Trigger event fired "UPDATE" when "DELETE" happening via foreign key  ("Stephen Cuppett" <stephen.cuppett@sas.com>)
Responses Re: BUG #4396: Trigger event fired "UPDATE" when "DELETE" happening via foreign key
List pgsql-bugs
Stephen Cuppett <Stephen.Cuppett@sas.com> writes:
> When A is deleted, B is deleted, E is set null.  Then, D is deleted and E is deleted.

> FOR EVERY ROW AFTER UPDATE is run on E for rows that no longer exist.

> Not sure if that's a bug or not... not sure it would be undesirable under conditions for that not to run for those
tuplesthat are already gone. 

Well, not firing the trigger would be pretty bad in some cases too.  For
instance if you're trying to log updates in a history table, you'd not
want to miss updates just because they were immediately obsoleted.

Looking again at your example, that's exactly what your trigger is
doing, isn't it?  Why in the world has your history table got an FK
back to the live tables?  That presumes that you'll never delete any
objects ... or that you're willing to lose all history about them
as soon as they're deleted, which seems a pretty odd choice.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4397: crash in tab-complete.c
Next
From: Stephen Cuppett
Date:
Subject: Re: BUG #4396: Trigger event fired "UPDATE" when "DELETE" happening via foreign key