Lists: | pgsql-jdbc |
---|
From: | sulfinu(at)gmail(dot)com |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | unnecessary exception patch |
Date: | 2008-01-11 13:43:18 |
Message-ID: | 200801111543.18210.sulfinu@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Hi,
this is a patch that avoids getting an undeserved PSQLException when setting
the transaction isolation level on a connection:
---
postgresql-jdbc-8.2-507.src/org/postgresql/jdbc2/AbstractJdbc2Connection.java
2007-12-01 11:17:49.000000000 +0200
+++ src/org/postgresql/jdbc2/AbstractJdbc2Connection.java 2008-01-11
15:26:58.000000000 +0200
@@ -759,6 +759,8 @@
*/
public void setTransactionIsolation(int level) throws SQLException
{
+ if (level == getTransactionIsolation())
+ return;
if (protoConnection.getTransactionState() !=
ProtocolConnection.TRANSACTION_IDLE)
throw new PSQLException(GT.tr("Cannot change transaction
isolation level in the middle of a transaction."),
PSQLState.ACTIVE_SQL_TRANSACTION);
It applies to the case when a connection is reused within a connection pool
and some of its properties are automatically reset before the connection is
handed to the requesting party.
Example: the default DriverManagerConnectionProvider in Hibernate.
Regards.
From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | sulfinu(at)gmail(dot)com |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: unnecessary exception patch |
Date: | 2008-01-14 10:27:38 |
Message-ID: | Pine.BSO.4.64.0801140526020.1408@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
On Fri, 11 Jan 2008, sulfinu(at)gmail(dot)com wrote:
> this is a patch that avoids getting an undeserved PSQLException when
> setting the transaction isolation level on a connection:
>
> + if (level == getTransactionIsolation())
> + return;
Looks reasonable. My only concern is that getTransactionIsolation does a
query to check the current isolation level, so we'd be penalizing any
callers who were deliberately changing the isoloation level.
Kris Jurka