From: Joseph Pravato <joseph.pravato@nomagic.com>
To: pgsql-jdbc@postgresql.org
Subject: Automatic transactions in SELECT
Date: Thu, 28 Feb 2013 10:25:17 -0600
Message-ID: <512F84ED.3050002@nomagic.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
We use SquirrelSQL to talk to our databases with the Postgres 9.2-1002 JDBC driver. We've been having issues with transactions mostly related to syntax issues.
Example:
select firstname from contact limit 10;
Will throw this error:
Error: ERROR: column "firstname" does not exist
Position: 8
SQLState: 42703
ErrorCode: 0
But, if we fix the column name:
select first_name from contact limit 10;
We would get this strange error:
Error: ERROR: current transaction is aborted, commands ignored until
end of transaction block
SQLState: 25P02
ErrorCode: 0
Over the past few weeks, our team has been looking into this issue where our application would just stop and hang. For the past couple months
we've been dealing with this, our solution was to go to everybody's SquirrelSQL sessions and hit rollback. This fixes the issue every time.
Usually, users' who's session caused the hang couldn't remember what they were doing, so we still don't know what exactly is causing the issue.
We did however figure out what the root cause is, as you can see above. Every statement in the JDBC driver is ran inside of a transaction. This
is not a SquirrelSQL problem since a simple test program that only uses the JDBC driver gives the same error. Yet when I run it in on the
command line (psql) it has no issues.
What gets particularly confusing with this issue is when your query is wrong in any way, you are required to rollback the transaction. Worse
yet, you have to re-run any prior statements in the transaction if you have any errors. The easiest solution is to turn auto-commit on and hope
that you never seriously screw up data. But, we are not going to, nor allowed to do that.
Did I miss anything, maybe a setting somewhere in the JDBC driver that can fix this issue? It makes it extremely difficult to run ad-hoc
queries since at anytime there is a possibility that some queries stop responding.
Please note, one of the recommendations was to switch sql query tools, turn on auto-commit, or to use save points. We would rather find a
solution with the JDBC driver instead of switching tools as we have been using SquirrelSQL for over a year with various databases.
We are currently looking into the use of save points, but as of now, any assistance is appreciated.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: joseph.pravato@nomagic.com
Subject: Re: Automatic transactions in SELECT
In-Reply-To: <512F84ED.3050002@nomagic.com>
References: <512F84ED.3050002@nomagic.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox