db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r359634 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/ iapi/types/ impl/jdbc/ impl/sql/ impl/sql/compile/
Date Wed, 28 Dec 2005 20:37:22 GMT
Author: djd
Date: Wed Dec 28 12:37:15 2005
New Revision: 359634

URL: http://svn.apache.org/viewcvs?rev=359634&view=rev
Log:
DERBY-776 Cleanup related to setValue(Object). Set return parameter for ? = call
statements directly from ResultSet, rather than through an Object.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ParameterValueSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameter.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ParameterValueSet.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ParameterValueSet.java?rev=359634&r1=359633&r2=359634&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ParameterValueSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/ParameterValueSet.java Wed Dec
28 12:37:15 2005
@@ -49,22 +49,6 @@
 	*/
     void setParameterMode(int position, int mode);
 
-	/**
-	 * Set a parameter position to a DataValueDescriptor.
-	 *
-	 * NOTE: This method assumes the caller will not pass a position that's
-	 * out of range.  The implementation may have an assertion that the position
-	 * is in range.
-	 *
-	 * @param sdv		The DataValueDescriptor to set
-	 * @param position	The parameter position to set it at
-	 * @param jdbcTypeId    The corresponding JDBC types from java.sql.Types
-	 * @param className  The declared class name for the type.
-	 */
-
-	void setStorableDataValue(DataValueDescriptor sdv, int position, int jdbcTypeId, String
className);
-
-
 	//////////////////////////////////////////////////////////////////
 	//
 	// CALLABLE STATEMENT
@@ -135,12 +119,17 @@
 	*/
 	void setParameterAsObject(int parameterIndex, Object value) throws StandardException;
 	
-	
+	/**
+	 * Get the DataValueDescriptor for an INOUT or OUT parameter.
+	 * @param position Zero based index of the parameter.
+	 * @return Parameter's value holder.
+	 * @throws StandardException Position out of range or the parameter is not INOUT or OUT.
+	 */
 	public DataValueDescriptor getParameterForGet( int position ) throws StandardException;
 
 	/**
 	 * Tells whether all the parameters are set and ready for execution.
-	   OUT and Cloudscape static method INOUT parameters are not required to be set.
+	   OUT are not required to be set.
 	 *
 	 * @return	true if all parameters are set, false if at least one
 	 *			parameter is not set.
@@ -214,13 +203,12 @@
 
 
     /**
-     * Set the value of the return parameter as a Java object.
+     * Get the value of the return parameter in order to set it.
      *
-     * @param value the return value
      *
      * @exception StandardException if a database-access error occurs.
      */
-	void setReturnValue(Object value) throws StandardException;
+	DataValueDescriptor getReturnValueForSet() throws StandardException;
 
 	/**
 	 * Return the scale of the given parameter index in this pvs.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java?rev=359634&r1=359633&r2=359634&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java Wed Dec 28 12:37:15
2005
@@ -1088,7 +1088,10 @@
 	*/
 	public void setBigDecimal(Number bigDecimal)  throws StandardException
 	{
-		setValue((Object) bigDecimal);
+		if (bigDecimal == null)
+			setToNull();
+		else
+			setValue(bigDecimal.toString());
 	}
 
 	/** @exception StandardException		Thrown on error */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement.java?rev=359634&r1=359633&r2=359634&view=diff
==============================================================================
--- 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
Wed Dec 28 12:37:15 2005
@@ -128,8 +128,8 @@
 
 				try
 				{
-					pvs.setReturnValue(results.getObject(1));
-
+					DataValueDescriptor returnValue = pvs.getReturnValueForSet();
+					returnValue.setValueFromResultSet(results, 1, true);
 				} catch (StandardException e)
 				{
 					throw EmbedResultSet.noStateChangeException(e);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameter.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameter.java?rev=359634&r1=359633&r2=359634&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameter.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameter.java Wed Dec
28 12:37:15 2005
@@ -302,23 +302,6 @@
 	////////////////////////////////////////////////////
 
 	/**
-	 * do a setValue on the particular field.  Doesn't do
-	 * checks on what it is being set to or on whether
-	 * it is a return parameter or what.  This is only
-	 * called internally; it is not expected to be called
-	 * directly as a result of some jdbc call (e.g. setObject()).
-	 *
-	 * @param newValue the value to set
-	 *
-	 * @exception StandardException on error
-	 */
-	void stuffObject(Object newValue) throws StandardException
-	{
-		value.setValue(newValue);
-		isSet = true;
-	}
-
-	/**
 	 * get string for param number
 	 */
 	String getJDBCParameterNumberStr()

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java?rev=359634&r1=359633&r2=359634&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericParameterValueSet.java
Wed Dec 28 12:37:15 2005
@@ -274,54 +274,6 @@
 		}
 	}
 
-	/*
-	 * workhorse for set and stuff storable data value
-	 */
-	/**
-	 * @see ParameterValueSet#setStorableDataValue
-	 */
-	public void setStorableDataValue(DataValueDescriptor sdv, int position, int jdbcTypeId,
String className)
-	{
-		if (SanityManager.DEBUG) 
-		{
-			if (!(position >= 0 && position < parms.length))
-			{
-				SanityManager.THROWASSERT("position value of " 
-					+ position + " is out of range (0 to " + parms.length + ")");
-			}
-			if (parms[position].getValue() != null)
-			{
-//COMMENTED OUT BY MAMTA -- should this be removed?
-//			SanityManager.THROWASSERT(
-//					"Attempt to reset a DataValueDescriptor in a ParameterValueSet, " +
-//					"position = " + position);
-			}
-
-			/* We need the next assertion because this method gets called
-			 * from generated code, hence no run time checking on the
-			 * parameters.
-			 */
-			if (! (sdv instanceof DataValueDescriptor))
-			{
-				if (sdv == null)
-				{
-					SanityManager.THROWASSERT("sdv expected to be non-null");
-				}
-				SanityManager.THROWASSERT(
-					"sdv expected to be DataValueDescriptor, not " +
-					sdv.getClass().getName());
-			}
-		}
-
-		parms[position].initialize(sdv, jdbcTypeId, className);
-
-		/* NOTE: We do not deal with associated parameters here.
-		 * This method is only called from the generated code
-		 * when initializing the parameters to null.  All
-		 * parameters, user and generated, will get initialized.
-		 */
-	}
-
 	GenericParameter getGenericParameter(int position)
 	{
     return(parms[position]);
@@ -495,21 +447,22 @@
 	}
 
     /**
-     * Set the value of the return parameter as a Java object.
+     * Get the value of the return parameter in order to set it.
      *
-     * @param value the return value
-	 *
+ 	 *
      * @exception StandardException if a database-access error occurs.
      */
-    public void setReturnValue(Object value) throws StandardException
+    public DataValueDescriptor getReturnValueForSet() throws StandardException
 	{
 		checkPosition(0);
+				
 		if (SanityManager.DEBUG)
 		{
-			SanityManager.ASSERT(parms.length > 0, "no return value");
-			SanityManager.ASSERT(hasReturnOutputParam, "shouldn't call setReturnValue() unless pvs
has a return value");
+			if (!hasReturnOutputParam)
+				SanityManager.THROWASSERT("getReturnValueForSet called on non-return parameter");
 		}
-		parms[0].stuffObject(value);
+		
+		return parms[0].getValue();
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java?rev=359634&r1=359633&r2=359634&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java Wed
Dec 28 12:37:15 2005
@@ -310,29 +310,11 @@
 	////////////////////////////////////////////////////////////////////
 
 	/**
-	 * For a ParameterNode, we generate a call to the type factory
-	 * to get a DataValueDescriptor, and pass the result to the
-	 * setStorableDataValue method of the ParameterValueSet for the
-	 * generated class.  We push the DataValueDescriptor field as the
-	 * generated expression.
-	 *
-	 * Generated code:
-	 *
-	 *   In the constructor for the generated class:
-	 *
-	 *	((ParameterValueSet) pvs).
-	 *		setStorableDataValue(
-	 *				<generated null>,
-	 *				parameterNumber, jdbcType, className);
-	 *
-	 *   For the return value:
+	 * For a ParameterNode, we generate for the return value:
 	 *
 	 *		(<java type name>)
-	 *			( (ParameterValueSet) pvs.
-	 *					getParameter(parameterNumber) )
+	 *			( (BaseActivation) this.getParameter(parameterNumber) )
 	 *
-	 * pvs is a ParameterValueSet that lives in the superclass of the class
-	 * being generated.
 	 *
 	 * @param acb	The ExpressionClassBuilder for the class being built
 	 * @param mb	The method the expression will go into
@@ -355,11 +337,6 @@
 			throw StandardException.newException(
 				SQLState.LANG_ATTEMPT_TO_BIND_XML);
 		}
-
-		// PUSHCOMPILE
-		/* Reuse code if possible */
-		//if (genRetval != null)
-		//	return genRetval;
 
         /* Generate the return value */
 



Mime
View raw message