From: | Alvaro Herrera <alvherre(at)surnet(dot)cl> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | Steve - DND <postgres(at)digitalnothing(dot)com>, postgres-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Current transaction ID? |
Date: | 2005-06-15 16:58:25 |
Message-ID: | 20050615165825.GR9860@surnet.cl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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"
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2005-06-15 17:01:31 | Re: Autovacuum in the backend |
Previous Message | Tom Lane | 2005-06-15 16:50:06 | Re: enebling regular user to create new users ? |