From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | pg noob <pgnube(at)gmail(dot)com> |
Cc: | pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: how to tell if a tuple has been inserted in current transaction |
Date: | 2012-05-03 14:29:00 |
Message-ID: | CAHyXU0yPdFUQEXis6sqMfJ3EbPuV2ep29CU_xoEy7Tz=uyqQKg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Thu, May 3, 2012 at 8:50 AM, pg noob <pgnube(at)gmail(dot)com> wrote:
>
> Hi all,
>
> I have a trigger function which is getting invoked on insert/update and
> within that trigger I would like to know if some tuple, from a different
> table referenced by foreign key constraint from the table with the trigger
> on it, was inserted within the same transaction as the insert/update that
> caused the trigger to fire.
>
> I found that I can tell if the foreign tuple was inserted or updated by
> checking if its xmin == select txid_current(), but there doesn't appear to
> be any way to know if it was modified because of an INSERT or an UPDATE. I
> would like to distinguish between whether it was an insert or update that
> caused the row to be modified. Is this possible?
just put a trigger on that table and scribble TG_OP into a field
reserved for that...
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Lonni J Friedman | 2012-05-03 17:04:05 | Re: JOIN producing duplicate results |
Previous Message | Oliveiros d'Azevedo Cristina | 2012-05-03 13:53:31 | Re: JOIN producing duplicate results |