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 rh...@apache.org on 2013/04/29 14:17:12 UTC

svn commit: r1476983 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/impl/sql/execute/ testing/org/apache/derbyTesting/functionTests/tests/jdbc4/

Author: rhillegas
Date: Mon Apr 29 12:17:12 2013
New Revision: 1476983

URL: http://svn.apache.org/r1476983
Log:
DERBY-6206: Cleanup mutability problems in org.apache.derby.impl.jdbc.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DMLWriteResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RowUtil.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientStatement.java?rev=1476983&r1=1476982&r2=1476983&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientStatement.java Mon Apr 29 12:17:12 2013
@@ -36,8 +36,17 @@ import org.apache.derby.shared.common.sa
 public class ClientStatement implements Statement, StatementCallbackInterface{
 
     /** For use in debugging setLargeMaxRows() method added by JDBC 4.2 */
-    public  static  long    fetchedRowBase = 0L;
+    private  static  long    fetchedRowBase = 0L;
     
+    /**
+     * Debug method used to test the setLargeMaxRows() method added by JDBC 4.2.
+     * This method is a NOP on a production (insane) build of Derby.
+     */
+    public  static  void    setFetchedRowBase( long newBase )
+    {
+        if (SanityManager.DEBUG)    { fetchedRowBase = newBase; }
+    }
+
     //---------------------navigational members-----------------------------------
 
     private MaterialStatement materialStatement_ = null;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?rev=1476983&r1=1476982&r2=1476983&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Mon Apr 29 12:17:12 2013
@@ -96,7 +96,7 @@ public class EmbedResultSet extends Conn
     implements EngineResultSet, Comparable {
 
     /** For use in debugging setLargeMaxRows() method added by JDBC 4.2 */
-    public  static  long    fetchedRowBase = 0L;
+    private  static  long    fetchedRowBase = 0L;
     
 	// cursor movement
 	protected static final int FIRST = 1;
@@ -305,6 +305,15 @@ public class EmbedResultSet extends Conn
 		order = conn.getResultSetOrderId();
 	}
 
+    /**
+     * Debug method used to test the setLargeMaxRows() method added by JDBC 4.2.
+     * This method is a NOP on a production (insane) build of Derby.
+     */
+    public  static  void    setFetchedRowBase( long newBase )
+    {
+        if (SanityManager.DEBUG)    { fetchedRowBase = newBase; }
+    }
+
 	private void checkNotOnInsertRow() throws SQLException {
 		if (isOnInsertRow) {
 			throw newSQLException(SQLState.NO_CURRENT_ROW);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java?rev=1476983&r1=1476982&r2=1476983&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSetMetaData.java Mon Apr 29 12:17:12 2013
@@ -21,6 +21,7 @@
 
 package org.apache.derby.impl.jdbc;
 
+import org.apache.derby.iapi.services.io.ArrayUtil;
 import org.apache.derby.iapi.sql.ResultDescription;
 import org.apache.derby.iapi.sql.ResultColumnDescriptor;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
@@ -65,7 +66,7 @@ public class EmbedResultSetMetaData
 	// constructor
 	//
 	public EmbedResultSetMetaData(ResultColumnDescriptor[] columnInfo) {
-		this.columnInfo = columnInfo;
+		this.columnInfo = (ResultColumnDescriptor[]) ArrayUtil.copy( columnInfo );
 	}
 
 	//

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java?rev=1476983&r1=1476982&r2=1476983&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java Mon Apr 29 12:17:12 2013
@@ -22,6 +22,7 @@
 package org.apache.derby.impl.jdbc;
 
 import org.apache.derby.iapi.error.DerbySQLException;
+import org.apache.derby.iapi.services.io.ArrayUtil;
 import java.sql.SQLException;
 
 import org.apache.derby.iapi.error.StandardException;
@@ -73,7 +74,7 @@ public class EmbedSQLException extends S
 	}
 
 	public Object[] getArguments() {
-		return arguments;
+		return ArrayUtil.copy( arguments );
 	}
 
 	/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DMLWriteResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DMLWriteResultSet.java?rev=1476983&r1=1476982&r2=1476983&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DMLWriteResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DMLWriteResultSet.java Mon Apr 29 12:17:12 2013
@@ -113,7 +113,7 @@ abstract class DMLWriteResultSet extends
 		needToObjectifyStream = (this.constantAction.getTriggerInfo() != null);
 	}
 
-	public final long	modifiedRowCount() { return rowCount + RowUtil.rowCountBase; }
+	public final long	modifiedRowCount() { return rowCount + RowUtil.getRowCountBase(); }
 
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RowUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RowUtil.java?rev=1476983&r1=1476982&r2=1476983&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RowUtil.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/RowUtil.java Mon Apr 29 12:17:12 2013
@@ -37,7 +37,19 @@ import org.apache.derby.iapi.sql.execute
 public class RowUtil
 {
     /** Row count base added for testing JDBC 4.2 */
-    public  static  long    rowCountBase = 0L;
+    private  static  long    rowCountBase = 0L;
+
+    /**
+     * Debug method used to test the setLargeMaxRows() method added by JDBC 4.2.
+     * This method is a NOP on a production (insane) build of Derby.
+     */
+    public  static  void    setRowCountBase( long newBase )
+    {
+        if (SanityManager.DEBUG)    { rowCountBase = newBase; }
+    }
+
+    /** Retrieve the row count base */
+    public  static  long    getRowCountBase() { return rowCountBase; }
 
  	/**
 	  Get an empty ExecRow.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest.java?rev=1476983&r1=1476982&r2=1476983&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest.java Mon Apr 29 12:17:12 2013
@@ -32,6 +32,7 @@ import org.apache.derbyTesting.junit.Tes
 import java.io.*;
 import java.sql.*;
 
+import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.services.io.DerbyIOException;
 import org.apache.derby.impl.jdbc.EmbedSQLException;
 
@@ -1196,6 +1197,12 @@ public class PreparedStatementTest exten
     public  static  void    largeUpdate_jdbc4_2( Connection conn )
         throws Exception
     {
+        //
+        // This test makes use of a debug entry point which is a NOP
+        // in an insane production build.
+        //
+        if (!SanityManager.DEBUG)    { return; }
+
         println( "Running large update test for JDBC 4.2" );
         
         conn.prepareStatement

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java?rev=1476983&r1=1476982&r2=1476983&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java Mon Apr 29 12:17:12 2013
@@ -20,6 +20,7 @@
 
 package org.apache.derbyTesting.functionTests.tests.jdbc4;
 
+import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.vti.VTITemplate;
 import org.apache.derby.impl.jdbc.EmbedResultSet;
 import org.apache.derby.impl.sql.execute.RowUtil;
@@ -368,6 +369,13 @@ public class StatementTest
     public  static  void    largeUpdate_jdbc4_2( Connection conn )
         throws Exception
     {
+        //
+        // This test makes use of a debug entry point which is a NOP
+        // in an insane production build.
+        //
+        if (!SanityManager.DEBUG)    { return; }
+        else { println( "Running largeUpdate_jdbc4_2() on debug code." ); }
+
         conn.prepareStatement
             (
              "create procedure setRowCountBase( newBase bigint )\n" +
@@ -394,6 +402,13 @@ public class StatementTest
     private static  void    largeUpdateTest( StatementWrapper sw, long rowCountBase )
         throws Exception
     {
+        //
+        // This test makes use of a debug entry point which is a NOP
+        // in an insane production build.
+        //
+        if (!SanityManager.DEBUG)    { return; }
+        else { println( "Running largeUpdateTest() on debug code." ); }
+
         // poke the rowCountBase into the engine. all returned row counts will be
         // increased by this amount
         setRowCountBase( sw.getWrappedStatement(), false, rowCountBase );
@@ -446,6 +461,12 @@ public class StatementTest
     private static  void    largeBatchTest( StatementWrapper sw, long rowCountBase )
         throws Exception
     {
+        //
+        // This test makes use of a debug entry point which is a NOP
+        // in an insane production build.
+        //
+        if (!SanityManager.DEBUG)    { return; }
+
         println( "Large batch test with rowCountBase = " + rowCountBase );
         
         // poke the rowCountBase into the engine. all returned row counts will be
@@ -473,6 +494,12 @@ public class StatementTest
     private static  void    largeMaxRowsTest( StatementWrapper sw, long maxRows )
         throws Exception
     {
+        //
+        // This test makes use of a debug entry point which is a NOP
+        // in an insane production build.
+        //
+        if (!SanityManager.DEBUG)    { return; }
+
         println( "Large max rows test with maxRows = " + maxRows );
 
         long    expectedRowCount = 3L;
@@ -497,6 +524,12 @@ public class StatementTest
     private static  void    largeBatchUpdateExceptionTest( StatementWrapper sw, long rowCountBase )
         throws Exception
     {
+        //
+        // This test makes use of a debug entry point which is a NOP
+        // in an insane production build.
+        //
+        if (!SanityManager.DEBUG)    { return; }
+
         println( "Large batch update exception test with rowCountBase = " + rowCountBase );
         
         sw.getWrappedStatement().clearBatch();
@@ -540,7 +573,7 @@ public class StatementTest
     {
         if ( onClient )
         {
-            ClientStatement.fetchedRowBase = rowCountBase;
+            ClientStatement.setFetchedRowBase( rowCountBase );
         }
         else
         {
@@ -699,8 +732,8 @@ public class StatementTest
     /** Set the base which is used for returned row counts and fetched row counters */
     public  static  void    setRowCountBase( long newBase )
     {
-        EmbedResultSet.fetchedRowBase = newBase;
-        RowUtil.rowCountBase = newBase;
+        EmbedResultSet.setFetchedRowBase( newBase );
+        RowUtil.setRowCountBase( newBase );
     }
 
 } // End class StatementTest