You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by be...@apache.org on 2006/11/14 11:25:52 UTC

svn commit: r474720 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/org/apache/derbyTesting/functionTests/ma...

Author: bernt
Date: Tue Nov 14 02:25:51 2006
New Revision: 474720

URL: http://svn.apache.org/viewvc?view=rev&rev=474720
Log:
DERBY-638 Network driver setTransactionIsolation() causes a commit, but does not complete it locally

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/setTransactionIsolation.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/setTransactionIsolation.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setTransactionIsolation.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/setTransactionIsolation.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?view=diff&rev=474720&r1=474719&r2=474720
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java Tue Nov 14 02:25:51 2006
@@ -945,7 +945,12 @@
                                 java.sql.ResultSet.CONCUR_READ_ONLY,
                                 holdability());
             }
+
             setTransactionIsolationStmt.executeUpdate("SET CURRENT ISOLATION = " + levelString);
+
+            // The server has now implicitely committed the
+            // transaction so we have to clean up locally.
+            completeLocalCommit();
 
             isolation_ = level;
         }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/setTransactionIsolation.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/setTransactionIsolation.out?view=diff&rev=474720&r1=474719&r2=474720
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/setTransactionIsolation.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/setTransactionIsolation.out Tue Nov 14 02:25:51 2006
@@ -493,3 +493,4 @@
 insert into t1copy (select * from t1)
 A lock could not be obtained within the time requested
 FAIL: setTransactionIsolation() did not throw exception with open hold cursor
+count=1, setTransactionIsolation() does not commit

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/setTransactionIsolation.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/setTransactionIsolation.out?view=diff&rev=474720&r1=474719&r2=474720
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/setTransactionIsolation.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/setTransactionIsolation.out Tue Nov 14 02:25:51 2006
@@ -529,3 +529,4 @@
 insert into t1copy (select * from t1)
 A lock could not be obtained within the time requested
 EXPECTED EXCEPTION SQLSTATE:X0X03 Invalid transaction state - held cursor requires same isolation level
+count=2, setTransactionIsolation() commits

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setTransactionIsolation.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setTransactionIsolation.out?view=diff&rev=474720&r1=474719&r2=474720
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setTransactionIsolation.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setTransactionIsolation.out Tue Nov 14 02:25:51 2006
@@ -529,3 +529,4 @@
 insert into t1copy (select * from t1)
 A lock could not be obtained within the time requested
 EXPECTED EXCEPTION SQLSTATE:X0X03 Invalid transaction state - held cursor requires same isolation level
+count=1, setTransactionIsolation() does not commit

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/setTransactionIsolation.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/setTransactionIsolation.java?view=diff&rev=474720&r1=474719&r2=474720
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/setTransactionIsolation.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/setTransactionIsolation.java Tue Nov 14 02:25:51 2006
@@ -78,7 +78,7 @@
     Statement stmt = conn.createStatement();
 
 
-	String[] tabsToDrop = {"tab1", "t1", "t1copy", "t2"};
+	String[] tabsToDrop = {"tab1", "t1", "t1copy", "t2", "t3"};
 	for (int i = 0; i < tabsToDrop.length; i++)
 		dropTable(stmt,tabsToDrop[i]);
 
@@ -111,6 +111,10 @@
 	stmt.executeUpdate("INSERT INTO T1 VALUES(1,'First Hello')");
 	stmt.executeUpdate("INSERT INTO T1 VALUES(2,'Second Hello')");
 	stmt.executeUpdate("INSERT INTO T1 VALUES(3,'Third Hello')");
+
+
+    stmt.executeUpdate("create table t3 (i integer)");
+
     System.out.println("done creating table and inserting data.");
 
     stmt.close();
@@ -128,7 +132,7 @@
 		   conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
 		   testIsolation(conn, false);
 		   testSetTransactionIsolationInHoldCursor(conn);
-
+           testSetTransactionIsolationCommits(conn);
 		} catch (SQLException sqle) {
 			System.out.print("FAIL:");
 			org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException(System.out, sqle);
@@ -211,6 +215,50 @@
 			return;
 		}
 		System.out.println("FAIL: setTransactionIsolation() did not throw exception with open hold cursor");
+	}
+	
+	/**
+	 *   setTransactionIsolation commits?
+	 */
+	public static void testSetTransactionIsolationCommits(Connection conn) 
+	{
+        // In the current client implementation, the transaction will
+        // commit when setTransactionIsolation is called, while the
+        // embedded driver will not commit. See
+        // http://issues.apache.org/jira/browse/DERBY-2064
+		try {
+            conn.rollback();
+            conn.setAutoCommit(false);
+			conn.setTransactionIsolation(java.sql.Connection.TRANSACTION_SERIALIZABLE);
+            Statement s = conn.createStatement();
+            s.executeUpdate("delete from t3");
+            s.executeUpdate("insert into t3 values(1)");
+            conn.commit();
+            s.executeUpdate("insert into t3 values(2)");
+			conn.setTransactionIsolation(java.sql.Connection.TRANSACTION_SERIALIZABLE);
+            conn.rollback();
+            ResultSet rs = s.executeQuery("select count(*) from t3");
+            rs.next();
+            int count = rs.getInt(1);
+            switch (count) {
+            case 1:
+                System.out.println("count="+ count + 
+                                   ", setTransactionIsolation() does not commit");
+                break;
+            case 2:
+                System.out.println("count="+ count + 
+                                   ", setTransactionIsolation() commits");
+                break;
+            default:
+                System.out.println("FAIL: count="+ count + 
+                                   ", unexepected behaviour from testSetTransactionIsolationCommits");
+                break;
+            }
+            rs.close();
+            s.close();
+		} catch (SQLException se) {
+			System.out.println(se.getMessage());
+		}
 	}
 	
 	public static void testLevelsAndPrintStatistics(Connection con, String sql,