Re: Trigger triggered from a foreign key

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Victor Sterpu'" <victor(at)caido(dot)ro>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Trigger triggered from a foreign key
Date: 2012-10-19 18:24:41
Message-ID: 032401cdae27$0199b2e0$04cd18a0$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> -----Original Message-----
> From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-
> owner(at)postgresql(dot)org] On Behalf Of Victor Sterpu
> Sent: Friday, October 19, 2012 2:15 PM
> To: pgsql-sql(at)postgresql(dot)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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message lmagnell 2012-10-19 20:24:52 Insert strings that contain colons into a table
Previous Message Victor Sterpu 2012-10-19 18:14:48 Trigger triggered from a foreign key