How to detect if in transaction?

From: Basil Bourque <basil(dot)list(at)me(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: How to detect if in transaction?
Date: 2011-01-18 20:52:46
Message-ID: 040F4D17-CCFC-49A8-96BF-524ECD3BF97C@me.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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.

--Basil Bourque

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message John DeSoi 2011-01-18 21:44:56 Re: How to detect if in transaction?
Previous Message Mark Smith 2011-01-18 18:17:46 ECPG date output depends on database datestyle