db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From be...@apache.org
Subject svn commit: r475707 - in /db/derby/code/branches/10.1/java: client/org/apache/derby/client/am/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/org/apache/derbyTesting/function...
Date Thu, 16 Nov 2006 12:23:39 GMT
Author: bernt
Date: Thu Nov 16 04:23:38 2006
New Revision: 475707

URL: http://svn.apache.org/viewvc?view=rev&rev=475707
Log:
DERB-638 backported from trunk

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

Modified: db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java?view=diff&rev=475707&r1=475706&r2=475707
==============================================================================
--- db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java Thu
Nov 16 04:23:38 2006
@@ -872,6 +872,9 @@
                             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/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/setTransactionIsolation.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/setTransactionIsolation.out?view=diff&rev=475707&r1=475706&r2=475707
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/setTransactionIsolation.out
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/setTransactionIsolation.out
Thu Nov 16 04:23:38 2006
@@ -565,3 +565,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/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/setTransactionIsolation.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/setTransactionIsolation.out?view=diff&rev=475707&r1=475706&r2=475707
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/setTransactionIsolation.out
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/setTransactionIsolation.out
Thu Nov 16 04:23:38 2006
@@ -673,3 +673,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/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/setTransactionIsolation.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/setTransactionIsolation.out?view=diff&rev=475707&r1=475706&r2=475707
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/setTransactionIsolation.out
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/setTransactionIsolation.out
Thu Nov 16 04:23:38 2006
@@ -673,3 +673,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/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/setTransactionIsolation.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/setTransactionIsolation.java?view=diff&rev=475707&r1=475706&r2=475707
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/setTransactionIsolation.java
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/setTransactionIsolation.java
Thu Nov 16 04:23:38 2006
@@ -75,7 +75,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]);
 
@@ -90,6 +90,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();
@@ -107,7 +111,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);
@@ -189,6 +193,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,



Mime
View raw message