Re: Current transaction ID? - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Current transaction ID?
Date
Msg-id 20050615165825.GR9860@surnet.cl
Whole thread Raw
In response to Re: Current transaction ID?  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-general
On Tue, Jun 14, 2005 at 07:41:11PM -0400, Bruce Momjian wrote:
> Steve - DND wrote:
> > Simple question I'm sure, but how can I get the transaction ID that a query
> > is currently running in? I can find all kinds of documentation talking about
> > transaction ids, but nothing about how to get the current one.
>
> You can look at the xmin of a tuple you created or an xmax of a tuple
> you deleted.

Beware -- if you use savepoints, the Xid will change and you will think
it was a different transaction when in fact it was the same one.

You should also know that savepoints are used invisibly sometimes, for
example in EXCEPTION clauses in PL/pgSQL.  (Though you return to the
original transaction when the EXCEPTION block finishes, I think.)

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"Los románticos son seres que mueren de deseos de vida"

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: enebling regular user to create new users ?
Next
From: Matt Miller
Date:
Subject: Re: enebling regular user to create new users ?