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 km...@apache.org on 2006/02/03 22:00:45 UTC

svn commit: r374742 - in /db/derby/code/branches/10.1/java: drda/org/apache/derby/impl/drda/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/org/apache/derbyTesting/functionTe...

Author: kmarsden
Date: Fri Feb  3 13:00:35 2006
New Revision: 374742

URL: http://svn.apache.org/viewcvs?rev=374742&view=rev
Log:
DERBY-898 setAutoCommit(false) is not working properly with connections objtained with ClientXADataSource.

-  Changes server side connection for network server XA to autocommit false.  Even when the client has autocommit on, the server side connection should be autocommit false and let the client drive the commits.

- Adds connections obtained from an XADataSource to the savepointJdbc30 test to verify that autocommit is being set properly and also verify that DERBY-899 (a dup of this issue) is fixed.



Modified:
    db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/XADatabase.java
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/savepointJdbc30.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/savepointJdbc30.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/savepointJdbc30.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/savepointJdbc30.java

Modified: db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/XADatabase.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/XADatabase.java?rev=374742&r1=374741&r2=374742&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/XADatabase.java (original)
+++ db/derby/code/branches/10.1/java/drda/org/apache/derby/impl/drda/XADatabase.java Fri Feb  3 13:00:35 2006
@@ -89,6 +89,9 @@
 		
 		// Get a new logical connection.
 		conn = xaConnection.getConnection();
+		// Client will always drive the commits so connection should
+		// always be autocommit false on the server. DERBY-898/DERBY-899
+		conn.setAutoCommit(false);
 		setConnection(conn);
 		return conn;
 		

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/savepointJdbc30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/savepointJdbc30.out?rev=374742&r1=374741&r2=374742&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/savepointJdbc30.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/savepointJdbc30.out Fri Feb  3 13:00:35 2006
@@ -1,4 +1,4 @@
-Test savepointJdbc30 starting
+Test savepointJdbc30 starting for regular connections
 Tests common to DRDA and embedded Cloudscape
 Test1 - no unnamed savepoints allowed if autocommit is true
 Expected Exception is Cannot set savepoint when in auto-commit mode.
@@ -72,4 +72,4 @@
 Test 26b release  of null savepoint
 Expected Exception is Cannot release a null savepoint.
 Next try non-DRDA tests
-Test savepointJdbc30 finished
+Test savepointJdbc30 finished for regular connections

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/savepointJdbc30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/savepointJdbc30.out?rev=374742&r1=374741&r2=374742&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/savepointJdbc30.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/savepointJdbc30.out Fri Feb  3 13:00:35 2006
@@ -1,4 +1,4 @@
-Test savepointJdbc30 starting
+Test savepointJdbc30 starting for regular connections
 Tests common to DRDA and embedded Cloudscape
 Test1 - no unnamed savepoints allowed if autocommit is true
 Expected Exception is Cannot set savepoint when in auto-commit mode.
@@ -72,4 +72,79 @@
 Test 26b release  of null savepoint
 Expected Exception is Cannot release a null savepoint.
 Next try non-DRDA tests
-Test savepointJdbc30 finished
+Test savepointJdbc30 finished for regular connections
+Test savepointJdbc30 starting for connections from XADataSource (local tranasaction)
+Tests common to DRDA and embedded Cloudscape
+Test1 - no unnamed savepoints allowed if autocommit is true
+Expected Exception is Cannot set savepoint when in auto-commit mode.
+Test1a - no named savepoints allowed if autocommit is true
+Expected Exception is Cannot set savepoint when in auto-commit mode.
+Test2 - Release and reuse a savepoint name
+Test3 - null name not allowed for named savepoints
+Expected Exception is Named savepoint needs a none-null name.
+Test4 - Verify names/ids of named/unnamed savepoints
+Expected Exception is This is an un-named savepoint.
+Expected Exception is This is a named savepoint.
+Test5a - create two savepoints in two different transactions and release the first one in the subsequent transaction
+Expected Exception is SAVEPOINT, s1 does not  exist or is not active in the current transaction.
+Test5b - create two savepoints in two different transactions and rollback the first one in the subsequent transaction
+Expected Exception is SAVEPOINT, s1 does not  exist or is not active in the current transaction.
+Test6a - create a savepoint, release it, create another with same name and release the first one
+Expected Exception is SAVEPOINT, s1 does not  exist or is not active in the current transaction.
+Test6b - create a savepoint, release it, create another with same name and rollback the first one
+Expected Exception is SAVEPOINT, s1 does not  exist or is not active in the current transaction.
+Test6c - Try to use a savepoint from another connection for release
+Expected Exception is Cannot release a savepoint that was not created by this connection.
+Test7a - swap savepoints across connections with release
+Expected Exception is Cannot release a savepoint that was not created by this connection.
+Test7b - swap savepoints across connections with rollback
+Expected Exception is Rollback to a savepoint not created by this connection.
+Test 9 test savepoint name
+Test 10 test savepoint name case sensitivity
+Test 11 rolling back a savepoint multiple times - should work
+Test 12 releasing a savepoint multiple times - should not work
+Expected Exception is SAVEPOINT, MyName does not  exist or is not active in the current transaction.
+Test 13 shouldn't be able to use a savepoint from earlier transaction after setting autocommit on and off
+Expected Exception is SAVEPOINT, MyName does not  exist or is not active in the current transaction.
+Test 14 A non-user initiated transaction rollback should release the internal savepoint array
+Expected Exception is A lock could not be obtained within the time requested
+Expected Exception is SAVEPOINT, MyName does not  exist or is not active in the current transaction.
+Test 15 check savepoints in batch
+Test 16 grammar check for savepoint sq1
+Expected Exception is Syntax error: MISSING ON ROLLBACK RETAIN CURSORS.
+Expected Exception is Multiple or conflicting keywords involving the 'ON ROLLBACK RETAIN CURSORS' clause are present.
+Expected Exception is Multiple or conflicting keywords involving the 'ON ROLLBACK RETAIN LOCKS' clause are present.
+Expected Exception is Multiple or conflicting keywords involving the 'UNIQUE' clause are present.
+Test 17 No nested savepoints allowed when using SQL to set savepoints.
+Test 17a Test with UNIQUE clause.
+Expected Exception is The maximum number of savepoints has been reached. 
+Test 17b Test without UNIQUE clause.
+Since no nesting is allowed, skipping UNIQUE still gives error for trying to define another savepoint
+Expected Exception is The maximum number of savepoints has been reached. 
+Test 18 No nested SQL savepoints allowed inside JDBC savepoint.
+Following SQL savepoint will fail because we are trying to nest it inside JDBC savepoint
+Expected Exception is The maximum number of savepoints has been reached. 
+Test 19 No nested SQL savepoints allowed inside SQL savepoint.
+Following SQL savepoint will fail because we are trying to nest it inside SQL savepoint
+Expected Exception is The maximum number of savepoints has been reached. 
+Test 20 Rollback of SQL savepoint works same as rollback of JDBC savepoint.
+Test 21 After releasing the SQL savepoint, rollback the transaction and should see everything undone.
+Test 22 Should not be able to create a SQL savepoint starting with name SYS
+Expected Exception is An object cannot be created with the schema name 'SYS'.
+Test 23 Should be able to use non-reserved keywords savepoint and release as identifiers
+Create table with savepoint and release as identifiers
+Create a savepoint with name savepoint
+Release the savepoint with name savepoint
+Create a savepoint with name release
+Rollback to the savepoint with name release
+Release the savepoint with name release
+Test 24 Savepoint name can't exceed 128 characters
+Expected Exception is The name 'MyName1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' is too long. The maximum length is '128'.
+Test 25 Should not be able to create a SQL savepoint starting with name SYS through jdbc
+Expected Exception is An object cannot be created with the schema name 'SYS'.
+Test 26a rollback of null savepoint
+Expected Exception is Cannot rollback to a null savepoint.
+Test 26b release  of null savepoint
+Expected Exception is Cannot release a null savepoint.
+Next try non-DRDA tests
+Test savepointJdbc30 finished for connections from XADataSource (local tranasaction)

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/savepointJdbc30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/savepointJdbc30.out?rev=374742&r1=374741&r2=374742&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/savepointJdbc30.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/savepointJdbc30.out Fri Feb  3 13:00:35 2006
@@ -1,4 +1,4 @@
-Test savepointJdbc30 starting
+Test savepointJdbc30 starting for regular connections
 Tests common to DRDA and embedded Cloudscape
 Test1 - no unnamed savepoints allowed if autocommit is true
 Expected Exception is Cannot issue savepoint when autoCommit is on.
@@ -99,4 +99,106 @@
 Following SQL savepoint will fail because we are trying to nest it inside JDBC savepoint
 Expected Exception is The maximum number of savepoints has been reached. 
 Expected Exception is The maximum number of savepoints has been reached. 
-Test savepointJdbc30 finished
+Test savepointJdbc30 finished for regular connections
+Test savepointJdbc30 starting for connections from XADataSource (local tranasaction)
+Tests common to DRDA and embedded Cloudscape
+Test1 - no unnamed savepoints allowed if autocommit is true
+Expected Exception is Cannot issue savepoint when autoCommit is on.
+Test1a - no named savepoints allowed if autocommit is true
+Expected Exception is Cannot issue savepoint when autoCommit is on.
+Test2 - Release and reuse a savepoint name
+Test3 - null name not allowed for named savepoints
+Expected Exception is Cannot pass null for savepoint name.
+Test4 - Verify names/ids of named/unnamed savepoints
+Expected Exception is No name for un-named savepoints.
+Expected Exception is No ID for named savepoints.
+Test5a - create two savepoints in two different transactions and release the first one in the subsequent transaction
+Expected Exception is SAVEPOINT, s1 does not  exist or is not active in the current transaction.
+Test5b - create two savepoints in two different transactions and rollback the first one in the subsequent transaction
+Expected Exception is SAVEPOINT, s1 does not  exist or is not active in the current transaction.
+Test6a - create a savepoint, release it, create another with same name and release the first one
+Expected Exception is SAVEPOINT, s1 does not  exist or is not active in the current transaction.
+Test6b - create a savepoint, release it, create another with same name and rollback the first one
+Expected Exception is SAVEPOINT, s1 does not  exist or is not active in the current transaction.
+Test6c - Try to use a savepoint from another connection for release
+Expected Exception is A RELEASE or ROLLBACK TO SAVEPOINT was specified, but the savepoint does not exist.
+Test7a - swap savepoints across connections with release
+Expected Exception is A RELEASE or ROLLBACK TO SAVEPOINT was specified, but the savepoint does not exist.
+Test7b - swap savepoints across connections with rollback
+Expected Exception is A RELEASE or ROLLBACK TO SAVEPOINT was specified, but the savepoint does not exist.
+Test 9 test savepoint name
+Test 10 test savepoint name case sensitivity
+Test 11 rolling back a savepoint multiple times - should work
+Test 12 releasing a savepoint multiple times - should not work
+Expected Exception is SAVEPOINT, MyName does not  exist or is not active in the current transaction.
+Test 13 shouldn't be able to use a savepoint from earlier transaction after setting autocommit on and off
+Expected Exception is SAVEPOINT, MyName does not  exist or is not active in the current transaction.
+Test 14 A non-user initiated transaction rollback should release the internal savepoint array
+Expected Exception is A lock could not be obtained within the time requested
+Expected Exception is SAVEPOINT, MyName does not  exist or is not active in the current transaction.
+Test 15 check savepoints in batch
+Test 16 grammar check for savepoint sq1
+Expected Exception is Syntax error: MISSING ON ROLLBACK RETAIN CURSORS.
+Expected Exception is Multiple or conflicting keywords involving the 'ON ROLLBACK RETAIN CURSORS' clause are present.
+Expected Exception is Multiple or conflicting keywords involving the 'ON ROLLBACK RETAIN LOCKS' clause are present.
+Expected Exception is Multiple or conflicting keywords involving the 'UNIQUE' clause are present.
+Test 17 No nested savepoints allowed when using SQL to set savepoints.
+Test 17a Test with UNIQUE clause.
+Expected Exception is The maximum number of savepoints has been reached. 
+Test 17b Test without UNIQUE clause.
+Since no nesting is allowed, skipping UNIQUE still gives error for trying to define another savepoint
+Expected Exception is The maximum number of savepoints has been reached. 
+Test 18 No nested SQL savepoints allowed inside JDBC savepoint.
+Following SQL savepoint will fail because we are trying to nest it inside JDBC savepoint
+Expected Exception is The maximum number of savepoints has been reached. 
+Test 19 No nested SQL savepoints allowed inside SQL savepoint.
+Following SQL savepoint will fail because we are trying to nest it inside SQL savepoint
+Expected Exception is The maximum number of savepoints has been reached. 
+Test 20 Rollback of SQL savepoint works same as rollback of JDBC savepoint.
+Test 21 After releasing the SQL savepoint, rollback the transaction and should see everything undone.
+Test 22 Should not be able to create a SQL savepoint starting with name SYS
+Expected Exception is An object cannot be created with the schema name 'SYS'.
+Test 23 Should be able to use non-reserved keywords savepoint and release as identifiers
+Create table with savepoint and release as identifiers
+Create a savepoint with name savepoint
+Release the savepoint with name savepoint
+Create a savepoint with name release
+Rollback to the savepoint with name release
+Release the savepoint with name release
+Test 24 Savepoint name can't exceed 128 characters
+Expected Exception is The name 'MyName1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' is too long. The maximum length is '128'.
+Test 25 Should not be able to create a SQL savepoint starting with name SYS through jdbc
+Expected Exception is An object cannot be created with the schema name 'SYS'.
+Test 26a rollback of null savepoint
+Expected Exception is SAVEPOINT, null does not  exist or is not active in the current transaction.
+Test 26b release  of null savepoint
+Expected Exception is SAVEPOINT, null does not  exist or is not active in the current transaction.
+Next try non-DRDA tests
+Test40 - named savepoint can't conflict with internally generated name for unnamed savepoints
+Test41a - Rollback to a savepoint, then try to release savepoint created after that savepoint
+Expected Exception is SAVEPOINT, s2 does not  exist or is not active in the current transaction.
+Test41b - Rollback to a savepoint, then try to rollback savepoint created after that savepoint
+Expected Exception is SAVEPOINT, s2 does not  exist or is not active in the current transaction.
+Test42 - Rollback/commit the transaction, then try to use savepoint from that transaction
+Expected Exception is SAVEPOINT, SAVEPT5 does not  exist or is not active in the current transaction.
+Expected Exception is SAVEPOINT, SAVEPT6 does not  exist or is not active in the current transaction.
+Test43 - Release and reuse a savepoint name
+Expected Exception is A SAVEPOINT with the passed name already exists in the current transaction.
+Test 45 reuse savepoint name after rollback - should not work
+Expected Exception is A SAVEPOINT with the passed name already exists in the current transaction.
+Test 46 Cursors declared before and within the savepoint unit will be closed when rolling back the savepoint
+Expected Exception is ResultSet not open. Operation 'next' not permitted. Verify that autocommit is OFF.
+Expected Exception is ResultSet not open. Operation 'next' not permitted. Verify that autocommit is OFF.
+Expected Exception is ResultSet not open. Operation 'next' not permitted. Verify that autocommit is OFF.
+Expected Exception is ResultSet not open. Operation 'next' not permitted. Verify that autocommit is OFF.
+Test 47 multiple tests for getSavepointId()
+8
+9
+10
+11
+12
+Test 48 No nested SQL savepoints allowed.
+Following SQL savepoint will fail because we are trying to nest it inside JDBC savepoint
+Expected Exception is The maximum number of savepoints has been reached. 
+Expected Exception is The maximum number of savepoints has been reached. 
+Test savepointJdbc30 finished for connections from XADataSource (local tranasaction)

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/savepointJdbc30.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/savepointJdbc30.java?rev=374742&r1=374741&r2=374742&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/savepointJdbc30.java (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/savepointJdbc30.java Fri Feb  3 13:00:35 2006
@@ -27,6 +27,9 @@
 import java.sql.Statement;
 import java.sql.SQLException;
 import java.sql.Types;
+import java.util.Properties;
+
+import javax.sql.XADataSource;
 
 import org.apache.derby.tools.ij;
 import org.apache.derby.tools.JDBCDisplayUtil;
@@ -45,21 +48,50 @@
 	static private boolean isDerbyNet = false;
 
 	public static void main(String[] args) {
-		Connection con = null, con2 = null;
-		Statement  s;
-		System.out.println("Test savepointJdbc30 starting");
-
-		try
-		{
-			// use the ij utility to read the property file and
-			// make the initial connection.
-			ij.getPropertyArg(args);
-			con = ij.startJBMS();
-			isDerbyNet = TestUtil.isNetFramework();
+	    // Check savepoints for both regular connections and XA
+	    
+	    Connection con = null, con2 = null;
+	    isDerbyNet = TestUtil.isNetFramework();
+	    
+	    try {
+	    //	  use the ij utility to read the property file and
+		// make the initial connection.
+		ij.getPropertyArg(args);
+		con = ij.startJBMS();
+		con2 = ij.startJBMS();
+		runTests("regular connections", con,con2);
+		con.close();
+		con2.close();
+		if (TestUtil.isJCCFramework())  // no xa for jcc
+		    return;
+		
+		// Test connections obtained via XADataSource DERBY-899
+		Properties dsprops = new Properties();
+		dsprops.setProperty("databaseName","wombat");
+		XADataSource ds  = TestUtil.getXADataSource(dsprops);
+		con = ds.getXAConnection().getConnection();
+		con2 = ds.getXAConnection().getConnection();
+		runTests("connections from XADataSource (local tranasaction)", 
+				 con, con2);
+		con.close();
+		con2.close();
+	    }
+		catch (SQLException e) {
+		    dumpSQLExceptions(e);
+				}
+		catch (Throwable e) {
+			System.out.println("FAIL -- unexpected exception:");
+			e.printStackTrace(System.out);
+		}
 
+	}
+	public static void runTests(String tag, Connection con, Connection con2) 
+	throws SQLException {
+		Statement  s;
+		System.out.println("Test savepointJdbc30 starting for "  + tag);
+		
 			con.setAutoCommit(true); // make sure it is true
 			s = con.createStatement();
-			con2 = ij.startJBMS();
 			con2.setAutoCommit(false);
 			/* Create the table and do any other set-up */
 			setUpTest(s);
@@ -78,18 +110,9 @@
 				nonDRDATests(con, s);
 
 			s.close();
-			con.close();
-			con2.close();
-		}
-		catch (SQLException e) {
-			dumpSQLExceptions(e);
-		}
-		catch (Throwable e) {
-			System.out.println("FAIL -- unexpected exception:");
-			e.printStackTrace(System.out);
-		}
-
-		System.out.println("Test savepointJdbc30 finished");
+			
+	
+		System.out.println("Test savepointJdbc30 finished for " + tag);
 	}
 
 	//The following tests have nested savepoints through JDBC calls. When coming through JCC,
@@ -873,7 +896,15 @@
 	//Set up the test by creating the table used by the rest of the test.
 	static void setUpTest(Statement s)
 					throws SQLException {
-		/* Create a table */
+		/* drop and create tables */
+	    try {
+	        s.execute("drop table t1");
+	    }catch (SQLException e){};
+	    
+	    try {
+	        s.execute("drop table t2");
+	    }catch (SQLException e){};
+	    
 		s.execute("create table t1 (c11 int, c12 smallint)");
 		s.execute("create table t2 (c11 int)");