Re: Transaction ID in Triggers

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>
Subject: Re: Transaction ID in Triggers
Date: 2009-08-14 20:08:16
Message-ID: 22497.1250280496@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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

Browse pgsql-novice by date

  From Date Subject
Next Message Greg Stark 2009-08-14 20:25:09 Re: Transaction ID in Triggers
Previous Message David Saracini 2009-08-14 19:39:41 Transaction ID in Triggers