Re: detect initiator of update/delete action - Mailing list pgsql-sql

From Luca Ferrari
Subject Re: detect initiator of update/delete action
Date
Msg-id CAKoxK+6UZF6eEm8kcBApXs76-5V3Q1XqO-Dc=XRWOfP1fB2NqQ@mail.gmail.com
Whole thread Raw
In response to detect initiator of update/delete action  (ssylla <stefansylla@gmx.de>)
List pgsql-sql
On Fri, Sep 20, 2013 at 9:52 AM, ssylla <stefansylla@gmx.de> wrote:
> There are two cases:
> 1. if the deletion was executed through a user action, both the update and
> insert statement of the 'table1_del' function should be executed
> 2. if the deletion was initiated through a function fired from another
> table, only the insert statement should be executed


There is nothing that allows a trigger to distinguish such kind of invocation.
However there is a different kind of approach that comes into my mind
and that I would try: within the trigger test for a specific temporary
table and a value into it. In the case the trigger is invoked
"directly" (1) the table will not be created, while in the case of a
trigger chain the other trigger is responsible for populating the temp
table (and the current trigger to truncate it). Of course a drawback
of this approach is that you need to create and populate the temp
table on each trigger of an higher level in the call chain.

Luca



pgsql-sql by date:

Previous
From: ssylla
Date:
Subject: detect initiator of update/delete action
Next
From: Gary Stainburn
Date:
Subject: unique key problem on update