Skip site navigation (1) Skip section navigation (2)

how to tell if a tuple has been inserted in current transaction

From: pg noob <pgnube(at)gmail(dot)com>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: how to tell if a tuple has been inserted in current transaction
Date: 2012-05-03 13:50:28
Message-ID: CAPNY-2UFrBbeN9A_5Siwcu-QhHv_R5kkJMii4GcdPzu8JGoR9Q@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
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?

Thank you for any information.

Responses

pgsql-novice by date

Next:From: Oliveiros d'Azevedo CristinaDate: 2012-05-03 13:53:31
Subject: Re: JOIN producing duplicate results
Previous:From: Brent DombrowskiDate: 2012-05-03 13:22:49
Subject: Re: JOIN producing duplicate results

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group