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 dj...@apache.org on 2006/01/01 20:13:07 UTC

svn commit: r360519 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/ engine/org/apache/derby/impl/sql/ engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/impl/store/access/ engine/org/apache/derby/impl/store/access/con...

Author: djd
Date: Sun Jan  1 11:12:54 2006
New Revision: 360519

URL: http://svn.apache.org/viewcvs?rev=360519&view=rev
Log:
DERBY-776 Remove method DataValueDescriptor.setValue(Object). Objects are now
set using DataValueDescriptor.setObjectForCast(Object) consistently.
Cleanup CastNode to use these methods correctly. Make DataValueDescriptor.setWidth
void rather than return itself.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBit.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDate.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLInteger.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongVarbit.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongint.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLRef.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLSmallint.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTime.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTinyint.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLVarbit.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/VariableSizeDataValue.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/BinaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/StorableFormatId.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerate.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapRowLocation.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/cast.sql

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java Sun Jan  1 11:12:54 2006
@@ -441,11 +441,11 @@
 	/* (non-Javadoc)
 	 * @see org.apache.derby.iapi.types.VariableSizeDataValue#setWidth(int, int, boolean)
 	 */
-	public DataValueDescriptor setWidth(int desiredPrecision, int desiredScale,
+	public void setWidth(int desiredPrecision, int desiredScale,
 			boolean errorOnTrunc) throws StandardException
 	{
 		if (isNull())
-			return this;
+			return;
 			
 		int deltaScale = desiredScale - sqlScale;
 		if (desiredPrecision != IGNORE_PRECISION)
@@ -460,7 +460,7 @@
 		}
 		
 		if (deltaScale == 0)
-			return this;
+			return;
 		
 		BigInteger bi = new BigInteger(data2c);
 		
@@ -468,7 +468,6 @@
 
 		data2c = bi.toByteArray();
 		sqlScale = desiredScale;		
-     	return this;
 	}
 	
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataType.java Sun Jan  1 11:12:54 2006
@@ -528,29 +528,57 @@
 	 }
 
 	/**
-	 * Set the Object that this Data Type contains (for an explicit cast).
-	 *
-	 * @exception StandardException		Thrown on error
+	 * @see DataValueDescriptor#setObjectForCast
+	 * 
+	 * @exception StandardException
+	 *                thrown on failure
+	 * 
+	 * @return me
 	 */
-	public void setObjectForCast(Object value, boolean instanceOf, String resultTypeClassName) throws StandardException
-	{
-		setValue(value);
-	}
+	public void setObjectForCast(Object theValue, boolean instanceOfResultType,
+			String resultTypeClassName) throws StandardException {
+		
+		if (theValue == null)
+		{
+			setToNull();
+			return;
+		}
+			
+		/*
+		 * Is the object of the right type? (only do the check if value is
+		 * non-null
+		 */
+		if (!instanceOfResultType) {
+				throw StandardException.newException(
+						SQLState.LANG_DATA_TYPE_SET_MISMATCH,
+						theValue.getClass().getName(), getTypeName(resultTypeClassName));
+		}
 
+		setObject(theValue);
+	}
+		
 	/**
-		Set the value from an object.
-		Usually overridden. This implementation sets this to
-		NULL if the passed in value is null, otherwise an exception
-		is thrown.
-	*/
-	public void setValue(Object theValue)
+	 * Set the value from an non-null object. Usually overridden.
+	 * This implementation throws an exception.
+	 * The object will have been correctly typed from the call to setObjectForCast.
+	 */
+	void setObject(Object theValue)
 		throws StandardException
 	{
-		if (theValue == null)
-			setToNull();
-		else
-			throwLangSetMismatch(theValue);
+		genericSetObject(theValue);
 	}
+	
+	/**
+	 * Get the type name of this value, possibly overriding
+	 * with the passed in class name (for user/java types).
+	 * @param className
+	 * @return
+	 */
+	String getTypeName(String className)
+	{
+		return getTypeName();
+	}
+
 
 	/**
 	 * Gets the value in the data value descriptor as a int.
@@ -566,12 +594,9 @@
 	}
 
 
-	protected void genericSetObject(Object theValue) throws StandardException {
+	void genericSetObject(Object theValue) throws StandardException {
 
-		//if (theValue instanceof String)
-		//	((DataValueDescriptor) this).setValue((String) theValue);
-		//else
-			throwLangSetMismatch(theValue);
+		throwLangSetMismatch(theValue);
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueDescriptor.java Sun Jan  1 11:12:54 2006
@@ -324,19 +324,6 @@
 		@exception StandardException thrown by me accessing my value.
 	*/
 	public void setInto(ResultSet rs, int position) throws SQLException, StandardException;
-
-	/**
-	 * Set the value of this DataValueDescriptor to the given value
-	 *
-	 * @param theValue	An Object containing the value to set this
-	 *					DataValueDescriptor to.  Null means set the value
-	 *					to SQL null.
-	 *
-	 * @return	This DataValueDescriptor
-	 *
-	 * @exception StandardException		Thrown on error
-	 */ 
-	public void setValue(Object theValue) throws StandardException;
 	
 	/**
 	 * Set the value of this DataValueDescriptor to the given int value
@@ -575,12 +562,15 @@
 	public String	getTypeName();
 
 	/**
-	 * Set the Object that this Data Type contains (for an explicit cast).
+	 * Set this value from an Object. Used from CAST of a Java type to
+	 * another type, including SQL types. If the passed instanceOfResultType
+	 * is false then the object is not an instance of the declared
+	 * type resultTypeClassName. Usually an exception should be thrown.
 	 *
 	 * @param value					The new value
 	 * @param instanceOfResultType	Whether or not the new value 
 	 *								is an instanceof the result type.
-	 * @param resultTypeClassName   The class name of the resulting type 
+	 * @param resultTypeClassName   The class name of the resulting (declared) type 
      *                              (for error messages only).
 	 *
 	 * @exception StandardException		Thrown on error

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java Sun Jan  1 11:12:54 2006
@@ -406,6 +406,16 @@
 		
 		setValue(theValue.intValue());
 	}
+	
+	/**
+	 * Set the value from a correctly typed Integer object.
+	 * Used for TINYINT, SMALLINT, INTEGER.
+	 * @throws StandardException 
+	 */
+	void setObject(Object theValue) throws StandardException
+	{
+		setValue(((Integer) theValue).intValue());
+	}
 
 	/**
 		setValue for integral exact numerics. Converts the BigDecimal

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBinary.java Sun Jan  1 11:12:54 2006
@@ -61,15 +61,13 @@
 import java.sql.PreparedStatement;
 
 /**
- * SQLBinary satisfies the DataValueDescriptor
- * interfaces (i.e., DataType). It implements a String holder,
- * e.g. for storing a column value; it can be specified
- * when constructed to not allow nulls. Nullability cannot be changed
- * after construction.
- * <p>
- * Because DataType is a subclass of DataType,
- * SQLBit can play a role in either a DataType/Value
- * or a DataType/KeyRow, interchangeably.
+ * SQLBinary is the abstract class for the binary datatypes.
+ * <UL>
+ * <LI> CHAR FOR BIT DATA
+ * <LI> VARCHAR FOR BIT DATA
+ * <LI> LONG VARCHAR
+ * <LI> BLOB
+ * </UL>
 
   <P>
   Format : <encoded length><raw data>
@@ -90,7 +88,7 @@
   (0xE0 is an esacape to allow any number of arbitary encodings in the future).
   </UL>
  */
-public abstract class SQLBinary
+abstract class SQLBinary
 	extends DataType implements BitDataValue
 {
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBit.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBit.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBit.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBit.java Sun Jan  1 11:12:54 2006
@@ -58,34 +58,7 @@
 import java.sql.SQLException;
 
 /**
- * SQLBit satisfies the DataValueDescriptor
- * interfaces (i.e., DataType). It implements a String holder,
- * e.g. for storing a column value; it can be specified
- * when constructed to not allow nulls. Nullability cannot be changed
- * after construction.
- * <p>
- * Because DataType is a subclass of DataType,
- * SQLBit can play a role in either a DataType/Value
- * or a DataType/KeyRow, interchangeably.
-
-  <P>
-  Format : <encoded length><raw data>
-  <BR>
-  Length is encoded to support 5.x databases where the length was stored as the number of bits.
-  The first bit of the first byte indicates if the format is an old (5.x) style or a new 8.1 style.
-  8.1 then uses the next two bits to indicate how the length is encoded.
-  <BR>
-  <encoded length> is one of N styles.
-  <UL>
-  <LI> (5.x format) 4 byte Java format integer value 0 - either <raw data> is 0 bytes/bits  or an unknown number of bytes.
-  <LI> (5.x format) 4 byte Java format integer value >0 (positive) - number of bits in <raw data>, number of bytes in <raw data>
-  is the minimum number of bytes required to store the number of bits.
-  <LI> (8.1 format) 1 byte encoded length (0 <= L <= 31) - number of bytes of <raw data> - encoded = 0x80 & L
-  <LI> (8.1 format) 3 byte encoded length (32 <= L < 64k) - number of bytes of <raw data> - encoded = 0xA0 <L as Java format unsigned short>
-  <LI> (8.1 format) 5 byte encoded length (64k <= L < 2G) - number of bytes of <raw data> - encoded = 0xC0 <L as Java format integer>
-  <LI> (future) to be determined L >= 2G - encoded 0xE0 <encoding of L to be determined>
-  (0xE0 is an esacape to allow any number of arbitary encodings in the future).
-  </UL>
+ * SQLBit represents the SQL type CHAR FOR BIT DATA
  */
 public class SQLBit
 	extends SQLBinary
@@ -128,20 +101,19 @@
 	}
 
 	/** 
+	 * Obtain the value using getBytes. This works for all FOR BIT DATA types.
+	 * Getting a stream is problematic as any other getXXX() call on the ResultSet
+	 * will close the stream we fetched. Therefore we have to create the value in-memory
+	 * as a byte array.
 	 * @see DataValueDescriptor#setValueFromResultSet 
 	 *
 	 * @exception SQLException		Thrown on error
 	 */
-	public void setValueFromResultSet(ResultSet resultSet, int colNumber,
+	public final void setValueFromResultSet(ResultSet resultSet, int colNumber,
 									  boolean isNullable)
 		throws SQLException
 	{
-			dataValue = resultSet.getBytes(colNumber);
-
-			if (isNullable && resultSet.wasNull())
-			{
-				setToNull();
-			}
+			setValue(resultSet.getBytes(colNumber));
 	}
 
 	/*
@@ -153,6 +125,15 @@
 	{
 		return TypeId.BIT_PRECEDENCE;
 	}
+	
+	/**
+	 * Set the value from an non-null object.
+	 */
+	final void setObject(Object theValue)
+		throws StandardException
+	{
+		setValue((byte[]) theValue);
+	}
 
 	/*
 	 * constructors
@@ -170,28 +151,6 @@
 		dataValue = val;
 	}
 
-
-	/**
-	 * @see DataValueDescriptor#setValue
-	 *
-	 */	
-	public final void setValue(Object theValue)
-		throws StandardException
-	{
-		if (theValue == null)
-		{
-			setToNull();
-		}
-		else if (theValue instanceof byte[])
-		{
-			((SQLBinary) this).setValue((byte[])theValue);
-		}
-		else
-		{
-			throwLangSetMismatch(theValue);
-		}
-	}
-
 	/**
 	 * Normalization method - this method may be called when putting
 	 * a value into a SQLBit, for example, when inserting into a SQLBit
@@ -230,7 +189,7 @@
 	 * @exception StandardException		Thrown on non-zero truncation
 	 *		if errorOnTrunc is true	
 	 */
-	public DataValueDescriptor setWidth(int desiredWidth, 
+	public void setWidth(int desiredWidth, 
 			int desiredScale,	// Ignored 
 			boolean errorOnTrunc)
 			throws StandardException
@@ -240,7 +199,7 @@
 		*/
 		if (getValue() == null)
 		{
-			return this;
+			return;
 		}
 
 		int sourceWidth = dataValue.length;
@@ -286,7 +245,6 @@
 			dataValue = shrunkData;
 
 		}
-		return this;
 	}
 
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java Sun Jan  1 11:12:54 2006
@@ -119,14 +119,14 @@
     // Anyhow, here we just ignore the call, since there is no padding to be done.
     // We do detect truncation, if the errorOnTrunc flag is set.
     // DB2 does return a WARNING on CAST and ERROR on INSERT.
-	public DataValueDescriptor setWidth(int desiredWidth,  // ignored!
+	public void setWidth(int desiredWidth,  // ignored!
 			int desiredScale,	// Ignored 
 			boolean errorOnTrunc)
 			throws StandardException
     {
 
 		if (isNull())
-			return this;
+			return;
 
 		int sourceWidth = getLength();
 
@@ -147,8 +147,6 @@
 				dataValue = shrunkData;
             }
         }
-
-        return this;
     }
 
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java Sun Jan  1 11:12:54 2006
@@ -611,21 +611,9 @@
 	/**
 	 * @see DataValueDescriptor#setValue
 	 */	
-	public void setValue(Object theValue)
-		throws StandardException
+	void setObject(Object theValue)
 	{
-		if ((theValue instanceof Boolean) ||
-			(theValue == null))
-		{
-			this.setValue((Boolean)theValue);
-		}
-		else if (theValue instanceof Number) {
-			setValueCore((Number) theValue);
-		}
-		else
-		{
-			genericSetObject(theValue);
-		}
+		setValue((Boolean) theValue);
 	}
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 

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=360519&r1=360518&r2=360519&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 Sun Jan  1 11:12:54 2006
@@ -108,7 +108,7 @@
 		}
 	}
 
-	public static void appendBlanks(char[] ca, int offset, int howMany) {
+	private static void appendBlanks(char[] ca, int offset, int howMany) {
 		while (howMany > 0) {
 
 			int count = howMany > BLANKS.length ? BLANKS.length : howMany;
@@ -1194,39 +1194,37 @@
 		intLength = 0;
 		cKey = null;
 	}
-
+	
 	/**
-	 * @see DataValueDescriptor#setValue
+	 * Allow any Java type to be cast to a character type using
+	 * Object.toString.
+	 * @see DataValueDescriptor#setObjectForCast
+	 * 
+	 * @exception StandardException
+	 *                thrown on failure
+	 * 
+	 * @return me
 	 */
-	public void setValue(Object theValue)  throws StandardException
-	{
-		if ((theValue instanceof String) ||
-			(theValue == null))
+	public void setObjectForCast(Object theValue, boolean instanceOfResultType,
+			String resultTypeClassName) throws StandardException {
+		
+		if (theValue == null)
 		{
-			setValue((String) theValue);
+			setToNull();
+			return;
 		}
-		else
-		{
 
-			{
-				setValue(theValue.toString());
-			}
-		}
+		if ("java.lang.String".equals(resultTypeClassName))
+		    setValue(theValue.toString());
+		else
+			super.setObjectForCast(theValue, instanceOfResultType, resultTypeClassName);
 	}
+	
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 
 		setValue(theValue.getString());
 	}
 
-
-	private void setAsToNationalString(Object theValue) 
-	{
-		String s = null;
-		if (theValue != null)
-			s = theValue.toString();
-		setValue(s);
-	}
-
 	/**
 	 * Normalization method - this method may be called when putting
 	 * a value into a SQLChar, for example, when inserting into a SQLChar
@@ -1348,7 +1346,7 @@
 	 *		is true and when a shrink will truncate non-white
 	 *		spaces.
 	 */
-	public DataValueDescriptor setWidth(int desiredWidth,
+	public void setWidth(int desiredWidth,
 									int desiredScale, // Ignored
 									boolean errorOnTrunc)
 							throws StandardException
@@ -1360,7 +1358,7 @@
 		*/
 		if (getString() == null)
 		{
-			return this;
+			return;
 		}
 
 		sourceWidth = getLength();
@@ -1401,7 +1399,7 @@
 			*/
 			setValue(getString().substring(0, desiredWidth));
 		}
-		return this;
+		return;
 	}
 
 	/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLClob.java Sun Jan  1 11:12:54 2006
@@ -298,14 +298,4 @@
 	{
 		throwLangSetMismatch("byte[]");
 	}
-
-	public void setValue(Object theValue)
-		throws StandardException
-	{
-		if (theValue == null)
-			setToNull();
-		else
-			throwLangSetMismatch(theValue);
-	}
-
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDate.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDate.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDate.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDate.java Sun Jan  1 11:12:54 2006
@@ -534,25 +534,13 @@
         }
     } // end of parseDate
 
-	public void setValue(Object theValue) throws StandardException
+	/**
+	 * Set the value from a correctly typed Date object.
+	 * @throws StandardException 
+	 */
+	void setObject(Object theValue) throws StandardException
 	{
-		if (theValue == null)
-		{
-			setToNull();
-		}
-		else if (theValue instanceof Date)
-		{
-			setValue((Date)theValue, (Calendar) null);
-		}
-		else if (theValue instanceof Timestamp)
-		{
-			setValue((Timestamp)theValue, (Calendar) null);
-		}
-		else
-		{
-			genericSetObject(theValue);
-		}
-
+		setValue((Date) theValue);
 	}
 
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java Sun Jan  1 11:12:54 2006
@@ -369,27 +369,14 @@
 	}
 
 	/**
-	 * @see DataValueDescriptor#setValue
-	 *
-	 */	
-	public void setValue(Object theValue)
-		throws StandardException
+	 * Set the value from a correctly typed BigDecimal object.
+	 * @throws StandardException 
+	 */
+	void setObject(Object theValue) throws StandardException
 	{
-		rawData = null;
-		if ((theValue instanceof BigDecimal) ||
-			(theValue == null))
-		{
-			setCoreValue((BigDecimal)theValue);
-		}
-		else if (theValue instanceof Number)
-		{
-			value = new BigDecimal(Double.toString(((Number)theValue).doubleValue()));
-		}
-		else
-		{
-			genericSetObject(theValue);
-		}
+		setValue((BigDecimal) theValue);
 	}
+	
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 
 		setCoreValue(SQLDecimal.getBigDecimal(theValue));
@@ -1064,13 +1051,13 @@
 	 * @exception StandardException		Thrown on non-zero truncation
 	 *		if errorOnTrunc is true	
 	 */
-	public DataValueDescriptor setWidth(int desiredPrecision, 
+	public void setWidth(int desiredPrecision, 
 			int desiredScale,
 			boolean errorOnTrunc)
 			throws StandardException
 	{
 		if (isNull())
-			return this;
+			return;
 			
 		if (desiredPrecision != IGNORE_PRECISION &&
 			((desiredPrecision - desiredScale) <  SQLDecimal.getWholeDigits(getBigDecimal())))
@@ -1080,7 +1067,6 @@
 		}
 		value = value.setScale(desiredScale, BigDecimal.ROUND_DOWN);
 		rawData = null;
-		return this;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDouble.java Sun Jan  1 11:12:54 2006
@@ -176,27 +176,16 @@
 			return new Double(value);
 	}
 
+
 	/**
-	 * @see DataValueDescriptor#setValue
-	 *
-	 * @exception StandardException on error
-	 */	
-	public void setValue(Object theValue)
-		throws StandardException
+	 * Set the value from a correctly typed Double object.
+	 * @throws StandardException 
+	 */
+	void setObject(Object theValue) throws StandardException
 	{
-		if (theValue == null)
-		{
-			setToNull();
-		}
-		else if (theValue instanceof Number)
-		{
-			this.setValue(((Number)theValue).doubleValue());
-		}
-		else
-		{
-			genericSetObject(theValue);
-		}
+		setValue(((Double) theValue).doubleValue());
 	}
+	
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 		setValue(theValue.getDouble());
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLInteger.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLInteger.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLInteger.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLInteger.java Sun Jan  1 11:12:54 2006
@@ -404,30 +404,6 @@
 		isnull = false;
 	}
 
-
-	/**
-	 * @see DataValueDescriptor#setValue
-	 *
-	 * @exception StandardException on failure of intValue on Number
-	 *
-	 */	
-	public void setValue(Object theValue) 
-		throws StandardException
-	{
-		if (theValue == null)
-		{
-			setToNull();
-		}
-		else if (theValue instanceof Number)
-		{
-			this.setValue(((Number)theValue).intValue());
-		}
-		else
-		{
-			genericSetObject(theValue);
-		}
-	}
-
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 
 		setValue(theValue.getInt());

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongVarbit.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongVarbit.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongVarbit.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongVarbit.java Sun Jan  1 11:12:54 2006
@@ -46,16 +46,7 @@
 import java.sql.SQLException;
 
 /**
- * SQLLongVarbit satisfies the DataValueDescriptor
- * interfaces (i.e., OrderableDataType). It implements a String holder,
- * e.g. for storing a column value; it can be specified
- * when constructed to not allow nulls. Nullability cannot be changed
- * after construction.
- * <p>
- * Because OrderableDataType is a subclass of DataType,
- * SQLLongVarbit can play a role in either a DataType/Value
- * or a OrderableDataType/KeyRow, interchangeably.
- *
+ * SQLLongVarbit represents the SQL type LONG VARCHAR FOR BIT DATA
  * It is an extension of SQLVarbit and is virtually indistinguishable
  * other than normalization.
  */
@@ -75,19 +66,6 @@
 		return new SQLLongVarbit();
 	}
 
-	/** 
-	 * @see DataValueDescriptor#setValueFromResultSet 
-	 *
-	 * @exception SQLException		Thrown on error
-	 */
-	public void setValueFromResultSet(ResultSet resultSet, int colNumber,
-									  boolean isNullable)
-		throws SQLException
-	{
-			stream = resultSet.getBinaryStream(colNumber);
-			dataValue = null;
-	}
-
 	/**
 		Return my format identifier.
 
@@ -155,7 +133,7 @@
 			this.dataValue = other.dataValue;
 		}
 		else
-			((SQLBinary) this).setValue(source.getBytes());
+			setValue(source.getBytes());
 	}
 
 	/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongint.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongint.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongint.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLLongint.java Sun Jan  1 11:12:54 2006
@@ -426,26 +426,14 @@
 	}
 
 	/**
-	 * @see DataValueDescriptor#setValue
-	 *
-	 * @exception StandardException		Thrown on error
-	 */	
-	public void setValue(Object theValue)
-		throws StandardException
+	 * Set the value from a correctly typed Long object.
+	 * @throws StandardException 
+	 */
+	void setObject(Object theValue)
 	{
-		if (theValue == null)
-		{
-			setToNull();
-		}
-		else if (theValue instanceof Number)
-		{
-			this.setValue(((Number)theValue).longValue());
-		}
-		else
-		{
-			genericSetObject(theValue);
-		}
+		setValue(((Long) theValue).longValue());
 	}
+	
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 
 		setValue(theValue.getLong());

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLReal.java Sun Jan  1 11:12:54 2006
@@ -466,27 +466,12 @@
 	}
 
 	/**
-	 * @see DataValueDescriptor#setValue
-	 *
-	 * @exception StandardException		Thrown on error
-	 */	
-	public void setValue(Object theValue)
-		throws StandardException
+	 * Set the value from a correctly typed Float object.
+	 * @throws StandardException 
+	 */
+	void setObject(Object theValue) throws StandardException
 	{
-		if (theValue == null)
-		{
-			setToNull();
-		}
-		else if (theValue instanceof Number)
-		{
-            // rounding issue to solve!!!/jsk, INF, 0.0f
-			this.setValue(((Number)theValue).floatValue());
-		}
-		else
-		{
-            // will most likely call .setValue(String)
-			genericSetObject(theValue);
-		}
+		setValue(((Float) theValue).floatValue());
 	}
 
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLRef.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLRef.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLRef.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLRef.java Sun Jan  1 11:12:54 2006
@@ -87,25 +87,12 @@
 		return value;
 	}
 
-	/**
-	 * @see DataValueDescriptor#setValue
-	 */
-	public void setValue(Object theValue)
-		throws StandardException
-	{
-		if ((theValue instanceof RowLocation) ||
-			(theValue == null))
-		{
-			this.setValue((RowLocation)theValue);
-		}
-		else
-		{
-			throwLangSetMismatch(theValue);
-		}
-	}
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 
-		setValue(theValue.getObject());
+		if (theValue.isNull())
+			setToNull();
+		else
+			value = (RowLocation) theValue.getObject();
 	}
 
 	public int getLength()

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLSmallint.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLSmallint.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLSmallint.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLSmallint.java Sun Jan  1 11:12:54 2006
@@ -443,27 +443,6 @@
 		isnull = false;
 	}
 
-	/**
-	 * @see DataValueDescriptor#setValue
-	 *
-	 * @exception StandardException		Thrown on error
-	 */	
-	public void setValue(Object theValue)
-		throws StandardException
-	{
-		if (theValue == null)
-		{
-			setToNull();
-		}		
-		else if (theValue instanceof Number)
-		{
-			this.setValue(((Number)theValue).shortValue());
-		}
-		else
-		{
-			genericSetObject(theValue);
-		}
-	}
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 
 		setValue(theValue.getShort());

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTime.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTime.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTime.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTime.java Sun Jan  1 11:12:54 2006
@@ -586,25 +586,15 @@
         }
     } // end of parseTime
 
-	public void setValue(Object theValue) throws StandardException
+	/**
+	 * Set the value from a correctly typed Time object.
+	 * @throws StandardException 
+	 */
+	void setObject(Object theValue) throws StandardException
 	{
-		restoreToNull();
-		if (theValue != null)
-		{
-			if (theValue instanceof Time)
-			{
-				this.setValue((Time)theValue, (Calendar) null);
-			}
-			else if (theValue instanceof Timestamp)
-			{
-				this.setValue((Timestamp)theValue, (Calendar) null);
-			}
-			else
-			{
-				genericSetObject(theValue);
-			}
-		}
+		setValue((Time) theValue);
 	}
+    
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 
 		if (theValue instanceof SQLTime) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java Sun Jan  1 11:12:54 2006
@@ -630,32 +630,14 @@
     } // end of parseDateOrTimestamp
 
 	/**
-	 * @see DataValueDescriptor#setValue
-	 *
+	 * Set the value from a correctly typed Timestamp object.
+	 * @throws StandardException 
 	 */
-	public void setValue(Object theValue) throws StandardException
+	void setObject(Object theValue) throws StandardException
 	{
-		if (theValue == null)
-		{
-			setToNull();
-		}
-		else if (theValue instanceof Date)
-		{
-			this.setValue((Date)theValue, (Calendar) null);
-		}
-		else if (theValue instanceof Time)
-		{
-			this.setValue((Time)theValue, (Calendar) null);
-		}
-		else if (theValue instanceof Timestamp)
-		{
-			this.setValue((Timestamp)theValue, (Calendar) null);
-		}
-		else
-		{
-			genericSetObject(theValue);
-		}
+		setValue((Timestamp) theValue);
 	}
+	
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 
 		if (theValue instanceof SQLTimestamp) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTinyint.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTinyint.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTinyint.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLTinyint.java Sun Jan  1 11:12:54 2006
@@ -449,27 +449,7 @@
 		isnull = false;
 	}
 
-	/**
-	 * @see DataValueDescriptor#setValue
-	 *
-	 * @exception StandardException		Thrown on error
-	 */	
-	public void setValue(Object theValue)
-		throws StandardException
-	{
-		if (theValue == null)
-		{
-			setToNull();
-		}
-		else if (theValue instanceof Number)
-		{
-			this.setValue(((Number)theValue).byteValue());
-		}
-		else
-		{
-			genericSetObject(theValue);
-		}
-	}
+	
 	protected void setFrom(DataValueDescriptor theValue) throws StandardException {
 
 		setValue(theValue.getByte());

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLVarbit.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLVarbit.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLVarbit.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLVarbit.java Sun Jan  1 11:12:54 2006
@@ -47,17 +47,8 @@
 import java.io.IOException;
 
 /**
- * SQLVarbit satisfies the DataValueDescriptor
- * interfaces (i.e., OrderableDataType). It implements a String holder,
- * e.g. for storing a column value; it can be specified
- * when constructed to not allow nulls. Nullability cannot be changed
- * after construction.
- * <p>
- * Because OrderableDataType is a subclass of DataType,
- * SQLVarbit can play a role in either a DataType/Value
- * or a OrderableDataType/KeyRow, interchangeably.
- *
- * It is an extension of SQLVarbit and is virtually indistinguishable
+ * SQLVarbit represents the SQL type VARCHAR FOR BIT DATA
+ * It is an extension of SQLBit and is virtually indistinguishable
  * other than normalization.
  */
 public class SQLVarbit extends SQLBit
@@ -108,7 +99,7 @@
 		int		desiredWidth = desiredType.getMaximumWidth();
 
 		byte[] sourceData = source.getBytes();
-		((SQLBinary) this).setValue(sourceData);
+		setValue(sourceData);
 		if (sourceData.length > desiredWidth)
 			setWidth(desiredWidth, 0, true);
 	}
@@ -127,7 +118,7 @@
 	 * @exception StandardException		Thrown on non-zero truncation
 	 *		if errorOnTrunc is true	
 	 */
-	public DataValueDescriptor setWidth(int desiredWidth, 
+	public void setWidth(int desiredWidth, 
 			int desiredScale,	// Ignored 
 			boolean errorOnTrunc)
 			throws StandardException
@@ -137,7 +128,7 @@
 		*/
 		if (getValue() == null)
 		{
-			return this;
+			return;
 		}
 
 		int sourceWidth = dataValue.length;
@@ -169,7 +160,6 @@
 			dataValue = shrunkData;
 
 		}
-		return this;
 	}
 
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/TypeId.java Sun Jan  1 11:12:54 2006
@@ -910,9 +910,7 @@
 
                         case StoredFormatIds.BLOB_TYPE_ID:
                                 typePrecedence = BLOB_PRECEDENCE;
-                                // no java type name, can't be used as java object
-                                javaTypeName = "byte[]"; 
-                                //javaTypeName = "java.sql.Blob";  // doesn't work w casting
+                                javaTypeName = "java.sql.Blob";
                                 maxMaxWidth = TypeId.BLOB_MAXWIDTH;
                                 isBitTypeId = true;
                                 isConcatableTypeId = true;
@@ -930,9 +928,7 @@
 
                       case StoredFormatIds.CLOB_TYPE_ID:
                               typePrecedence = CLOB_PRECEDENCE;
-                              // no java type name, can't be used as java object
-                              javaTypeName = "java.lang.String";
-                              //javaTypeName = "java.sql.Clob"; // doesn't work w casting
+                              javaTypeName = "java.sql.Clob";
                               maxMaxWidth = TypeId.CLOB_MAXWIDTH;
                               isStringTypeId = true;
                               isConcatableTypeId = true;
@@ -942,9 +938,7 @@
 
                       case StoredFormatIds.NCLOB_TYPE_ID:
                               typePrecedence = NCLOB_PRECEDENCE;
-                              // no java type name, can't be used as java object
-                              javaTypeName = "java.lang.String"; 
-                              //javaTypeName = "java.sql.Clob";  // doesn't work w casting
+                              javaTypeName = "java.sql.Clob";
                               maxMaxWidth = TypeId.NCLOB_MAXWIDTH;
                               isStringTypeId = true;
                               isConcatableTypeId = true;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/UserType.java Sun Jan  1 11:12:54 2006
@@ -238,32 +238,6 @@
 	{
 		return value;
 	}
-
-	/**
-	* @see DataValueDescriptor#setObjectForCast
-	*
-	* @exception StandardException thrown on failure
-	*
-	* @return me
-	*/
-	public void setObjectForCast(Object theValue, boolean instanceOfResultType, String resultTypeClassName)
-		throws StandardException
-	{
-		/* This check is a performance problem.  We need to it though
-		 * to catch ClassCastExceptions.
-		 */
-		/* Is the object of the right type? (only do the check if value is non-null */
-		if (theValue != null)
-		{
-			if ( ! instanceOfResultType)
-			{
-				throw StandardException.newException(SQLState.LANG_DATA_TYPE_SET_MISMATCH, 
-								getTypeName(), resultTypeClassName);
-			}
-		}
-
-		setValue(theValue);
-	}
 		
 	public int getLength()
 	{
@@ -275,6 +249,17 @@
 	{
 
 		return isNull() ? "JAVA_OBJECT" : ClassInspector.readableClassName(value.getClass());
+	}
+	
+	/**
+	 * Get the type name of this value,  overriding
+	 * with the passed in class name (for user/java types).
+	 * @param className
+	 * @return
+	 */
+	String getTypeName(String className)
+	{
+		return className;
 	}
 
 	/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/VariableSizeDataValue.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/VariableSizeDataValue.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/VariableSizeDataValue.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/VariableSizeDataValue.java Sun Jan  1 11:12:54 2006
@@ -49,7 +49,7 @@
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public DataValueDescriptor setWidth(int desiredWidth,
+	public void setWidth(int desiredWidth,
 									int desiredScale,
 									boolean errorOnTrunc)
 							throws StandardException;

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=360519&r1=360518&r2=360519&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 Sun Jan  1 11:12:54 2006
@@ -201,7 +201,7 @@
 		UserDataValue dvd = (UserDataValue) getParameterForSet(position);
 
 		GenericParameter gp = parms[position];
-		if (value != null && (gp.jdbcTypeId == Types.OTHER || gp.jdbcTypeId == org.apache.derby.iapi.reference.JDBC20Translation.SQL_TYPES_JAVA_OBJECT)) {
+		if (value != null) {
 
 			{
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java Sun Jan  1 11:12:54 2006
@@ -596,11 +596,13 @@
 			{
 				if (getTypeId().isNumericTypeId())
 				{
+					// to leave the DataValueDescriptor value on the stack, since setWidth is void
+					mb.dup();
+
 					mb.push(getTypeServices().getPrecision());
 					mb.push(getTypeServices().getScale());
 					mb.push(true);
-					mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.VariableSizeDataValue, "setWidth", ClassName.DataValueDescriptor, 3);
-					mb.cast(resultTypeName);
+					mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.VariableSizeDataValue, "setWidth", "void", 3);
 				}
 			}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java Sun Jan  1 11:12:54 2006
@@ -157,16 +157,4 @@
 		mb.callMethod(VMOpcode.INVOKESTATIC, "org.apache.derby.iapi.util.StringUtil", "fromHexString",
 						"byte[]", 3);
 	}
-
-	
-	void setConstantWidth(ExpressionClassBuilder acb, MethodBuilder mb) {
-		if ((bitLength % 8) != 0) {
-			// temp for binary types.
-			mb.cast("org.apache.derby.iapi.types.VariableSizeDataValue");
-			mb.push(bitLength);
-			mb.push(0);
-			mb.push(false);
-			mb.callMethod(VMOpcode.INVOKEINTERFACE, null, "setWidth", "org.apache.derby.iapi.types.DataValueDescriptor", 3);
-		}
-	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Sun Jan  1 11:12:54 2006
@@ -920,127 +920,43 @@
 			For most types generate
 
 			targetDVD.setValue(sourceDVD);
+			
+			For source or destination java types generate
+			
+			Object o = sourceDVD.getObject();
+			targetDVD.setObjectForCast(o, o instanceof dest java type, dest java type);
 
 			// optional for variable length types
 			targetDVD.setWidth();
 		*/
 
-		if (!sourceCTI.isNationalStringTypeId() && !sourceCTI.userType() && !destCTI.userType()) {
-		mb.getField(field); // targetDVD reference for the setValue method call
-		mb.swap();
-		mb.cast(ClassName.DataValueDescriptor);
-		mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.DataValueDescriptor, "setValue", "void", 1);
-
-		mb.getField(field);
-		/* 
-		** If we are casting to a variable length datatype, we
-		** have to make sure we have set it to the correct
-		** length.
-		*/
-		if (destCTI.variableLength()) 
-		{
-			boolean isNumber = destCTI.isNumericTypeId();
-
-			/* setWidth() is on VSDV - upcast since
-			 * decimal implements subinterface
-			 * of VSDV.
-			 */
-			mb.push(isNumber ? castTarget.getPrecision() : castTarget.getMaximumWidth());
-			mb.push(castTarget.getScale());
-			mb.push(!sourceCTI.variableLength() || isNumber);
-			mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.VariableSizeDataValue, "setWidth", ClassName.DataValueDescriptor, 3);
-
-			/* setWidth returns DataValueDescriptor - we need
- 			 * to cast result to actual subinterface getting returned.
-			 */
-			mb.cast(resultTypeName);
-		}
-
-		return;
+		if (!sourceCTI.userType() && !destCTI.userType()) {
+			mb.getField(field); // targetDVD reference for the setValue method call
+			mb.swap();
+			mb.upCast(ClassName.DataValueDescriptor);
+			mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.DataValueDescriptor,
+					"setValue", "void", 1);
 		}
-
-
-
-
-
-
-		/*
-		** If we are casting from a national string to a date, time,
-		** or timestamp, do a getDate(), getTime(), or getTimestamp()
-		** rather than a getObject(). This is because getObject() returns
-		** a String, and setValue() can't tell whether the String comes
-		** from a national or non-national character type, so it can't tell
-		** whether to use the database locale to do the conversion.
-		*/
-		String getMethod = "getObject";
-		String getType = "java.lang.Object";
-		String castType = sourceCTI.getCorrespondingJavaTypeName();
-		int argCount = 0;
-		if (sourceCTI.isNationalStringTypeId())
-		{
-			switch (destCTI.getJDBCTypeId())
-			{
-			  case Types.DATE:
-				getMethod = "getDate";
-				getType = "java.sql.Date";
-				castType = getType;
-				break;
-
-			  case Types.TIME:
-				getMethod = "getTime";
-				getType = "java.sql.Time";
-				castType = getType;
-				break;
-
-			  case Types.TIMESTAMP:
-				getMethod = "getTimestamp";
-				getType = "java.sql.Timestamp";
-				castType = getType;
-				break;
-			}
-
-			if (!getMethod.equals("getObject")) {
-
-				mb.pushThis();
-				mb.callMethod(VMOpcode.INVOKEVIRTUAL, 
-					acb.getBaseClassName(), 
-					"getCalendar", "java.util.Calendar", 0);
-
-				argCount++;
-			}
-		}
-
-		/* 
-		** generate: field.setValue((<type>) expr.getObject ) 
-		** or		 field.setValue((<type>) expr.getDate )
-		** or		 field.setValue((<type>) expr.getTime )
-		** or		 field.setValue((<type>) expr.getTimestamp )
-		*/
-		mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.DataValueDescriptor, getMethod, getType, argCount);
-
-		/* 
-		** Cast to java.lang.Object if source or destination type 
-		** is a java type because that's how the interface is defined.
-		*/
-		mb.cast(destCTI.userType() || sourceCTI.userType() ? "java.lang.Object" : castType);
-		//castExpr
-
-		mb.getField(field); // instance for the setValue/setObjectForCast method call
-		mb.swap(); // push it before the value
-
-		/*
-		** If we are casting a java type, then
-		** we generate:
-		**
-		**		DataValueDescriptor.setObjectForCast(java.lang.Object castExpr, boolean instanceOfExpr, destinationClassName)
-		** where instanceOfExpr is "source instanceof destinationClass".
-		**
-		** otherwise:
-		**
-		**		<specificDataValue>.setValue(<type>castExpr)
-		*/
-		if (sourceCTI.userType())
+		else
 		{
+			/* 
+			** generate: expr.getObject()
+			*/
+			mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.DataValueDescriptor,
+					"getObject", "java.lang.Object", 0);
+
+			//castExpr
+
+			mb.getField(field); // instance for the setValue/setObjectForCast method call
+			mb.swap(); // push it before the value
+
+			/*
+			** We are casting a java type, generate:
+			**
+			**		DataValueDescriptor.setObjectForCast(java.lang.Object castExpr, boolean instanceOfExpr, destinationClassName)
+			** where instanceOfExpr is "source instanceof destinationClass".
+			**
+			*/
 			String destinationType = getTypeId().getCorrespondingJavaTypeName();
 
 			// at this point method instance and cast result are on the stack
@@ -1048,19 +964,11 @@
 			mb.dup();
 			mb.isInstanceOf(destinationType);
 			mb.push(destinationType);
-			mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.DataValueDescriptor, "setObjectForCast", "void", 3);
-		}
-		else
-		{
-			String itype = ClassName.DataValueDescriptor;
-			if (castType.startsWith("java.lang.")) {
-				if (!castType.equals("java.lang.String") && !castType.equals("java.lang.Object"))
-					itype = resultTypeName;
-			}
-			// System.out.println("type = " + castType);
-			mb.callMethod(VMOpcode.INVOKEINTERFACE, itype, "setValue", "void", 1);
-			// mb.endStatement();
+			mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.DataValueDescriptor,
+					"setObjectForCast", "void", 3);
+
 		}
+
 		mb.getField(field);
 
 		/* 
@@ -1071,54 +979,22 @@
 		if (destCTI.variableLength()) 
 		{
 			boolean isNumber = destCTI.isNumericTypeId();
+			
+			// to leave the DataValueDescriptor value on the stack, since setWidth is void
+			mb.dup();
 
 			/* setWidth() is on VSDV - upcast since
 			 * decimal implements subinterface
 			 * of VSDV.
 			 */
+			
 			mb.push(isNumber ? castTarget.getPrecision() : castTarget.getMaximumWidth());
 			mb.push(castTarget.getScale());
 			mb.push(!sourceCTI.variableLength() || isNumber);
-			mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.VariableSizeDataValue, "setWidth", ClassName.DataValueDescriptor, 3);
+			mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.VariableSizeDataValue,
+					"setWidth", "void", 3);
 
-								/*
-								** The last argument is true if we should
-								** throw error on truncation.  We throw an
-								** error on all but Bits and Strings
-								** (everything with variable length that
-								** isn't a number -- all variable length
-								** except DECIMAL/NUMERIC).
-								*/
-								/* RESOLVE:
-								** NOTE: If the source is a parameter
-								** then the user can pass any type
-								** in as the parameter.  We will not
-								** raise a truncation exception in
-								** this case, even if we would if the
-								** cast was directly on the value
-								** being passed in as a parameter.
-								** For example:
-								**	cast(123 as char(1)) throws truncation
-								**			exception
-								**	cast(? as char(1)), user passes 123
-								**		no truncation exception
-								** We are considering this behavior to be
-								** an extension, at least for now. We may 
-								** need to revisit this if there's a
-								** SQL-J compliance test with this.
-								** (The solution would be to add a method
-								** off of ParameterValueSet to get some
-								** info about the data type of the
-								** actual parameter and generate code for
-								** the 3rd parameter to setWidth() based
-								** on the execution time data type.
-								*/
-			/* setWidth returns DataValueDescriptor - we need
- 			 * to cast result to actual subinterface getting returned.
-			 */
-			mb.cast(resultTypeName);
 		}
-	
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java Sun Jan  1 11:12:54 2006
@@ -292,10 +292,13 @@
 		if (getTypeId().variableLength())//since result type is variable length, generate setWidth code.
 		{
 			boolean isNumber = getTypeId().isNumericTypeId();
+			// to leave the DataValueDescriptor value on the stack, since setWidth is void
+			mb.dup();
+
 			mb.push(isNumber ? getTypeServices().getPrecision() : getTypeServices().getMaximumWidth());
 			mb.push(getTypeServices().getScale());
 			mb.push(true);
-			mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.VariableSizeDataValue, "setWidth", ClassName.DataValueDescriptor, 3);
+			mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.VariableSizeDataValue, "setWidth", "void", 3);
 		}
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java Sun Jan  1 11:12:54 2006
@@ -1042,8 +1042,8 @@
 							mb.push(isNumericType ? paramdtd.getPrecision() : paramdtd.getMaximumWidth());
 							mb.push(paramdtd.getScale());
 							mb.push(isNumericType);
-							mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.VariableSizeDataValue, "setWidth", ClassName.DataValueDescriptor, 3);
-							mb.endStatement();
+							mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.VariableSizeDataValue, "setWidth", "void", 3);
+							// mb.endStatement();
 						}
 					}
 				}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/StorableFormatId.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/StorableFormatId.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/StorableFormatId.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/StorableFormatId.java Sun Jan  1 11:12:54 2006
@@ -247,26 +247,6 @@
     }
 
 	/**
-	 * Set the value of this DataValueDescriptor to the given value
-	 *
-	 * @param theValue	An Object containing the value to set this
-	 *					DataValueDescriptor to.  Null means set the value
-	 *					to SQL null.
-	 *
-	 * @return	This DataValueDescriptor
-	 *
-	 * @exception StandardException		Thrown on error
-     *
-     * @see org.apache.derby.iapi.types.DataValueDescriptor#setValue
-	 */ 
-	public void setValue(Object theValue) 
-        throws StandardException
-    {
-        throw(StandardException.newException(
-                SQLState.HEAP_UNIMPLEMENTED_FEATURE));
-    }
-
-	/**
 	 * Set the value of this DataValueDescriptor from another.
 	 *
 	 * @param theValue	The Date value to set this DataValueDescriptor to

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerate.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerate.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerate.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/conglomerate/GenericConglomerate.java Sun Jan  1 11:12:54 2006
@@ -169,25 +169,6 @@
                 SQLState.HEAP_UNIMPLEMENTED_FEATURE));
     }
 
-	/**
-	 * Set the value of this DataValueDescriptor to the given value
-	 *
-	 * @param theValue	An Object containing the value to set this
-	 *					DataValueDescriptor to.  Null means set the value
-	 *					to SQL null.
-	 *
-	 * @return	This DataValueDescriptor
-	 *
-	 * @exception StandardException		Thrown on error
-     *
-     * @see org.apache.derby.iapi.types.DataValueDescriptor#setValue
-	 */ 
-	public void setValue(Object theValue) 
-        throws StandardException
-    {
-        throw(StandardException.newException(
-                SQLState.HEAP_UNIMPLEMENTED_FEATURE));
-    }
 
 	/**
 	 * Set the value of this DataValueDescriptor from another.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapRowLocation.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapRowLocation.java?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapRowLocation.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/heap/HeapRowLocation.java Sun Jan  1 11:12:54 2006
@@ -106,8 +106,6 @@
 	public DataValueDescriptor getNewNull() {
 		return null;
 	}
-	public void setValue(Object o) {
-	}
 
 	public Object getObject() {
 		return null;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out Sun Jan  1 11:12:54 2006
@@ -1588,4 +1588,67 @@
 ij> -- clean up
 drop table t1;
 ERROR 42Y55: 'DROP TABLE' cannot be performed on 'T1' because it does not exist.
+ij> -- test some casting from a java type to standard SQL types.
+-- should all fail at runtime
+select cast (aliasinfo as BOOLEAN) from sys.sysaliases;
+1    
+-----
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'BOOLEAN'.
+ij> select cast (aliasinfo as SMALLINT) from sys.sysaliases;
+1     
+------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'SMALLINT'.
+ij> select cast (aliasinfo as INTEGER) from sys.sysaliases;
+1          
+-----------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'INTEGER'.
+ij> select cast (aliasinfo as BIGINT) from sys.sysaliases;
+1                   
+--------------------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'BIGINT'.
+ij> select cast (aliasinfo as REAL) from sys.sysaliases;
+1            
+-------------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'REAL'.
+ij> select cast (aliasinfo as DOUBLE) from sys.sysaliases;
+1                     
+----------------------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'DOUBLE'.
+ij> select cast (aliasinfo as DECIMAL(5,4)) from sys.sysaliases;
+1       
+--------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'DECIMAL'.
+ij> select cast (aliasinfo as CHAR(30) FOR BIT DATA) from sys.sysaliases;
+1                                                           
+------------------------------------------------------------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'CHAR () FOR BIT DATA'.
+ij> select cast (aliasinfo as VARCHAR(30) FOR BIT DATA) from sys.sysaliases;
+1                                                           
+------------------------------------------------------------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'VARCHAR () FOR BIT DATA'.
+ij> select cast (aliasinfo as LONG VARCHAR FOR BIT DATA) from sys.sysaliases;
+1                                                                                                                               
+--------------------------------------------------------------------------------------------------------------------------------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'LONG VARCHAR FOR BIT DATA'.
+ij> select cast (aliasinfo as BLOB) from sys.sysaliases;
+1                                                                                                                               
+--------------------------------------------------------------------------------------------------------------------------------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'BLOB'.
+ij> select cast (aliasinfo as CLOB) from sys.sysaliases where alias = 'INSTALL_JAR';
+1                                                                                                                               
+--------------------------------------------------------------------------------------------------------------------------------
+ERROR XCL12: An attempt was made to put a data value of type 'org.apache.derby.catalog.types.RoutineAliasInfo' into a data value of type 'CLOB'.
+ij> -- Java casts to character types excluding CLOB are supported using Object.toString
+select cast (aliasinfo as CHAR(240)) from sys.sysaliases where alias = 'INSTALL_JAR';
+1                                                                                                                               
+--------------------------------------------------------------------------------------------------------------------------------
+INSTALL_JAR(IN URL VARCHAR(256),IN JAR VARCHAR(128),IN DEPLOY INTEGER) LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA    &
+ij> select cast (aliasinfo as VARCHAR(240)) from sys.sysaliases where alias = 'INSTALL_JAR';
+1                                                                                                                               
+--------------------------------------------------------------------------------------------------------------------------------
+INSTALL_JAR(IN URL VARCHAR(256),IN JAR VARCHAR(128),IN DEPLOY INTEGER) LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA     
+ij> select cast (aliasinfo as LONG VARCHAR) from sys.sysaliases where alias = 'INSTALL_JAR';
+1                                                                                                                               
+--------------------------------------------------------------------------------------------------------------------------------
+INSTALL_JAR(IN URL VARCHAR(256),IN JAR VARCHAR(128),IN DEPLOY INTEGER) LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA     
 ij> 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/cast.sql
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/cast.sql?rev=360519&r1=360518&r2=360519&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/cast.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/cast.sql Sun Jan  1 11:12:54 2006
@@ -691,3 +691,23 @@
 
 -- clean up
 drop table t1;
+
+-- test some casting from a java type to standard SQL types.
+-- should all fail at runtime
+select cast (aliasinfo as BOOLEAN) from sys.sysaliases;
+select cast (aliasinfo as SMALLINT) from sys.sysaliases;
+select cast (aliasinfo as INTEGER) from sys.sysaliases;
+select cast (aliasinfo as BIGINT) from sys.sysaliases;
+select cast (aliasinfo as REAL) from sys.sysaliases;
+select cast (aliasinfo as DOUBLE) from sys.sysaliases;
+select cast (aliasinfo as DECIMAL(5,4)) from sys.sysaliases;
+select cast (aliasinfo as CHAR(30) FOR BIT DATA) from sys.sysaliases;
+select cast (aliasinfo as VARCHAR(30) FOR BIT DATA) from sys.sysaliases;
+select cast (aliasinfo as LONG VARCHAR FOR BIT DATA) from sys.sysaliases;
+select cast (aliasinfo as BLOB) from sys.sysaliases;
+select cast (aliasinfo as CLOB) from sys.sysaliases where alias = 'INSTALL_JAR';
+
+-- Java casts to character types excluding CLOB are supported using Object.toString
+select cast (aliasinfo as CHAR(240)) from sys.sysaliases where alias = 'INSTALL_JAR';
+select cast (aliasinfo as VARCHAR(240)) from sys.sysaliases where alias = 'INSTALL_JAR';
+select cast (aliasinfo as LONG VARCHAR) from sys.sysaliases where alias = 'INSTALL_JAR';