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 ma...@apache.org on 2006/12/14 20:25:45 UTC

svn commit: r487314 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc: EmbedCallableStatement.java EmbedPreparedStatement.java

Author: mamta
Date: Thu Dec 14 11:25:44 2006
New Revision: 487314

URL: http://svn.apache.org/viewvc?view=rev&rev=487314
Log:
EmbedCallableStatement.executeStatement stuffs the output parameter value into
ParameterValueSet object. But ParameterValueSet object which is fetched at the
beginning of the method might not be the valid object if a new activation object
got created for the Statement because it was invalid. I am making changes such
that a fetch of ParameterValueSet object into a local variable is done after
the possiblity of new Activation object has been accounted for. I have also put
javadoc comments for the users of ParameterValueSet object which is returned
by EmbedPreparedStatement.getParms method.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java?view=diff&rev=487314&r1=487313&r2=487314
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java Thu Dec 14 11:25:44 2006
@@ -94,11 +94,18 @@
 		synchronized (getConnectionSynchronization())
 		{
 			wasNull = false;
-			ParameterValueSet pvs = getParms();
+			//Don't fetch the getParms into a local varibale
+			//at this point because it is possible that the activation
+			//associated with this callable statement may have become
+			//stale. If the current activation is invalid, a new activation 
+			//will be created for it in executeStatement call below. 
+			//We should be using the ParameterValueSet associated with
+			//the activation associated to the CallableStatement after
+			//the executeStatement below. That ParameterValueSet is the
+			//right object to hold the return value from the CallableStatement.
 			try
 			{
-				pvs.validate();
-
+				getParms().validate();
 			} catch (StandardException e)
 			{
 				throw EmbedResultSet.noStateChangeException(e);
@@ -109,6 +116,13 @@
 			 */
 			boolean execResult = super.executeStatement(a, executeQuery,
 				(executeUpdate && (! hasReturnOutputParameter)));
+
+			//Fetch the getParms into a local variable now because the
+			//activation associated with a CallableStatement at this 
+			//point(after the executStatement) is the current activation. 
+			//We can now safely stuff the return value of the 
+			//CallableStatement into the following ParameterValueSet object.
+			ParameterValueSet pvs = getParms();
 
 			/*
 			** If we have a return parameter, then we

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java?view=diff&rev=487314&r1=487313&r2=487314
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java Thu Dec 14 11:25:44 2006
@@ -1447,7 +1447,24 @@
 	}
 
 	/**
-	 * Get the ParameterValueSet from the activation
+	 * Get the ParameterValueSet from the activation.
+	 * 
+	 * The caller of this method should be aware that the
+	 * activation associated with a Statement can change
+	 * and hence the ParameterValueSet returned by this
+	 * call should not be hold onto. An example of this
+	 * can be seen in EmbedCallableStatement.executeStatement
+	 * where at the beginning of the method, we check the
+	 * validity of the parameters. But we donot keep the
+	 * parameters in a local variable to use later. The reason
+	 * for this is that the next call in the method, 
+	 * super.executeStatement can recompile the statement and 
+	 * create a new activation if the statement plan has been 
+	 * invalidated. To account for this possibility, 
+	 * EmbedCallableStatement.executeStatement makes 
+	 * another call to get the ParameterValueSet before stuffing 
+	 * the output parameter value into the ParameterValueSet
+	 * object.
 	 *
 	 *
 	 * @return	The ParameterValueSet for the activation