Re: Trigger triggered from a foreign key - Mailing list pgsql-sql

From David Johnston
Subject Re: Trigger triggered from a foreign key
Date
Msg-id 032401cdae27$0199b2e0$04cd18a0$@yahoo.com
Whole thread Raw
In response to Trigger triggered from a foreign key  (Victor Sterpu <victor@caido.ro>)
List pgsql-sql
> -----Original Message-----
> From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-
> owner@postgresql.org] On Behalf Of Victor Sterpu
> Sent: Friday, October 19, 2012 2:15 PM
> To: pgsql-sql@postgresql.org
> Subject: [SQL] Trigger triggered from a foreign key
> 
> I have this trigger that works fine. The trigger prevents the deletion of
the
> last record.
> But I want skip this trigger execution when the delete is done from a
external
> key.
> How can I do this?
> 

I do not think this is possible; there is no "stack" context to examine to
determine how a DELETE was issued.

The trigger itself would seem to be possibly exhibit concurrency issues,
meaning that in certain circumstances the last record could be deleted.  You
may want to add explicit locking to avoid that possibility.  That or figure
out a better way to accomplish whatever it is you are trying to do.

David J.





pgsql-sql by date:

Previous
From: Victor Sterpu
Date:
Subject: Trigger triggered from a foreign key
Next
From: lmagnell
Date:
Subject: Insert strings that contain colons into a table