From: David Johnston <polobo@yahoo.com>
To: 'Victor Sterpu' <victor@caido.ro>
To: pgsql-sql@postgresql.org
Subject: Re: Trigger triggered from a foreign key
Date: Fri, 19 Oct 2012 14:24:41 -0400
Message-ID: <032401cdae27$0199b2e0$04cd18a0$@yahoo.com> (raw)
In-Reply-To: <50819898.9090508@caido.ro>
References: <50819898.9090508@caido.ro>
> -----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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: polobo@yahoo.com, victor@caido.ro
Subject: Re: Trigger triggered from a foreign key
In-Reply-To: <032401cdae27$0199b2e0$04cd18a0$@yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox