db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r813882 - in /db/derby/code/branches/10.2: ./ java/engine/org/apache/derby/iapi/jdbc/ java/engine/org/apache/derby/jdbc/ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derbyTesting/functionTests/master/De...
Date Fri, 11 Sep 2009 15:42:09 GMT
Author: mamta
Date: Fri Sep 11 15:42:08 2009
New Revision: 813882

URL: http://svn.apache.org/viewvc?rev=813882&view=rev
Log:
DERBY-4310

Backport changes to 10.2 codeline. Had to hand write the tests in XATest because that test
has not been converted to junit test in 10.2 codeline and hence the merge on it didn't work.


Modified:
    db/derby/code/branches/10.2/   (props changed)
    db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java
    db/derby/code/branches/10.2/java/engine/org/apache/derby/jdbc/XAStatementControl.java
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java

Propchange: db/derby/code/branches/10.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep 11 15:42:08 2009
@@ -1 +1 @@
-/db/derby/code/trunk:788436
+/db/derby/code/trunk:788436,800523

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java?rev=813882&r1=813881&r2=813882&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement.java
Fri Sep 11 15:42:08 2009
@@ -60,6 +60,10 @@
         return getCallableStatement().wasNull();
     }
 
+    public final void close() throws SQLException {
+        control.closeRealCallableStatement();
+    }
+    
     public final String getString(int parameterIndex)
         throws SQLException
     {

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java?rev=813882&r1=813881&r2=813882&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
Fri Sep 11 15:42:08 2009
@@ -88,6 +88,11 @@
         return getPreparedStatement().executeUpdate();
     }
 
+	public void close() throws SQLException
+	{
+	    control.closeRealPreparedStatement();
+	}
+	
     /**
      * Set a parameter to SQL NULL.
      *

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java?rev=813882&r1=813881&r2=813882&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
Fri Sep 11 15:42:08 2009
@@ -127,9 +127,9 @@
      * ResultSet, if one exists, is also closed.
 	 * @exception SQLException thrown on failure.
      */
-	public final void close() throws SQLException
+	public void close() throws SQLException
     {
-		getStatement().close();
+		control.closeRealStatement();
     }
 
     public final Connection getConnection()

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java?rev=813882&r1=813881&r2=813882&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatementControl.java
Fri Sep 11 15:42:08 2009
@@ -37,6 +37,26 @@
 	public int checkHoldCursors(int holdability) throws SQLException;
 
 	/**
+	 * Close the real JDBC Statement when this is controlling a Statement.
+	 * @throws SQLException
+	 */
+	public void closeRealStatement() throws SQLException;
+	
+	/**
+	 * Close the real JDBC CallableStatement when this is controlling a
+	 * CallableStatement. 
+	 * @throws SQLException
+	 */
+	public void closeRealCallableStatement() throws SQLException;
+	
+	/**
+	 * Close the real JDBC CallableStatement when this is controlling a
+	 * PreparedStatement. 
+	 * @throws SQLException
+	 */
+	public void closeRealPreparedStatement() throws SQLException;
+	
+	/**
 		Return the real JDBC statement for the brokered statement
 		when this is controlling a Statement.
 	*/

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/jdbc/XAStatementControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/jdbc/XAStatementControl.java?rev=813882&r1=813881&r2=813882&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/jdbc/XAStatementControl.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/jdbc/XAStatementControl.java
Fri Sep 11 15:42:08 2009
@@ -85,6 +85,27 @@
                 applicationStatement);
 	}
 
+	/**
+	 * Close the realStatement within this control. 
+	 */
+	public void closeRealStatement() throws SQLException {
+		realStatement.close();
+	}
+	
+	/**
+	 * Close the realCallableStatement within this control. 
+	 */
+	public void closeRealCallableStatement() throws SQLException {
+		realCallableStatement.close();
+	}
+	
+	/**
+	 * Close the realPreparedStatement within this control. 
+	 */
+	public void closeRealPreparedStatement() throws SQLException {
+		realPreparedStatement.close();
+	}
+	
 	public Statement getRealStatement() throws SQLException {
 
 		// 

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out?rev=813882&r1=813881&r2=813882&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
Fri Sep 11 15:42:08 2009
@@ -202,4 +202,6 @@
 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
+derby4310PreparedStatement
+derby4310CallableStatement
 XATest complete

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out?rev=813882&r1=813881&r2=813882&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
Fri Sep 11 15:42:08 2009
@@ -201,4 +201,6 @@
 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
+derby4310PreparedStatement
+derby4310CallableStatement
 XATest complete

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java?rev=813882&r1=813881&r2=813882&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
Fri Sep 11 15:42:08 2009
@@ -22,6 +22,7 @@
 package org.apache.derbyTesting.functionTests.tests.jdbcapi;
 
 import java.sql.Connection;
+import java.sql.CallableStatement;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -77,6 +78,11 @@
         
         // DERBY-966 holdability testing
         derby966(dsx);
+        
+        // DERBY-4310 closing of statement with an embedded XAConnection
+        // should not cause recompile of statement
+        derby4310PreparedStatement(dsx);
+        derby4310CallableStatement(dsx);
 
         // for cleaning up, make a clean new connection
         Connection dmc2 = ij.startJBMS();
@@ -792,6 +798,125 @@
 
     }
     
+    /** 
+     * Dummy method for derby4310CallableStatement
+     */
+    public static void zeroArg() {  }
+    
+    /**
+     * This test checks the fix on DERBY-4310, for not repreparing 
+     * CallableStatements upon calling close() on them.
+     */
+    public static void derby4310CallableStatement(XADataSource xads) 
+    throws Exception 
+    {
+        System.out.println("derby4310CallableStatement");
+        try {
+            XAConnection xac = xads.getXAConnection();
+            XAResource xar = xac.getXAResource();
+
+            Xid xid = XATestUtil.getXid(4310, 9, 49);
+
+            /* Create the procedure based on XATest.zeroArg() */
+            Connection conn = xac.getConnection();
+            Statement s = conn.createStatement();
+            s.executeUpdate("CREATE PROCEDURE ZA() LANGUAGE JAVA "+
+                            "EXTERNAL NAME 'org.apache.derbyTesting.functionTests.tests.jdbcapi.XATest.zeroArg'
"+
+                            "PARAMETER STYLE JAVA");
+            conn.commit();
+            
+            /* Prepare and execute CallableStatement based on the procedure above */
+            CallableStatement cs = conn.prepareCall("CALL ZA()");
+            cs.execute();
+
+            /* Start and end a transaction on the XAResource object */
+            xar.start(xid, XAResource.TMNOFLAGS);
+            xar.end(xid, XAResource.TMSUCCESS);
+
+            /* Drop the procedure on a parallel, regular connection */
+            Connection conn2 = ij.startJBMS();
+            Statement s2 = conn2.createStatement();
+            s2.execute("DROP PROCEDURE ZA");
+            conn2.commit();
+            conn2.close();
+            
+            try {
+                /* Try to close the prepared statement. This would throw an exception
+                 * before the fix, claiming that the table was not found. */
+                cs.close();
+            } finally {
+                /* Rollback the transaction and close the connections */
+                xar.rollback(xid);
+                conn.close();
+                xac.close();
+            }
+        } catch (SQLException e) {
+            TestUtil.dumpSQLExceptions(e);
+            e.printStackTrace(System.out);
+        } catch (XAException e) {
+            XATestUtil.dumpXAException("derby4310CallableStatement", e);
+        }
+    }
+    
+    /**
+     * This test checks the fix on DERBY-4310, for not repreparing 
+     * PreparedStatements upon calling close() on them.
+     * @param xads
+     */
+    private static void derby4310PreparedStatement(XADataSource xads)
+    throws Exception
+    {
+        System.out.println("derby4310PreparedStatement");
+        try {
+            XAConnection xac = xads.getXAConnection();
+            XAResource xar = xac.getXAResource();
+
+            Xid xid = XATestUtil.getXid(4310, 9, 48);
+            
+            Connection conn = xac.getConnection();
+            
+            /* Create the table and insert some records into it. */
+            Statement s = conn.createStatement();
+            s.executeUpdate("CREATE TABLE foo4310_PS (I INT)");
+            conn.createStatement().executeUpdate("insert into APP.foo4310_PS values (0)");
+            conn.createStatement().executeUpdate("insert into APP.foo4310_PS values (1)");
+            conn.createStatement().executeUpdate("insert into APP.foo4310_PS values (2)");
+            conn.commit();
+            
+            /* Prepare and execute the statement to be tested */
+            PreparedStatement ps = conn.prepareStatement("SELECT * FROM APP.foo4310_PS");
+            ps.executeQuery().close();
+
+            /* Start and end a transaction on the XAResource object */
+            xar.start(xid, XAResource.TMNOFLAGS);
+            xar.end(xid, XAResource.TMSUCCESS);
+
+            /* Drop the table on a parallel, regular connection */
+            Connection conn2 = ij.startJBMS();
+            Statement s2 = conn2.createStatement();
+            s2.execute("DROP TABLE foo4310_PS");
+            conn2.commit();
+            conn2.close();
+
+            
+            try {
+                /* Try to close the prepared statement. This would throw an exception
+                 * before the fix, claiming that the table was not found. */
+                ps.close();
+            } finally {
+                /* Rollback the transaction and close the connections */
+                xar.rollback(xid);
+                conn.close();
+                xac.close();
+            }
+        } catch (SQLException e) {
+            TestUtil.dumpSQLExceptions(e);
+            e.printStackTrace(System.out);
+        } catch (XAException e) {
+            XATestUtil.dumpXAException("derby4310PreparedStatement", e);
+        }
+    }
+
     /**
      * Derby-966 holdability and global/location transactions.
      * (work in progress)



Mime
View raw message