db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r392073 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/jdbc/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/...
Date Thu, 06 Apr 2006 21:01:20 GMT
Author: djd
Date: Thu Apr  6 14:01:15 2006
New Revision: 392073

URL: http://svn.apache.org/viewcvs?rev=392073&view=rev
Log:
DERBY-1158 (partial) Embedded Statements that are holdable automatically downgrade to
close cursors on commit during a global transaction.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
    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/XATest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
Thu Apr  6 14:01:15 2006
@@ -55,7 +55,6 @@
      */
 	public final ResultSet executeQuery() throws SQLException
     {
-        checkHoldability();
         return wrapResultSet(getPreparedStatement().executeQuery());
     } 
 
@@ -423,7 +422,6 @@
      */
     public final boolean execute() throws SQLException
     {
-        checkHoldability();
         return getPreparedStatement().execute();
     }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java Thu
Apr  6 14:01:15 2006
@@ -101,14 +101,12 @@
 
     public final boolean execute(String sql) throws SQLException
 	{
-        checkHoldability();
 		return getStatement().execute(sql);
     } 
 
     public final ResultSet executeQuery(String sql) throws SQLException
 	{
-        checkHoldability();
-		return wrapResultSet(getStatement().executeQuery(sql));
+ 		return wrapResultSet(getStatement().executeQuery(sql));
     }
 
     public final int executeUpdate(String sql) throws SQLException
@@ -541,11 +539,4 @@
 		getStatement().getConnection();
 		return control;
 	}
-    
-    final void checkHoldability() throws SQLException {
-        int holdability = controlCheck().checkHoldCursors(resultSetHoldability);
-        if (holdability != resultSetHoldability)
-            throw Util.generateCsSQLException(SQLState.CANNOT_HOLD_CURSOR_XA);
-
-    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java Thu Apr
 6 14:01:15 2006
@@ -62,6 +62,14 @@
     implements EngineStatement {
 
 	private final java.sql.Connection applicationConnection;
+    
+    /**
+     * Statement reference the application is using to execute
+     * this Statement. Normally set to this, but if this was
+     * created by a Connection from an XAConnection then this
+     * will be a reference to the BrokeredStatement.
+     */
+    private EngineStatement applicationStatement;
 
 	int updateCount = -1;
 	java.sql.ResultSet results;
@@ -111,6 +119,7 @@
 
 		lcc = getEmbedConnection().getLanguageConnection();
 		applicationConnection = getEmbedConnection().getApplicationConnection();
+        applicationStatement = this;
 
         // By default, no statements time out.
         // Timeout is set explicitly with setQueryTimeout().
@@ -1419,7 +1428,13 @@
 			batchStatements = null;
 		}
 	}
-
+    
+    /**
+     * Set the application statement for this Statement.
+    */
+    public final void setApplicationStatement(EngineStatement s) {
+        this.applicationStatement = s;
+    }
 
 	private EmbedResultSet[] dynamicResults;
 	private int currentDynamicResultSet;
@@ -1533,13 +1548,19 @@
     /**
      * Get the execute time holdability for the Statement.
      * When in a global transaction holdabilty defaults to false.
+     * @throws SQLException Error from getResultSetHoldability.
      */
-    private boolean getExecuteHoldable()
+    private boolean getExecuteHoldable() throws SQLException
     {
         if (resultSetHoldability  == JDBC30Translation.CLOSE_CURSORS_AT_COMMIT)
             return false;
         
-        return true;
+        // Simple non-XA case
+        if (applicationStatement == this)
+            return true;
+        
+        return applicationStatement.getResultSetHoldability() ==
+            JDBC30Translation.HOLD_CURSORS_OVER_COMMIT;
     }
 }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/XAStatementControl.java Thu Apr
 6 14:01:15 2006
@@ -25,6 +25,7 @@
 import org.apache.derby.iapi.jdbc.BrokeredStatement;
 import org.apache.derby.iapi.jdbc.BrokeredPreparedStatement;
 import org.apache.derby.iapi.jdbc.BrokeredCallableStatement;
+import org.apache.derby.iapi.jdbc.EngineStatement;
 import org.apache.derby.impl.jdbc.EmbedConnection;
 import org.apache.derby.impl.jdbc.EmbedResultSet;
 import org.apache.derby.impl.jdbc.EmbedStatement;
@@ -60,6 +61,9 @@
 		this(xaConnection);
 		this.realStatement = realStatement;
 		this.applicationStatement = applicationConnection.newBrokeredStatement(this);
+        
+        ((EmbedStatement) realStatement).setApplicationStatement(
+                applicationStatement);
 	}
 	XAStatementControl(EmbedPooledConnection xaConnection, 
                 PreparedStatement realPreparedStatement, 
@@ -67,6 +71,8 @@
 		this(xaConnection);
 		this.realPreparedStatement = realPreparedStatement;
 		this.applicationStatement = applicationConnection.newBrokeredStatement(this, sql, generatedKeys);
+        ((EmbedStatement) realPreparedStatement).setApplicationStatement(
+                applicationStatement);
 	}
 	XAStatementControl(EmbedPooledConnection xaConnection, 
                 CallableStatement realCallableStatement, 
@@ -74,6 +80,8 @@
 		this(xaConnection);
 		this.realCallableStatement = realCallableStatement;
 		this.applicationStatement = applicationConnection.newBrokeredStatement(this, sql);
+        ((EmbedStatement) realCallableStatement).setApplicationStatement(
+                applicationStatement);
 	}
 
 	public Statement getRealStatement() throws SQLException {
@@ -96,7 +104,7 @@
 			// create new Statement
 			Statement newStatement = applicationStatement.createDuplicateStatement(xaConnection.realConnection,
realStatement);
 			((EmbedStatement) realStatement).transferBatch((EmbedStatement) newStatement);
-
+ 
 			try {
 				realStatement.close();
 			} catch (SQLException sqle) {
@@ -104,6 +112,8 @@
 
 			realStatement = newStatement;
 			realConnection = xaConnection.realConnection;
+            ((EmbedStatement) realStatement).setApplicationStatement(
+                    applicationStatement);
 		}
 		else {
 			// application connection is different, therefore the outer application
@@ -143,6 +153,8 @@
 
 			realPreparedStatement = newPreparedStatement;
 			realConnection = xaConnection.realConnection;
+            ((EmbedStatement) realPreparedStatement).setApplicationStatement(
+                        applicationStatement);
 		}
 		else {
 			// application connection is different, therefore the outer application
@@ -179,6 +191,8 @@
 
 			realCallableStatement = newCallableStatement;
 			realConnection = xaConnection.realConnection;
+            ((EmbedStatement) realCallableStatement).setApplicationStatement(
+                    applicationStatement);
 		}
 		else {
 			// application connection is different, therefore the outer application

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
Thu Apr  6 14:01:15 2006
@@ -323,8 +323,6 @@
   auto commit     true
   read only       false
 TESTING RE_USE OF STATEMENT OBJECTS
-THE STATEMENT OBJECTS CAN NOT BE REUSED ACROSS LOCAL/GLOBAL CONNECTIONS BECAUSE, LOCAL CONNECTION
CREATES THEM
-WITH HOLDABILITY TRUE WHEREAS GLOBAL CONNECTION CAN ONLY WORK WITH STATEMENTS WITH HOLDABILITY
FALSE
 LOCK TABLE
 END LOCK TABLE
 Statement State @ Create 
@@ -351,12 +349,12 @@
 Params-local-1: ru(params) contents {3}
 sru1-local-1: mismatched Statement connection
 sru1-local-1: ru(SN1) contents {1} {2} {3}
-Expecting exception because global transaction sru1-global-2 is trying to use a statement
with holdability true
+Expecting downgrade because global transaction sru1-global-2 is using a statement with holdability
true
 sru1-global-2: mismatched Statement connection
 sru1-global-2: ru(SQL_CURLH000C) contents {1} {2} {3}
 sru2-global-3: mismatched Statement connection
 sru2-global-3: ru(OAK2) contents {1} {2} {3}
-Expecting exception because global transaction sru1-global-4 is trying to use a statement
with holdability true
+Expecting downgrade because global transaction sru1-global-4 is using a statement with holdability
true
 sru1-global-4: mismatched Statement connection
 sru1-global-4: ru(SQL_CURLH000C) contents {1} {2} {3}
 Statement State @ GLOBAL 
@@ -380,8 +378,7 @@
   getFetchSize() 999
   getMaxFieldSize() 137
   getMaxRows() 85
-PASS: got exception because holdability is true on prepared statement and that is not allowed
in global transactions
-Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
+Params-global-1: ru(SQL_CURLH000C) contents {3}
 sru1-local-5: mismatched Statement connection
 sru1-local-5: ru(SQL_CURLH000C) contents {1} {2} {3}
 sru2-local-6: mismatched Statement connection
@@ -410,7 +407,7 @@
   getMaxFieldSize() 137
   getMaxRows() 85
 LOCK TABLE
-  xid row 0 lock count 12
+  xid row 0 lock count 14
   xid row 1 lock count 12
 END LOCK TABLE
 sru1-local-8: mismatched Statement connection
@@ -441,7 +438,7 @@
   getMaxFieldSize() 137
   getMaxRows() 85
 LOCK TABLE
-  xid row 0 lock count 12
+  xid row 0 lock count 14
   xid row 1 lock count 12
 END LOCK TABLE
 sruBatch update counts : 1  1  2  1 :

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
Thu Apr  6 14:01:15 2006
@@ -386,8 +386,6 @@
   auto commit     true
   read only       false
 TESTING RE_USE OF STATEMENT OBJECTS
-THE STATEMENT OBJECTS CAN NOT BE REUSED ACROSS LOCAL/GLOBAL CONNECTIONS BECAUSE, LOCAL CONNECTION
CREATES THEM
-WITH HOLDABILITY TRUE WHEREAS GLOBAL CONNECTION CAN ONLY WORK WITH STATEMENTS WITH HOLDABILITY
FALSE
 LOCK TABLE
 END LOCK TABLE
 Statement State @ Create 
@@ -422,12 +420,12 @@
 Params-local-1: ru(params) contents {3}
 sru1-local-1: mismatched Statement connection
 sru1-local-1: ru(SN1) contents {1} {2} {3}
-Expecting exception because global transaction sru1-global-2 is trying to use a statement
with holdability true
+Expecting downgrade because global transaction sru1-global-2 is using a statement with holdability
true
 sru1-global-2: mismatched Statement connection
 sru1-global-2: ru(SQL_CURLH000C) contents {1} {2} {3}
 sru2-global-3: mismatched Statement connection
 sru2-global-3: ru(OAK2) contents {1} {2} {3}
-Expecting exception because global transaction sru1-global-4 is trying to use a statement
with holdability true
+Expecting downgrade because global transaction sru1-global-4 is using a statement with holdability
true
 sru1-global-4: mismatched Statement connection
 sru1-global-4: ru(SQL_CURLH000C) contents {1} {2} {3}
 Statement State @ GLOBAL 
@@ -459,8 +457,7 @@
   Parameter Count 2
     1 type 12
     2 type 12
-PASS: got exception because holdability is true on prepared statement and that is not allowed
in global transactions
-Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
+Params-global-1: ru(SQL_CURLH000C) contents {3}
 sru1-local-5: mismatched Statement connection
 sru1-local-5: ru(SQL_CURLH000C) contents {1} {2} {3}
 sru2-local-6: mismatched Statement connection
@@ -497,7 +494,7 @@
     1 type 12
     2 type 12
 LOCK TABLE
-  xid row 0 lock count 12
+  xid row 0 lock count 14
   xid row 1 lock count 12
 END LOCK TABLE
 sru1-local-8: mismatched Statement connection
@@ -536,7 +533,7 @@
     1 type 12
     2 type 12
 LOCK TABLE
-  xid row 0 lock count 12
+  xid row 0 lock count 14
   xid row 1 lock count 12
 END LOCK TABLE
 sruBatch update counts : 1  1  2  1 :

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
Thu Apr  6 14:01:15 2006
@@ -185,13 +185,23 @@
 BGAC 1
 DERBY-1025 Call conn.commit to avoid exception with client
 START GLOBAL TRANSACTION
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a
global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a
global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a
global transaction.
+Global transaction open ResultSets 12
 EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a
global transaction.
 Global createStatement(hold)Statement holdable CLOSE_CURSORS_AT_COMMIT 2
 01J07 :java.sql.SQLWarning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT
for a global transaction.
 Global prepareStatement(hold)Statement holdable HOLD_CURSORS_OVER_COMMIT 1
-01J07 :java.sql.SQLWarning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT
for a global transaction.
+After global transaction closed ResultSets 12
+Global xact Statement sdh Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement shh Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement sch Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement psdh Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement pshh Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement psch Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement sdc Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement shc Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement scc Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement psdh_d Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement pshh_d Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement psch_d Statement holdable CLOSE_CURSORS_AT_COMMIT 2
 derby966 complete
 XATest complete

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
Thu Apr  6 14:01:15 2006
@@ -169,14 +169,36 @@
 BGBC 0
 BGAC 1
 START GLOBAL TRANSACTION
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a
global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a
global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a
global transaction.
+Global transaction open ResultSets 12
 EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a
global transaction.
 Global createStatement(hold)Statement holdable CLOSE_CURSORS_AT_COMMIT 2
 01J07 :SQL Warning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT
for a global transaction.
 Global prepareStatement(hold)Statement holdable CLOSE_CURSORS_AT_COMMIT 2
 01J07 :SQL Warning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT
for a global transaction.
-01J07 :SQL Warning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT
for a global transaction.
+Global xact Statement sdh Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement shh Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement sch Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement psdh Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement pshh Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement psch Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement sdc Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement shc Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement scc Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement psdh_d Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement pshh_d Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement psch_d Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+After global transaction closed ResultSets 12
+Global xact Statement sdh Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement shh Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement sch Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement psdh Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement pshh Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement psch Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement sdc Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement shc Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement scc Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+Global xact Statement psdh_d Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement pshh_d Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+Global xact Statement psch_d Statement holdable CLOSE_CURSORS_AT_COMMIT 2
 derby966 complete
 XATest complete

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource.out?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- 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
Thu Apr  6 14:01:15 2006
@@ -397,8 +397,6 @@
   auto commit     true
   read only       false
 TESTING RE_USE OF STATEMENT OBJECTS
-THE STATEMENT OBJECTS CAN NOT BE REUSED ACROSS LOCAL/GLOBAL CONNECTIONS BECAUSE, LOCAL CONNECTION
CREATES THEM
-WITH HOLDABILITY TRUE WHEREAS GLOBAL CONNECTION CAN ONLY WORK WITH STATEMENTS WITH HOLDABILITY
FALSE
 LOCK TABLE
 END LOCK TABLE
 Statement State @ Create 
@@ -424,11 +422,11 @@
   getMaxRows() 85
 Params-local-1: ru(params) contents {3}
 sru1-local-1: ru(SN1) contents {1} {2} {3}
-Expecting exception because global transaction sru1-global-2 is trying to use a statement
with holdability true
-sru1-global-2: SQL Exception: Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for
a global transaction.
+Expecting downgrade because global transaction sru1-global-2 is using a statement with holdability
true
+sru1-global-2: ru(SN1) contents {1} {2} {3}
 sru2-global-3: ru(OAK2) contents {1} {2} {3}
-Expecting exception because global transaction sru1-global-4 is trying to use a statement
with holdability true
-sru1-global-4: SQL Exception: Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for
a global transaction.
+Expecting downgrade because global transaction sru1-global-4 is using a statement with holdability
true
+sru1-global-4: ru(SN1) contents {1} {2} {3}
 Statement State @ GLOBAL 
   getResultSetType() SCROLL_INSENSITIVE
   getResultSetConcurrency() READ_ONLY
@@ -450,8 +448,7 @@
   getFetchSize() 999
   getMaxFieldSize() 137
   getMaxRows() 85
-PASS: got exception because holdability is true on prepared statement and that is not allowed
in global transactions
-Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
+Params-global-1: ru(params) contents {3}
 sru1-local-5: ru(SN1) contents {1} {2} {3}
 sru2-local-6: ru(OAK2) contents {1} {2} {3}
 sru3-local-7: ru(SF3) contents {1} {2} {3}
@@ -478,7 +475,7 @@
   getMaxRows() 85
 Params-local-2: ru(params) contents {3}
 LOCK TABLE
-  xid row 0 lock count 4
+  xid row 0 lock count 14
   xid row 1 lock count 14
 END LOCK TABLE
 sru1-local-8: ru(SN1) contents {1} {2} {3}
@@ -506,7 +503,7 @@
   getMaxFieldSize() 137
   getMaxRows() 85
 LOCK TABLE
-  xid row 0 lock count 4
+  xid row 0 lock count 14
   xid row 1 lock count 12
 END LOCK TABLE
 sruBatch update counts : 1  1  2  1 :

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- 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
Thu Apr  6 14:01:15 2006
@@ -488,8 +488,6 @@
   auto commit     true
   read only       false
 TESTING RE_USE OF STATEMENT OBJECTS
-THE STATEMENT OBJECTS CAN NOT BE REUSED ACROSS LOCAL/GLOBAL CONNECTIONS BECAUSE, LOCAL CONNECTION
CREATES THEM
-WITH HOLDABILITY TRUE WHEREAS GLOBAL CONNECTION CAN ONLY WORK WITH STATEMENTS WITH HOLDABILITY
FALSE
 LOCK TABLE
 END LOCK TABLE
 Statement State @ Create 
@@ -523,11 +521,11 @@
     2 type 12
 Params-local-1: ru(params) contents {3}
 sru1-local-1: ru(SN1) contents {1} {2} {3}
-Expecting exception because global transaction sru1-global-2 is trying to use a statement
with holdability true
-sru1-global-2: SQL Exception: Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for
a global transaction.
+Expecting downgrade because global transaction sru1-global-2 is using a statement with holdability
true
+sru1-global-2: ru(SN1) contents {1} {2} {3}
 sru2-global-3: ru(OAK2) contents {1} {2} {3}
-Expecting exception because global transaction sru1-global-4 is trying to use a statement
with holdability true
-sru1-global-4: SQL Exception: Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for
a global transaction.
+Expecting downgrade because global transaction sru1-global-4 is using a statement with holdability
true
+sru1-global-4: ru(SN1) contents {1} {2} {3}
 Statement State @ GLOBAL 
   getResultSetType() SCROLL_INSENSITIVE
   getResultSetConcurrency() READ_ONLY
@@ -557,8 +555,7 @@
   Parameter Count 2
     1 type 12
     2 type 12
-PASS: got exception because holdability is true on prepared statement and that is not allowed
in global transactions
-Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
+Params-global-1: ru(params) contents {3}
 sru1-local-5: ru(SN1) contents {1} {2} {3}
 sru2-local-6: ru(OAK2) contents {1} {2} {3}
 sru3-local-7: ru(SF3) contents {1} {2} {3}
@@ -593,7 +590,7 @@
     2 type 12
 Params-local-2: ru(params) contents {3}
 LOCK TABLE
-  xid row 0 lock count 4
+  xid row 0 lock count 14
   xid row 1 lock count 14
 END LOCK TABLE
 sru1-local-8: ru(SN1) contents {1} {2} {3}
@@ -629,7 +626,7 @@
     1 type 12
     2 type 12
 LOCK TABLE
-  xid row 0 lock count 4
+  xid row 0 lock count 14
   xid row 1 lock count 12
 END LOCK TABLE
 sruBatch update counts : 1  1  2  1 :
@@ -864,14 +861,8 @@
 HOLDABLE PreparedStatement in global xact false connection warning ResultSetHoldability restricted
to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
 HOLDABLE CallableStatement in global xact false connection warning ResultSetHoldability restricted
to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
 STATEMENT HOLDABILITY false
-Expected SQLException (local Statement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT
for a global transaction.
-Expected SQLException (local Statement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT
for a global transaction.
 PREPARED STATEMENT HOLDABILITY false
-Expected SQLException (local PreparedStatement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT
for a global transaction.
-Expected SQLException (local PreparedStatement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT
for a global transaction.
 CALLABLE STATEMENT HOLDABILITY false
-Expected SQLException (local CallableStatement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT
for a global transaction.
-Expected SQLException (local CallableStatement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT
for a global transaction.
 CONNECTION(held) HOLDABILITY true
 PASS XA HOLDABILITY TEST
 **Test holdability state for: PooledConnection **

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
Thu Apr  6 14:01:15 2006
@@ -26,6 +26,8 @@
 import java.sql.SQLException;
 import java.sql.SQLWarning;
 import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.Properties;
 
 import javax.sql.XAConnection;
@@ -916,15 +918,6 @@
             // start a global xact and test those statements.
             xar.start(xid, XAResource.TMNOFLAGS);
             
-            // Statements obtained while default was hold.
-            // All should work, holability will be downgraded
-            // to close on commit for those Statements with hold set.
-            if (TestUtil.isDerbyNetClientFramework()) { // DERBY-1158
-            sdh.executeQuery("SELECT * FROM APP.FOO").close();
-            shh.executeQuery("SELECT * FROM APP.FOO").close();
-            }
-            sch.executeQuery("SELECT * FROM APP.FOO").close();
-                        
             // Statements not returning ResultSet's should be ok
             if (!TestUtil.isDerbyNetClientFramework()) { // DERBY-1159
             sdh.executeUpdate("DELETE FROM APP.FOO where A < -99");
@@ -932,22 +925,21 @@
             sch.executeUpdate("DELETE FROM APP.FOO where A < -99");
             }
             
+            ArrayList openRS = new ArrayList();
+            
+            // Statements obtained while default was hold.
+            // All should work, holability will be downgraded
+            // to close on commit for those Statements with hold set.
+            openRS.add(sdh.executeQuery("SELECT * FROM APP.FOO"));
+            openRS.add(shh.executeQuery("SELECT * FROM APP.FOO"));
+            openRS.add(sch.executeQuery("SELECT * FROM APP.FOO"));
+
             
             // PreparedStatements obtained while default was hold.
-            // Only sch should work as held cursors not supported in XA
-            try {
-                psdh.executeQuery().close();
-                System.out.println("FAIL - held Statement in global psdf");
-            } catch (SQLException e) {
-                TestUtil.dumpSQLExceptions(e, true);
-            }
-            try {
-                pshh.executeQuery().close();
-                System.out.println("FAIL - held Statement in global pshh");
-            } catch (SQLException e) {
-                TestUtil.dumpSQLExceptions(e, true);
-            }
-            psch.executeQuery().close();
+            // Holdability should be downgraded.
+            openRS.add(psdh.executeQuery());
+            openRS.add(pshh.executeQuery());
+            openRS.add(psch.executeQuery());
             
             // Statements not returning ResultSet's should be ok
             if (!TestUtil.isDerbyNetClientFramework()) { // DERBY-1159
@@ -955,31 +947,24 @@
             pshh_d.executeUpdate();
             psch_d.executeUpdate();
             }
-             
-            // Statements obtained while default was close.
-            // Only sch should work as held cursors not supported in XA
-            sdc.executeQuery("SELECT * FROM APP.FOO").close();
-            if (TestUtil.isDerbyNetClientFramework()) { // DERBY-1158
-            shc.executeQuery("SELECT * FROM APP.FOO").close();
-            }
-            scc.executeQuery("SELECT * FROM APP.FOO").close();
-            
+
             // Statements not returning ResultSet's should be ok
             if (!TestUtil.isDerbyNetClientFramework()) { // DERBY-1159
             sdc.executeUpdate("DELETE FROM APP.FOO where A < -99");
             shc.executeUpdate("DELETE FROM APP.FOO where A < -99");
             scc.executeUpdate("DELETE FROM APP.FOO where A < -99");
-            }
+            }             
+ 
+            // Statements obtained while default was close.
+            // all should return close on commit ResultSets
+            openRS.add(sdc.executeQuery("SELECT * FROM APP.FOO"));
+            openRS.add(shc.executeQuery("SELECT * FROM APP.FOO"));
+            openRS.add(scc.executeQuery("SELECT * FROM APP.FOO"));
             
             // PreparedStatements obtained while default was close.
-           psdc.executeQuery().close();
-           try {
-                pshc.executeQuery().close();
-                System.out.println("FAIL - held Statement in global");
-            } catch (SQLException e) {
-                TestUtil.dumpSQLExceptions(e, true);
-            }
-            pscc.executeQuery().close();
+            openRS.add(psdc.executeQuery());
+            openRS.add(pshc.executeQuery());
+            openRS.add(pscc.executeQuery());
             
             // Statements not returning ResultSet's should be ok
             if (!TestUtil.isDerbyNetClientFramework()) { // DERBY-1159
@@ -987,6 +972,19 @@
             pshc_d.executeUpdate();
             pscc_d.executeUpdate();
             }
+            
+            // All the ResultSets should be open. Run a simple
+            // test, clearWarnings throws an error if the ResultSet
+            // is closed. Also would be nice here to use the new
+            // JDBC 4.0 method getHoldabilty to ensure the
+            // holdability is reported correctly.
+            int orsCount = 0;
+            for (Iterator i = openRS.iterator(); i.hasNext();) {
+                ResultSet ors = (ResultSet) i.next();
+                ors.clearWarnings();
+                orsCount++;
+            }
+            System.out.println("Global transaction open ResultSets " + orsCount);
 
                    
             // Test we cannot switch the connection to holdable
@@ -1015,12 +1013,64 @@
                 ResultSet.HOLD_CURSORS_OVER_COMMIT);
             showHoldStatus("Global prepareStatement(hold)", psglobalhold);
             psglobalhold.close();
-
+            
+            if (!TestUtil.isDerbyNetClientFramework()) { //DERBY-1158 in progress
+            // Show the holdability for all the Statements while
+            // in the global transaction, all should be close on commit.
+            showHoldStatus("Global xact Statement sdh ", sdh);
+            showHoldStatus("Global xact Statement shh ", shh);
+            showHoldStatus("Global xact Statement sch ", sch);
+            
+            showHoldStatus("Global xact Statement psdh ", psdh);
+            showHoldStatus("Global xact Statement pshh ", pshh);
+            showHoldStatus("Global xact Statement psch ", psch);
+            
+            showHoldStatus("Global xact Statement sdc ", sdc);
+            showHoldStatus("Global xact Statement shc ", shc);
+            showHoldStatus("Global xact Statement scc ", scc);
+ 
+            showHoldStatus("Global xact Statement psdh_d ", psdh_d);
+            showHoldStatus("Global xact Statement pshh_d ", pshh_d);
+            showHoldStatus("Global xact Statement psch_d ", psch_d);
+            }
+ 
         
             xar.end(xid, XAResource.TMSUCCESS);
             if (xar.prepare(xid) != XAResource.XA_RDONLY)
                 System.out.println("FAIL prepare didn't indicate r/o");
             
+            // All the ResultSets should be closed. Run a simple
+            // test, clearWarnings throws an error if the ResultSet
+            // is closed.
+            int crsCount = 0;
+            for (Iterator i = openRS.iterator(); i.hasNext();) {
+                ResultSet crs = (ResultSet) i.next();
+                try {
+                    crs.clearWarnings();
+                } catch (SQLException sqle) {
+                }
+                crsCount++;
+            }
+            System.out.println("After global transaction closed ResultSets " + crsCount);
+
+            
+            // Check the statements revert to holdable as required.
+            showHoldStatus("Global xact Statement sdh ", sdh);
+            showHoldStatus("Global xact Statement shh ", shh);
+            showHoldStatus("Global xact Statement sch ", sch);
+            
+            showHoldStatus("Global xact Statement psdh ", psdh);
+            showHoldStatus("Global xact Statement pshh ", pshh);
+            showHoldStatus("Global xact Statement psch ", psch);
+ 
+            showHoldStatus("Global xact Statement sdc ", sdc);
+            showHoldStatus("Global xact Statement shc ", shc);
+            showHoldStatus("Global xact Statement scc ", scc);
+            
+            showHoldStatus("Global xact Statement psdh_d ", psdh_d);
+            showHoldStatus("Global xact Statement pshh_d ", pshh_d);
+            showHoldStatus("Global xact Statement psch_d ", psch_d);
+            
             conn.close();
             
             System.out.println("derby966 complete");
@@ -1104,6 +1154,7 @@
             System.out.println(w.getSQLState() + " :" + w.toString());
             w = w.getNextWarning();
         }
+        s.getConnection().clearWarnings();
         
     }
     /**

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- 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
Thu Apr  6 14:01:15 2006
@@ -464,8 +464,6 @@
 
 		// now check re-use of *Statement objects across local/global connections.
 		System.out.println("TESTING RE_USE OF STATEMENT OBJECTS");
-		System.out.println("THE STATEMENT OBJECTS CAN NOT BE REUSED ACROSS LOCAL/GLOBAL CONNECTIONS
BECAUSE, LOCAL CONNECTION CREATES THEM");
-		System.out.println("WITH HOLDABILITY TRUE WHEREAS GLOBAL CONNECTION CAN ONLY WORK WITH
STATEMENTS WITH HOLDABILITY FALSE");
 		cs1 = xac.getConnection();
 
     
@@ -493,24 +491,18 @@
 		cs1.commit(); // need to commit to switch to an global connection;
 		xid = new cdsXid(1, (byte) 103, (byte) 119);
 		xar.start(xid, XAResource.TMNOFLAGS); // simple case - underlying connection is re-used
for global.
-		System.out.println("Expecting exception because global transaction sru1-global-2 is trying
to use a statement with holdability true");
+		System.out.println("Expecting downgrade because global transaction sru1-global-2 is using
a statement with holdability true");
 		queryOnStatement("sru1-global-2", cs1, sru1);
 		sruBatch.addBatch("insert into ru values 5");
 		Statement sru2 = cs1.createStatement();
 		sru2.setCursorName("OAK2");
 		queryOnStatement("sru2-global-3", cs1, sru2);
-		System.out.println("Expecting exception because global transaction sru1-global-4 is trying
to use a statement with holdability true");
+		System.out.println("Expecting downgrade because global transaction sru1-global-4 is using
a statement with holdability true");
 		queryOnStatement("sru1-global-4", cs1, sru1);
 		showStatementState("GLOBAL ", sruState);
 		showStatementState("PS GLOBAL ", psruState);
 		showStatementState("CS GLOBAL ", csruState);
-		try {
-			resultSetQuery("Params-global-1", psParams.executeQuery());
-			System.out.println("FAIL: should have gotten exception because holdability is true on
prepared statement and that is not allowed in global transactions");
-		} catch (SQLException ex) {
-			System.out.println("PASS: got exception because holdability is true on prepared statement
and that is not allowed in global transactions");
-			System.out.println(ex.getMessage());
-		}
+		resultSetQuery("Params-global-1", psParams.executeQuery());
 
 		xar.end(xid, XAResource.TMSUCCESS);
 		// now a new underlying connection is created

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java?rev=392073&r1=392072&r2=392073&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
Thu Apr  6 14:01:15 2006
@@ -355,47 +355,22 @@
            shxa.close();
            
            
-			// check we cannot use a holdable statement set up in local mode.
+			// check we can use a holdable statement set up in local mode.
+            // holdability is downgraded, tested in XATest.java
 			System.out.println("STATEMENT HOLDABILITY " + (sh.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
-			try {
-				sh.executeQuery("select id from hold_30");
-				System.out.println("FAIL used held statement in global transaction");
-			} catch (SQLException sqle) {
-				System.out.println("Expected SQLException (local Statement hold) " + sqle.getMessage());
-			}
-			try {
-				sh.execute("select id from hold_30");
-				System.out.println("FAIL used held statement in global transaction");
-			} catch (SQLException sqle) {
-				System.out.println("Expected SQLException (local Statement hold) " + sqle.getMessage());
-			}
-			System.out.println("PREPARED STATEMENT HOLDABILITY " + (psh.getResultSetHoldability()
== ResultSet.HOLD_CURSORS_OVER_COMMIT));
-			try {
-				psh.executeQuery();
-				System.out.println("FAIL used held prepared statement in global transaction");
-			} catch (SQLException sqle) {
-				System.out.println("Expected SQLException (local PreparedStatement hold) " + sqle.getMessage());
-			}
-			try {
-				psh.execute();
-				System.out.println("FAIL used held prepared statement in global transaction");
-			} catch (SQLException sqle) {
-				System.out.println("Expected SQLException (local PreparedStatement hold) " + sqle.getMessage());
-			}
+			sh.executeQuery("select id from hold_30").close();
+			sh.execute("select id from hold_30");
+            sh.getResultSet().close();
+
+            System.out.println("PREPARED STATEMENT HOLDABILITY " + (psh.getResultSetHoldability()
== ResultSet.HOLD_CURSORS_OVER_COMMIT));
+			psh.executeQuery().close();
+			psh.execute();
+            psh.getResultSet().close();
 
 			System.out.println("CALLABLE STATEMENT HOLDABILITY " + (csh.getResultSetHoldability()
== ResultSet.HOLD_CURSORS_OVER_COMMIT));
-			try {
-				csh.executeQuery();
-				System.out.println("FAIL used held callable statement in global transaction");
-			} catch (SQLException sqle) {
-				System.out.println("Expected SQLException (local CallableStatement hold) " + sqle.getMessage());
-			}
-			try {
-				csh.execute();
-				System.out.println("FAIL used held callable statement in global transaction");
-			} catch (SQLException sqle) {
-				System.out.println("Expected SQLException (local CallableStatement hold) " + sqle.getMessage());
-			}
+			csh.executeQuery().close();
+			csh.execute();
+            csh.getResultSet().close();
 
 			// but an update works
 			sh.executeUpdate("insert into hold_30 values(10, 'init10')");



Mime
View raw message