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 made changes - 14/Nov/06 01:24 PM
Field Original Value New Value
Assignee Bernt M. Johnsen [ bernt ]
Bernt M. Johnsen made changes - 14/Nov/06 01:24 PM
Status Open [ 1 ] In Progress [ 3 ]
Bernt M. Johnsen added a comment - 14/Nov/06 01:25 PM
Simple patch uploaded.

Bernt M. Johnsen made changes - 14/Nov/06 01:25 PM
Attachment DERBY-2084.diff [ 12344961 ]
Bernt M. Johnsen made changes - 14/Nov/06 01:25 PM
Link This issue is part of DERBY-310 [ DERBY-310 ]
Bernt M. Johnsen made changes - 14/Nov/06 01:27 PM
Link This issue relates to DERBY-1148 [ DERBY-1148 ]
Bernt M. Johnsen made changes - 14/Nov/06 01:27 PM
Link This issue relates to DERBY-638 [ DERBY-638 ]
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

Bernt M. Johnsen made changes - 14/Nov/06 02:04 PM
Derby Info [Regression]
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().

Repository Revision Date User Message
ASF #476087 Fri Nov 17 09:17:55 UTC 2006 bernt DERBY-2084 getTransactionIsolation() in network client should not activate a transaction
Files Changed
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java

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

Bernt M. Johnsen made changes - 17/Nov/06 09:19 AM
Resolution Fixed [ 1 ]
Derby Info [Regression] [Patch Available, Regression]
Status In Progress [ 3 ] Resolved [ 5 ]
Fix Version/s 10.3.0.0 [ 12310800 ]
Bernt M. Johnsen added a comment - 17/Nov/06 09:20 AM
Merge to 10.2

Bernt M. Johnsen made changes - 17/Nov/06 09:20 AM
Status Resolved [ 5 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Repository Revision Date User Message
ASF #476088 Fri Nov 17 09:21:18 UTC 2006 bernt DERBY-2084 merged from trunk
Files Changed
MODIFY /db/derby/code/branches/10.2/java/client/org/apache/derby/client/am/Connection.java

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

Bernt M. Johnsen made changes - 17/Nov/06 09:21 AM
Fix Version/s 10.2.1.8 [ 12312096 ]
Status Reopened [ 4 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Bernt M. Johnsen added a comment - 17/Nov/06 09:23 AM
Merge to 10.1

Bernt M. Johnsen made changes - 17/Nov/06 09:23 AM
Status Resolved [ 5 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Repository Revision Date User Message
ASF #476119 Fri Nov 17 12:28:12 UTC 2006 bernt DERBY-2084 merged from trunk to 10.1
Files Changed
MODIFY /db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java

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

Bernt M. Johnsen made changes - 17/Nov/06 12:29 PM
Resolution Fixed [ 1 ]
Derby Info [Patch Available, Regression] [Regression]
Fix Version/s 10.1.3.2 [ 12311972 ]
Status Reopened [ 4 ] Resolved [ 5 ]
Bernt M. Johnsen made changes - 19/Jan/07 10:15 AM
Status Resolved [ 5 ] Closed [ 6 ]
Dag H. Wanvik made changes - 30/Jun/09 03:55 PM
Bug behavior facts [Regression]