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

Re: Transaction ID in Triggers

From: David Saracini <dsaracini(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql novice forum <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Transaction ID in Triggers
Date: 2009-08-14 20:31:21
Message-ID: 877740.35913.qm@web180311.mail.gq1.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi Tom,

Thank you for the quick reply.  Unfortunately, I have a couple of more questions.  :)

So, if I understand it...  then, txid_current returns the xmax in the high-order and the xmin in the low-order.  Correct?  and the xmax is the transaction that deleted the tuple and the xmin stores the last transaction that (inserted or modified).  Correct?

Thanks - and Regards,

David



________________________________
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Saracini <dsaracini(at)yahoo(dot)com>
Cc: pgsql novice forum <pgsql-novice(at)postgresql(dot)org>
Sent: Friday, August 14, 2009 1:08:16 PM
Subject: Re: [NOVICE] Transaction ID in Triggers 

David Saracini <dsaracini(at)yahoo(dot)com> writes:
> Is there a way to find out the current transaction id from within a Trigger?  I'm interested in implementing a better audit trail mechanism and this would help me greatly.

If you have your hands on a row that was inserted or updated by the
current transaction, you could look at its xmin.  Another possibility
(in recent releases) is to take the low-order 32 bits of txid_current().

            regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2009-08-14 20:38:20
Subject: Re: Transaction ID in Triggers
Previous:From: Greg StarkDate: 2009-08-14 20:25:09
Subject: Re: Transaction ID in Triggers

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