db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r381549 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/ testing/org/apache/derbyTesting/func...
Date Tue, 28 Feb 2006 03:42:34 GMT
Author: djd
Date: Mon Feb 27 19:42:32 2006
New Revision: 381549

URL: http://svn.apache.org/viewcvs?rev=381549&view=rev
Log:
DERBY-1006 Disallow holdable cursor setting at the connection and statement
level while in a global transaction for the client driver. Matches the embedded
as the holdable cursors are not supported in global (XA) transactions.

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/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/tests/jdbcapi/XATest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?rev=381549&r1=381548&r2=381549&view=diff
==============================================================================
--- 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 Mon Feb 27
19:42:32 2006
@@ -1192,6 +1192,15 @@
                 agent_.logWriter_.traceEntry(this, "setHoldability", holdability);
             }
             checkForClosedConnection();
+            // In an XA global transaction do not allow the
+            // holdability to be set to hold cursors across
+            // commits, as the engine does not support it.
+            if (this.isXAConnection_ && this.xaState_ == XA_T1_ASSOCIATED)
+            {
+                if (holdability == JDBC30Translation.HOLD_CURSORS_OVER_COMMIT)
+                    throw new SqlException(agent_.logWriter_, 
+                            new MessageId(SQLState.CANNOT_HOLD_CURSOR_XA));
+            }
             this.holdability = holdability;
             
        }
@@ -1442,6 +1451,15 @@
         checkForClosedConnection();
         resultSetType = downgradeResultSetType(resultSetType);
         resultSetConcurrency = downgradeResultSetConcurrency(resultSetConcurrency, resultSetType);
+        // In an XA global transaction do not allow the
+        // holdability to be set to hold cursors across
+        // commits, as the engine does not support it.
+        if (this.isXAConnection_ && this.xaState_ == XA_T1_ASSOCIATED)
+        {
+            if (resultSetHoldability == JDBC30Translation.HOLD_CURSORS_OVER_COMMIT)
+                throw new SqlException(agent_.logWriter_, 
+                        new MessageId(SQLState.CANNOT_HOLD_CURSOR_XA));
+        }
         Statement s = newStatement_(resultSetType, resultSetConcurrency, resultSetHoldability);
         s.cursorAttributesToSendOnPrepare_ = s.cacheCursorAttributesToSendOnPrepare();
         openStatements_.add(s);

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=381549&r1=381548&r2=381549&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
Mon Feb 27 19:42:32 2006
@@ -191,5 +191,8 @@
 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.
+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.
 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=381549&r1=381548&r2=381549&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
Mon Feb 27 19:42:32 2006
@@ -176,5 +176,8 @@
 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.
+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.
 derby966 complete
 XATest complete

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=381549&r1=381548&r2=381549&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
Mon Feb 27 19:42:32 2006
@@ -941,11 +941,42 @@
                 TestUtil.dumpSQLExceptions(e, true);
             }
             pscc.executeQuery().close();
+                   
+            // Test we cannot switch the connection to holdable
+            // or create a statement with holdable.
+            try {
+                conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
+                System.out.println("FAIL - set holdability in global xact.");
+            } catch (SQLException sqle)
+            {
+                TestUtil.dumpSQLExceptions(sqle, true);
+            }
             
+            try {
+                    conn.createStatement(
+                    ResultSet.TYPE_FORWARD_ONLY,
+                    ResultSet.CONCUR_READ_ONLY,
+                    ResultSet.HOLD_CURSORS_OVER_COMMIT);
+                    System.out.println("FAIL - Statement holdability in global xact.");
+            } catch (SQLException sqle) {
+                TestUtil.dumpSQLExceptions(sqle, true);
+            }
+            try {
+                conn.prepareStatement(
+                "SELECT * FROM APP.FOO",
+                ResultSet.TYPE_FORWARD_ONLY,
+                ResultSet.CONCUR_READ_ONLY,
+                ResultSet.HOLD_CURSORS_OVER_COMMIT);
+                System.out.println("FAIL - PreparedStatement holdability in global xact.");
+        } catch (SQLException sqle) {
+            TestUtil.dumpSQLExceptions(sqle, true);
+        }
             xar.end(xid, XAResource.TMSUCCESS);
             if (xar.prepare(xid) != XAResource.XA_RDONLY)
                 System.out.println("FAIL prepare didn't indicate r/o");
             
+            conn.close();
+            
             System.out.println("derby966 complete");
                 
         } catch (SQLException e) {
@@ -1050,4 +1081,77 @@
         return s + Integer.toString(holdability);
     }
     
+    /*
+     * 5 interleaving transactions.
+     * Taken from the SQL test xaANotherTest.
+     * <code>
+xa_connect user 'mamta' password 'mamta' ;
+
+-- global connection 1
+xa_start xa_noflags 1;
+xa_getconnection;
+insert into APP.foo values (1);
+xa_end xa_suspend 1;
+
+-- global connection 2
+xa_start xa_noflags 2;
+insert into APP.foo values (2);
+xa_end xa_suspend 2;
+
+-- global connection 3
+xa_start xa_noflags 3;
+insert into APP.foo values (3);
+xa_end xa_suspend 3;
+
+-- global connection 4
+xa_start xa_noflags 4;
+insert into APP.foo values (4);
+xa_end xa_suspend 4;
+
+-- global connection 5
+xa_start xa_noflags 5;
+insert into APP.foo values (5);
+xa_end xa_suspend 5;
+
+xa_start xa_resume 1;
+insert into APP.foo values (11);
+xa_end xa_suspend 1;
+
+xa_start xa_resume 5;
+insert into APP.foo values (55);
+xa_end xa_suspend 5;
+
+xa_start xa_resume 2;
+insert into APP.foo values (22);
+xa_end xa_suspend 2;
+
+xa_start xa_resume 4;
+insert into APP.foo values (44);
+xa_end xa_suspend 4;
+
+xa_start xa_resume 3;
+insert into APP.foo values (33);
+xa_end xa_suspend 3;
+
+-- prepare all the global connections except the first one. This way, we will see all
+-- the global transactions prepared so far after the database shutdown and restart.
+xa_end xa_success 2;
+xa_prepare 2;
+xa_end xa_success 3;
+xa_prepare 3;
+xa_end xa_success 4;
+xa_prepare 4;
+xa_end xa_success 5;
+xa_prepare 5;
+
+     * </code>
+     */
+    private static void interleavingTransactions5(XADataSource xads) throws SQLException
+    {
+        System.out.println("interleavingTransactions5");
+        
+        XAConnection xac = xads.getXAConnection("mamta", "mamtapwd");
+        
+    }
+ 
 }



Mime
View raw message