transaction in progress

Started by Rick Giggerover 22 years ago3 messagesgeneral
Jump to latest
#1Rick Gigger
rgigger@leadership-solutions.net

Is there a convenient way to tell in postgres if a transaction has been
started or not?

#2Bruce Momjian
bruce@momjian.us
In reply to: Rick Gigger (#1)
Re: transaction in progress

Rick Gigger wrote:

Is there a convenient way to tell in postgres if a transaction has been
started or not?

libpq has PQtransactionStatus, though I wonder why we don't have this
visible via a read-only GUC variable to make it easier for other languages.

Anyone?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
Re: transaction in progress

Bruce Momjian <pgman@candle.pha.pa.us> writes:

libpq has PQtransactionStatus, though I wonder why we don't have this
visible via a read-only GUC variable to make it easier for other languages.

Because it'd be useless --- the only way to interrogate it would be via
SHOW or some other SQL command, which would have the effect of changing
your transaction status, at least with client libraries that implement
autocommit. Not to mention that the SHOW itself would fail if you're
in a failed transaction.

You have to have an out-of-band mechanism for checking xact status.
Thus PQtransactionStatus. AFAIK there are already equivalent APIs
in other popular libraries.

regards, tom lane