| From: | Greg Stark <gsstark(at)mit(dot)edu> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | David Saracini <dsaracini(at)yahoo(dot)com>, pgsql novice forum <pgsql-novice(at)postgresql(dot)org> |
| Subject: | Re: Transaction ID in Triggers |
| Date: | 2009-08-14 20:25:09 |
| Message-ID: | 407d949e0908141325g10578e48ic830df96297787d0@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
On Fri, Aug 14, 2009 at 9:08 PM, Tom Lane<tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> 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().
For an auditing mechanism you probably just want to use the whole of
txid_current() anyways.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Saracini | 2009-08-14 20:31:21 | Re: Transaction ID in Triggers |
| Previous Message | Tom Lane | 2009-08-14 20:08:16 | Re: Transaction ID in Triggers |