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"