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/30 18:17:33 UTC

svn commit: r1477711 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/ impl/jdbc/ impl/sql/ impl/sql/execute/

Author: rhillegas
Date: Tue Apr 30 16:17:32 2013
New Revision: 1477711

URL: http://svn.apache.org/r1477711
Log:
DERBY-6206: Cleanup mutability issues in BaseActivation.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/Activation.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DeleteCascadeResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/Activation.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/Activation.java?rev=1477711&r1=1477710&r2=1477711&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/Activation.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/Activation.java Tue Apr 30 16:17:32 2013
@@ -567,7 +567,7 @@ public interface Activation extends Depe
 	//clear the parent resultset hash table;
 	public void clearParentResultSets();
 
-	public Hashtable getParentResultSets();
+	public Enumeration getParentResultSetKeys();
 
 	/**
 	 * beetle 3865: updateable cursor using index.  A way of communication

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java?rev=1477711&r1=1477710&r2=1477711&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 Tue Apr 30 16:17:32 2013
@@ -707,7 +707,9 @@ public class EmbedStatement extends Conn
 			//bug 4838 - save the auto-generated key information in activation. keeping this
 			//information in lcc will not work work it can be tampered by a nested trasaction
 			if (autoGeneratedKeys == Statement.RETURN_GENERATED_KEYS)
+            {
 				activation.setAutoGeneratedKeysResultsetInfo(columnIndexes, columnNames);
+            }
 			return executeStatement(activation, executeQuery, executeUpdate);
 		} finally {
 		    restoreContextStack();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java?rev=1477711&r1=1477710&r2=1477711&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericActivationHolder.java Tue Apr 30 16:17:32 2013
@@ -322,8 +322,10 @@ final public class GenericActivationHold
 
 				newAC.setResultSetHoldability(ac.getResultSetHoldability());
 				if (ac.getAutoGeneratedKeysResultsetMode()) //Need to do copy only if auto generated mode is on
+                {
 					newAC.setAutoGeneratedKeysResultsetInfo(ac.getAutoGeneratedKeysColumnIndexes(),
 					ac.getAutoGeneratedKeysColumnNames());
+                }
 				newAC.setMaxRows(ac.getMaxRows());
 
 				// break the link with the prepared statement
@@ -809,9 +811,9 @@ final public class GenericActivationHold
 		ac.clearParentResultSets();
 	}
 
-	public Hashtable getParentResultSets()
+	public Enumeration getParentResultSetKeys()
 	{
-		return ac.getParentResultSets();
+		return ac.getParentResultSetKeys();
 	}
 
 	public void setForUpdateIndexScan(CursorResultSet forUpdateResultSet)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java?rev=1477711&r1=1477710&r2=1477711&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java Tue Apr 30 16:17:32 2013
@@ -25,6 +25,7 @@ import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.SQLWarning;
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Vector;
@@ -42,6 +43,7 @@ import org.apache.derby.iapi.reference.P
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.context.Context;
 import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.services.io.ArrayUtil;
 import org.apache.derby.iapi.services.io.FormatableBitSet;
 import org.apache.derby.iapi.services.loader.GeneratedByteCode;
 import org.apache.derby.iapi.services.loader.GeneratedClass;
@@ -643,8 +645,8 @@ public abstract class BaseActivation imp
 	public void setAutoGeneratedKeysResultsetInfo(int[] columnIndexes, String[] columnNames)
 	{
 		autoGeneratedKeysResultSetMode = true;
-		autoGeneratedKeysColumnIndexes = columnIndexes;
-		autoGeneratedKeysColumnNames = columnNames;
+		autoGeneratedKeysColumnIndexes = ArrayUtil.copy( columnIndexes );
+		autoGeneratedKeysColumnNames = ArrayUtil.copy( columnNames );
 	}
 
 	/** @see Activation#getAutoGeneratedKeysResultsetMode */
@@ -656,13 +658,13 @@ public abstract class BaseActivation imp
 	/** @see Activation#getAutoGeneratedKeysColumnIndexes */
 	public int[] getAutoGeneratedKeysColumnIndexes()
 	{
-		return autoGeneratedKeysColumnIndexes;
+		return ArrayUtil.copy( autoGeneratedKeysColumnIndexes );
 	}
 
 	/** @see Activation#getAutoGeneratedKeysColumnNames */
 	public String[] getAutoGeneratedKeysColumnNames()
 	{
-		return autoGeneratedKeysColumnNames;
+		return ArrayUtil.copy( autoGeneratedKeysColumnNames );
 	}
 
 	//
@@ -1641,9 +1643,9 @@ public abstract class BaseActivation imp
 		return (Vector) parentResultSets.get(resultSetId);
 	}
 
-	public Hashtable getParentResultSets()
+	public Enumeration getParentResultSetKeys()
 	{
-		return parentResultSets;
+		return parentResultSets.keys();
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DeleteCascadeResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DeleteCascadeResultSet.java?rev=1477711&r1=1477710&r2=1477711&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DeleteCascadeResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/DeleteCascadeResultSet.java Tue Apr 30 16:17:32 2013
@@ -430,8 +430,7 @@ class DeleteCascadeResultSet extends Del
 	**/
 	private boolean isMultipleDeletePathsExist()
 	{
-		Hashtable parentResultSets = activation.getParentResultSets();
-		for (Enumeration e = parentResultSets.keys() ; e.hasMoreElements() ;) 
+		for (Enumeration e = activation.getParentResultSetKeys() ; e.hasMoreElements() ;) 
 		{
 			String rsId  = (String) e.nextElement();
 			Vector sVector = (Vector) activation.getParentResultSet(rsId);
@@ -453,8 +452,7 @@ class DeleteCascadeResultSet extends Del
 	**/
 	private void setRowHoldersTypeToUniqueStream()
 	{
-		Hashtable parentResultSets = activation.getParentResultSets();
-		for (Enumeration e = parentResultSets.keys() ; e.hasMoreElements() ;) 
+		for (Enumeration e = activation.getParentResultSetKeys() ; e.hasMoreElements() ;) 
 		{
 			String rsId  = (String) e.nextElement();
 			Vector sVector = (Vector) activation.getParentResultSet(rsId);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java?rev=1477711&r1=1477710&r2=1477711&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java Tue Apr 30 16:17:32 2013
@@ -417,10 +417,13 @@ class InsertResultSet extends DMLWriteRe
 		*/
 		if(activation.getAutoGeneratedKeysResultsetMode())
 		{
-			if (activation.getAutoGeneratedKeysColumnIndexes() != null)
-				verifyAutoGeneratedColumnsIndexes(activation.getAutoGeneratedKeysColumnIndexes());
-			else  if (activation.getAutoGeneratedKeysColumnNames() != null)
-				verifyAutoGeneratedColumnsNames(activation.getAutoGeneratedKeysColumnNames());
+            int[]   agi = activation.getAutoGeneratedKeysColumnIndexes();
+            if ( agi != null ) { verifyAutoGeneratedColumnsIndexes( agi ); }
+            else
+            {
+                String[]    agc = activation.getAutoGeneratedKeysColumnNames();
+                if ( agc != null ) { verifyAutoGeneratedColumnsNames( agc ); }
+            }
 		}
 		rowCount = 0L;