Issue Details (XML | Word | Printable)

Key: DERBY-2084
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Bernt M. Johnsen
Reporter: Bernt M. Johnsen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

getTransactionIsolation() in network client should not activate a transaction

Created: 14/Nov/06 12:30 PM   Updated: 30/Jun/09 03:55 PM
Return to search
Component/s: Network Client
Affects Version/s: 10.1.3.1, 10.2.1.6, 10.3.1.4
Fix Version/s: 10.1.3.2, 10.2.2.0, 10.3.1.4

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works DERBY-2084.diff 2006-11-14 01:25 PM Bernt M. Johnsen 1 kB
Issue Links:
Incorporates
 
Reference
 

Bug behavior facts: Regression
Resolution Date: 17/Nov/06 12:29 PM


 Description  « Hide
getTransactionIsolation() is implemented by means of
     rs = getTransactionIsolationStmt.executeQuery("values current isolation");

This will activate a transaction. Thus the code snippet

        Connection conn =
            DriverManager.getConnection(url);
        conn.setAutoCommit(false);
        int tx = conn.getTransactionIsolation();
        conn.close();

will fail with

java.sql.SQLException: Cannot close a connection while a transaction is still active.
        at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
        at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
        at org.apache.derby.client.am.Connection.closeResourcesX(Unknown Source)
        at org.apache.derby.client.am.Connection.closeX(Unknown Source)
        at org.apache.derby.client.net.NetConnection.closeX(Unknown Source)
        at org.apache.derby.client.am.Connection.close(Unknown Source)
        at org.apache.derby.client.net.NetConnection.close(Unknown Source)
        at GetTransactionIsolation.test(GetTransactionIsolation.java:12)
        at GetTransactionIsolation.main(GetTransactionIsolation.java:22)
Caused by: org.apache.derby.client.am.SqlException: Cannot close a connection while a transaction is still active.
        at org.apache.derby.client.am.Connection.checkForTransactionInProgress(Unknown Source)
        ... 7 more



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Bernt M. Johnsen added a comment - 14/Nov/06 12:58 PM
Only when autoc commit is false.

Bernt M. Johnsen added a comment - 14/Nov/06 01:25 PM
Simple patch uploaded.

Bernt M. Johnsen added a comment - 14/Nov/06 02:04 PM
This is a regression from 10.1.2.1 to 10.1.3.1 caused by the fix for DERBY-1148

Deepa Remesh added a comment - 14/Nov/06 05:58 PM
Bernt, I verified that your patch fixes the problem reported. I hadn't realized that the fix for DERBY-1148 would lead to this bug.

As an aside, I relooked at my patch for DERBY-1148. And I am wondering if the storing and saving of autocommit value is needed. I am checking if the below statement (and related statements) serve any purpose:
// Store the current auto-commit value and use it to restore
// at the end of this method.
boolean currentAutoCommit = autoCommit_;

I did some quick checks with and without these statements and seem to get same results. Any thoughts on this?

Bernt M. Johnsen added a comment - 15/Nov/06 01:03 PM
Semantically, it should make no difference if getTransactionIsolation() commited when autocommit==true, but I think the way it is now is working ok too.

Daniel John Debrunner added a comment - 15/Nov/06 04:16 PM
Bernt, sorry but I don't understand what your last comment is trying to say. "No difference" to whar?

Bernt M. Johnsen added a comment - 16/Nov/06 09:23 AM
Dan: It dosen't matter, since I was wrong.
Deepa: The current implementation is correct. You need to temporarily turn off autocommit because there may be open result-sets when getTransactionIsolation().

Bernt M. Johnsen added a comment - 17/Nov/06 09:19 AM
Committed revision 476087.

Bernt M. Johnsen added a comment - 17/Nov/06 09:20 AM
Merge to 10.2

Bernt M. Johnsen added a comment - 17/Nov/06 09:21 AM
Committed revision 476088.

Bernt M. Johnsen added a comment - 17/Nov/06 09:23 AM
Merge to 10.1

Bernt M. Johnsen added a comment - 17/Nov/06 12:29 PM
Moerged from trunk to 10.1.
Committed revision 476119.