db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r482806 - in /db/derby/code/trunk/java: engine/org/apache/derby/jdbc/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Date Tue, 05 Dec 2006 22:19:15 GMT
Author: mamta
Date: Tue Dec  5 14:19:14 2006
New Revision: 482806

URL: http://svn.apache.org/viewvc?view=rev&rev=482806
Log:
Add some sanity code to make sure that the connection is indeed idle when the code expects
it to. 
Also, enhanced XA related test to make sure that writable XA transaction following a read-only
XA 
transaction works correctly.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAResource.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java?view=diff&rev=482806&r1=482805&r2=482806
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java Tue Dec
 5 14:19:14 2006
@@ -229,6 +229,11 @@
 
 		// reset any remaining state of the connection
 		realConnection.resetFromPool();
+		if (SanityManager.DEBUG)
+		{
+			SanityManager.ASSERT(realConnection.transactionIsIdle(),
+			"real connection should have been idle at this point"); 			
+		}
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAResource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAResource.java?view=diff&rev=482806&r1=482805&r2=482806
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAResource.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedXAResource.java Tue Dec  5
14:19:14 2006
@@ -282,6 +282,12 @@
                 } else {
                     
                     returnConnectionToResource(tranState, xid_im);
+					if (SanityManager.DEBUG)
+					{
+						if (realConnection != null)
+							SanityManager.ASSERT(realConnection.transactionIsIdle(),
+									"real connection should have been idle at this point"); 			
+					}
                     return XAResource.XA_RDONLY;
                 }
             } catch (SQLException sqle) {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out?view=diff&rev=482806&r1=482805&r2=482806
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
Tue Dec  5 14:19:14 2006
@@ -551,6 +551,17 @@
 autocommitxastart expected  : XAException - null
 Expected XA error code: -9
 acxs 3
+TESTING READ_ONLY TRANSACTION FOLLOWED BY WRTIABLE TRANSACTION
+read-only XA transaction
+  isolation level READ_COMMITTED
+  auto commit     false
+  read only       true
+acxs 5
+Writable XA transaction
+  isolation level READ_COMMITTED
+  auto commit     false
+  read only       false
+acxs 7
 testing jira 95 for DataSource; ok - expected exception: XCY00
 testing jira 95 for XADataSource; ok - expected exception: XCY00
 DataSource - EMPTY

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out?view=diff&rev=482806&r1=482805&r2=482806
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
Tue Dec  5 14:19:14 2006
@@ -687,6 +687,19 @@
 autocommitxastart expected  : XAException - null
 Expected XA error code: -9
 acxs 3
+TESTING READ_ONLY TRANSACTION FOLLOWED BY WRTIABLE TRANSACTION
+read-only XA transaction
+  holdability     false
+  isolation level READ_COMMITTED
+  auto commit     false
+  read only       true
+acxs 5
+Writable XA transaction
+  holdability     false
+  isolation level READ_COMMITTED
+  auto commit     false
+  read only       false
+acxs 7
 testing jira 95 for DataSource; ok - expected exception: XCY00
 testing jira 95 for XADataSource; ok - expected exception: XCY00
 DataSource - EMPTY

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java?view=diff&rev=482806&r1=482805&r2=482806
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
Tue Dec  5 14:19:14 2006
@@ -654,6 +654,38 @@
 		conn4.close();
 		xac4.close();
 		
+		// Test following sequence of steps
+		// 1)start a read-only global transaction 
+		// 2)finish that read-only transaction
+		// 3)start another global transaction 
+		System.out.println("TESTING READ_ONLY TRANSACTION FOLLOWED BY WRTIABLE TRANSACTION");
+		XAConnection xac5 = dsx.getXAConnection();
+		Xid xid5a = new cdsXid(5, (byte) 119, (byte) 129);
+		Connection conn5 = xac5.getConnection();
+		Statement sru5a = conn5.createStatement();
+		xar = xac5.getXAResource();
+		xar.start(xid5a, XAResource.TMNOFLAGS);
+		conn5.setReadOnly(true);
+		printState("read-only XA transaction", conn5);
+		ResultSet rs5 = sru5a.executeQuery("select count(*) from autocommitxastart");
+		rs5.next(); System.out.println("acxs " + rs5.getInt(1));
+		rs5.close();
+		xar.end(xid5a, XAResource.TMSUCCESS);
+		xar.commit(xid5a, true);
+		conn5.close();
+		//now start a new transaction
+		conn5 = xac5.getConnection();
+		sru5a = conn5.createStatement();
+		xar.start(xid5a, XAResource.TMNOFLAGS);
+		printState("Writable XA transaction", conn5);
+		sru5a.executeUpdate("insert into autocommitxastart values 6,7");
+		rs5 = sru5a.executeQuery("select count(*) from autocommitxastart");
+		rs5.next(); System.out.println("acxs " + rs5.getInt(1));
+		xar.end(xid5a, XAResource.TMSUCCESS);
+		xar.commit(xid5a, true);
+		conn5.close();
+		xac5.close();
+		
 		
 		// test jira-derby 95 - a NullPointerException was returned when passing
 		// an incorrect database name (a url in this case) - should now give error XCY00



Mime
View raw message