db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r383732 - in /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests: master/XATest.out tests/jdbcapi/XATest.java util/XATestUtil.java
Date Tue, 07 Mar 2006 00:55:16 GMT
Author: djd
Date: Mon Mar  6 16:55:15 2006
New Revision: 383732

URL: http://svn.apache.org/viewcvs?rev=383732&view=rev
Log:
DERBY-434 XATest changes to get closer to running it with client.
Merge of 379989 from trunk.

Modified:
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/XATestUtil.java

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out?rev=383732&r1=383731&r2=383732&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
Mon Mar  6 16:55:15 2006
@@ -1,29 +1,32 @@
+initial Connection holdable HOLD_CURSORS_OVER_COMMIT 1
 singleConnectionOnePhaseCommit
+XA Connection holdable CLOSE_CURSORS_AT_COMMIT 2
+XA Statement holdable CLOSE_CURSORS_AT_COMMIT 2
 A          
 -----------
 0          
-GXID|STATUS  |READ&|USERNAME  |TYPE                          
--------------------------------------------------------------
-(0  |ACTIVE  |false|APP       |UserTransaction               
+GXID|STATUS  |READONLY|USERNAME  |TYPE                          
+----------------------------------------------------------------
+(0  |ACTIVE  |false   |APP       |UserTransaction               
 interleavingTransactions
-GXID|STATUS  |READ&|USERNAME  |TYPE                          
--------------------------------------------------------------
-(1  |ACTIVE  |false|SKU       |UserTransaction               
-(2  |ACTIVE  |false|SKU       |UserTransaction               
-GXID|STATUS  |READ&|USERNAME  |TYPE                          
--------------------------------------------------------------
-(1  |ACTIVE  |false|SKU       |UserTransaction               
-(2  |ACTIVE  |false|SKU       |UserTransaction               
-GXID|STATUS  |READ&|USERNAME  |TYPE                          
--------------------------------------------------------------
-(1  |PREPARED|false|SKU       |UserTransaction               
-(2  |PREPARED|false|SKU       |UserTransaction               
+GXID|STATUS  |READONLY|USERNAME  |TYPE                          
+----------------------------------------------------------------
+(1  |ACTIVE  |false   |SKU       |UserTransaction               
+(2  |ACTIVE  |false   |SKU       |UserTransaction               
+GXID|STATUS  |READONLY|USERNAME  |TYPE                          
+----------------------------------------------------------------
+(1  |ACTIVE  |false   |SKU       |UserTransaction               
+(2  |ACTIVE  |false   |SKU       |UserTransaction               
+GXID|STATUS  |READONLY|USERNAME  |TYPE                          
+----------------------------------------------------------------
+(1  |PREPARED|false   |SKU       |UserTransaction               
+(2  |PREPARED|false   |SKU       |UserTransaction               
 recovered start 2
 recovered 0
 recovered end 0
-GXID|STATUS  |READ&|USERNAME  |TYPE                          
--------------------------------------------------------------
-(3  |IDLE    |NULL |SKU       |UserTransaction               
+GXID|STATUS  |READONLY|USERNAME  |TYPE                          
+----------------------------------------------------------------
+(3  |IDLE    |NULL    |SKU       |UserTransaction               
 A          
 -----------
 0          
@@ -31,13 +34,13 @@
 3          
 noTransaction
 morph
-GXID|STATUS  |READ&|USERNAME  |TYPE                          
--------------------------------------------------------------
-GXID|STATUS  |READ&|USERNAME  |TYPE                          
--------------------------------------------------------------
-GXID|STATUS  |READ&|USERNAME  |TYPE                          
--------------------------------------------------------------
-(1  |IDLE    |NULL |APP       |UserTransaction               
+GXID|STATUS  |READONLY|USERNAME  |TYPE                          
+----------------------------------------------------------------
+GXID|STATUS  |READONLY|USERNAME  |TYPE                          
+----------------------------------------------------------------
+GXID|STATUS  |READONLY|USERNAME  |TYPE                          
+----------------------------------------------------------------
+(1  |IDLE    |NULL    |APP       |UserTransaction               
 EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a
global transaction.
 Statement created in global has holdabilty: false
 A          
@@ -45,12 +48,12 @@
 2001       
 2002       
 2003       
-GXID|STATUS  |READ&|USERNAME  |TYPE                          
--------------------------------------------------------------
-(1  |PREPARED|false|APP       |UserTransaction               
-(1  |IDLE    |NULL |APP       |UserTransaction               
-GXID|STATUS  |READ&|USERNAME  |TYPE                          
--------------------------------------------------------------
+GXID|STATUS  |READONLY|USERNAME  |TYPE                          
+----------------------------------------------------------------
+(1  |PREPARED|false   |APP       |UserTransaction               
+(1  |IDLE    |NULL    |APP       |UserTransaction               
+GXID|STATUS  |READONLY|USERNAME  |TYPE                          
+----------------------------------------------------------------
 A          
 -----------
 2001       
@@ -78,59 +81,99 @@
 2005       
 2007       
 derby966
-Local connection holdable true
-Local(held) default Statement holdable true
-held true
+Local Connection holdable HOLD_CURSORS_OVER_COMMIT 1
+Local(held) default Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+ResultSet HOLD_CURSORS_OVER_COMMIT 1
   BC A=0
   AC A=1
-Local(held) default PreparedStatement holdable true
-held true
+  AC A=3
+  AC A=2001
+  AC A=2002
+  AC A=2003
+  AC A=2005
+  AC A=2007
+Local(held) default PreparedStatement holdable HOLD_CURSORS_OVER_COMMIT 1
+ResultSet HOLD_CURSORS_OVER_COMMIT 1
   BC A=0
   AC A=1
-Local(held) held Statement holdable true
-held true
+  AC A=3
+  AC A=2001
+  AC A=2002
+  AC A=2003
+  AC A=2005
+  AC A=2007
+Local(held) held Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+ResultSet HOLD_CURSORS_OVER_COMMIT 1
   BC A=0
   AC A=1
-Local(held) held PreparedStatement holdable true
-held true
+  AC A=3
+  AC A=2001
+  AC A=2002
+  AC A=2003
+  AC A=2005
+  AC A=2007
+Local(held) held PreparedStatement holdable HOLD_CURSORS_OVER_COMMIT 1
+ResultSet HOLD_CURSORS_OVER_COMMIT 1
   BC A=0
   AC A=1
-Local(held) close Statement holdable false
-held false
+  AC A=3
+  AC A=2001
+  AC A=2002
+  AC A=2003
+  AC A=2005
+  AC A=2007
+Local(held) close Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+ResultSet CLOSE_CURSORS_AT_COMMIT 2
   BC A=0
 EXPECTED SQLSTATE(XCL16): ResultSet not open. Operation 'next' not permitted. Verify that
autocommit is OFF.
-Local(held) close PreparedStatement holdable false
-held false
+Local(held) close PreparedStatement holdable CLOSE_CURSORS_AT_COMMIT 2
+ResultSet CLOSE_CURSORS_AT_COMMIT 2
   BC A=0
 EXPECTED SQLSTATE(XCL16): ResultSet not open. Operation 'next' not permitted. Verify that
autocommit is OFF.
-Local(close) default Statement holdable false
-held false
+Local(close) default Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+ResultSet CLOSE_CURSORS_AT_COMMIT 2
   BC A=0
 EXPECTED SQLSTATE(XCL16): ResultSet not open. Operation 'next' not permitted. Verify that
autocommit is OFF.
-Local(close) default PreparedStatement holdable false
-held false
+Local(close) default PreparedStatement holdable CLOSE_CURSORS_AT_COMMIT 2
+ResultSet CLOSE_CURSORS_AT_COMMIT 2
   BC A=0
 EXPECTED SQLSTATE(XCL16): ResultSet not open. Operation 'next' not permitted. Verify that
autocommit is OFF.
-Local(close) held Statement holdable true
-held true
+Local(close) held Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+ResultSet HOLD_CURSORS_OVER_COMMIT 1
   BC A=0
   AC A=1
-Local(close) held PreparedStatement holdable true
-held true
+  AC A=3
+  AC A=2001
+  AC A=2002
+  AC A=2003
+  AC A=2005
+  AC A=2007
+Local(close) held PreparedStatement holdable HOLD_CURSORS_OVER_COMMIT 1
+ResultSet HOLD_CURSORS_OVER_COMMIT 1
   BC A=0
   AC A=1
-Local(close) close Statement holdable false
-held false
+  AC A=3
+  AC A=2001
+  AC A=2002
+  AC A=2003
+  AC A=2005
+  AC A=2007
+Local(close) close Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+ResultSet CLOSE_CURSORS_AT_COMMIT 2
   BC A=0
 EXPECTED SQLSTATE(XCL16): ResultSet not open. Operation 'next' not permitted. Verify that
autocommit is OFF.
-Local(close) close PreparedStatement holdable false
-held false
+Local(close) close PreparedStatement holdable CLOSE_CURSORS_AT_COMMIT 2
+ResultSet CLOSE_CURSORS_AT_COMMIT 2
   BC A=0
 EXPECTED SQLSTATE(XCL16): ResultSet not open. Operation 'next' not permitted. Verify that
autocommit is OFF.
+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.
 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/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java?rev=383732&r1=383731&r2=383732&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
Mon Mar  6 16:55:15 2006
@@ -50,7 +50,9 @@
     public static void main(String[] args) throws Exception {
         ij.getPropertyArg(args);
         Connection dmc = ij.startJBMS();
-
+        
+        showHoldStatus("initial ", dmc);
+        
         XATestUtil.createXATransactionView(dmc);
         dmc.close();
 
@@ -149,8 +151,11 @@
             xar.start(xid, XAResource.TMNOFLAGS);
 
             Connection conn = xac.getConnection();
+            
+            showHoldStatus("XA ", conn);
 
             Statement s = conn.createStatement();
+            showHoldStatus("XA ", s);
 
             s.execute("create table foo (a int)");
             s.executeUpdate("insert into foo values (0)");
@@ -172,6 +177,7 @@
 
         } catch (SQLException sqle) {
             TestUtil.dumpSQLExceptions(sqle);
+            sqle.printStackTrace(System.out);
         } catch (XAException e) {
             XATestUtil.dumpXAException("singleConnectionOnePhaseCommit", e);
         }
@@ -701,7 +707,10 @@
             try {
                 xar.start(xid3, XAResource.TMNOFLAGS);
             } catch (XAException xae) {
-                if (xae.errorCode != XAException.XAER_OUTSIDE)
+                if ((xae.errorCode != XAException.XAER_OUTSIDE)
+                    &&
+                    // DERBY-1024
+                    (xae.errorCode != XAException.XAER_RMFAIL))
                     throw xae;
             }
             conn.commit();
@@ -780,10 +789,7 @@
             // Obtain Statements and PreparedStatements
             // with all the holdability options.
             
-            boolean hold =
-                conn.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT;
-            
-            System.out.println("Local connection holdable " + hold);
+            showHoldStatus("Local ", conn);
            
             Statement sdh = conn.createStatement();
             showHoldStatus("Local(held) default ", sdh);
@@ -859,9 +865,18 @@
             conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
             
             ResultSet rs = sdh.executeQuery("SELECT * FROM APP.FOO");
+            rs.next(); System.out.println("BGBC " + rs.getInt(1));
             conn.commit();
-            rs.next();
+            rs.next(); System.out.println("BGAC " + rs.getInt(1));
+            
+            // This switch to global is ok because conn
+            // is in auto-commit mode, thus the start performs
+            // an implicit commit to complete the local transaction.
             
+            // DERBY-1025 Client only bug
+            if (TestUtil.isDerbyNetClientFramework())
+                conn.commit();
+            System.out.println("START GLOBAL TRANSACTION");
             // start a global xact and test those statements.
             xar.start(xid, XAResource.TMNOFLAGS);
             
@@ -918,6 +933,12 @@
             }
             pscc.executeQuery().close();
             
+            xar.end(xid, XAResource.TMSUCCESS);
+            if (xar.prepare(xid) != XAResource.XA_RDONLY)
+                System.out.println("FAIL prepare didn't indicate r/o");
+            
+            System.out.println("derby966 complete");
+                
         } catch (SQLException e) {
             TestUtil.dumpSQLExceptions(e);
             e.printStackTrace(System.out);
@@ -947,23 +968,23 @@
         boolean held = s.getResultSetHoldability() ==
             ResultSet.HOLD_CURSORS_OVER_COMMIT;
         
-        
-        
-        System.out.println("held " + held);
+        System.out.println("ResultSet " + holdStatus(s.getResultSetHoldability()));
         
         rs.next();
         System.out.println("  BC A=" + rs.getInt(1));
         conn.commit();
        
         try {
-           rs.next();
-           rs.getInt(1);
-           System.out.println("  AC A=" + rs.getInt(1));
+            while (rs.next())
+            {
+                rs.getInt(1);
+                System.out.println("  AC A=" + rs.getInt(1));
+            }
            if (!held)
                System.out.println("FAIL: non-held cursor not closed by commit");
         } catch (SQLException sqle)
         {
-            TestUtil.dumpSQLExceptions(sqle, !held);
+             TestUtil.dumpSQLExceptions(sqle, !held);
         }
         
         rs.close();
@@ -975,9 +996,35 @@
     */
     private static void showHoldStatus(String tag, Statement s) throws SQLException
     {
-        boolean hold =
-            s.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT;
+        System.out.println(tag + "Statement holdable " +
+                holdStatus(s.getResultSetHoldability()));
+    }
+    /**
+     * Show the held status of the Connection.
+    */
+    private static void showHoldStatus(String tag, Connection conn) throws SQLException
+    {
+        System.out.println(tag + "Connection holdable " +
+                holdStatus(conn.getHoldability()));
+    }
+    
+    private static String holdStatus(int holdability)
+    {
+        String s;
+        switch (holdability)
+        {
+        case ResultSet.CLOSE_CURSORS_AT_COMMIT:
+            s = "CLOSE_CURSORS_AT_COMMIT ";
+            break;
+        case ResultSet.HOLD_CURSORS_OVER_COMMIT:
+            s = "HOLD_CURSORS_OVER_COMMIT ";
+            break;
+        default:
+            s = "UNKNOWN HOLDABILITY ";
+            break;
+        }
         
-        System.out.println(tag + "Statement holdable " + hold);
+        return s + Integer.toString(holdability);
     }
+    
 }

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/XATestUtil.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/XATestUtil.java?rev=383732&r1=383731&r2=383732&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/XATestUtil.java
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/XATestUtil.java
Mon Mar  6 16:55:15 2006
@@ -63,7 +63,7 @@
                 "create view XATESTUTIL.global_xactTable as " +
                 "select  cast(global_xid as char(2)) as gxid," +
                 " status, " +
-                " case when first_instant is NULL then 'NULL' else 'false' end as readOnly,
" +
+                " CAST (case when first_instant is NULL then 'NULL' else 'false' end AS VARCHAR(8))
as readOnly, " +
                 " cast (username as char(10)) as username, type " +
                 " from new org.apache.derby.diag.TransactionTable() As transaction_table");
         s.close();



Mime
View raw message