Skip site navigation (1) Skip section navigation (2)

Re: How to detect if in transaction?

From: John DeSoi <desoi(at)pgedit(dot)com>
To: Basil Bourque <basil(dot)list(at)me(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to detect if in transaction?
Date: 2011-01-18 21:44:56
Message-ID: F6B81278-30E9-479E-8861-45D10B222645@pgedit.com (view raw or flat)
Thread:
Lists: pgsql-novice
On Jan 18, 2011, at 3:52 PM, Basil Bourque wrote:

> How can I tell if a session is in a pending transaction? In other words, a "BEGIN TRANSACTION" has been issued but the transaction has not yet done a COMMIT or ROLLBACK. How can I ask if that is the condition?
> 
> I've googled and searched the archives. Others have asked the question, but I've not seen an answer. I did read that Postgres defaults to AUTO-COMMIT until I issue a "BEGIN TRANSACTION". I want to programmatically detect that condition for the sake of defensive programming, logging, debugging, and so on.

What client interface are you using to connect to Postgres? This information is available using the low level communication protocol, but I'm not sure there is an SQL command to give the status.


John DeSoi, Ph.D.





In response to

Responses

pgsql-novice by date

Next:From: Bill P.Date: 2011-01-19 15:25:24
Subject: Anyone else getting someone else's USER INFO when going to EnterpriseDB Forums
Previous:From: Basil BourqueDate: 2011-01-18 20:52:46
Subject: How to detect if in transaction?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group