Return-Path: Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 87015 invoked by uid 500); 6 Jan 2005 21:45:42 -0000 Delivered-To: apmail-incubator-derby-cvs@incubator.apache.org Received: (qmail 87012 invoked by uid 99); 6 Jan 2005 21:45:42 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 06 Jan 2005 13:45:41 -0800 Received: (qmail 66551 invoked by uid 65534); 6 Jan 2005 21:45:35 -0000 Date: 6 Jan 2005 21:45:35 -0000 Message-ID: <20050106214535.66535.qmail@minotaur.apache.org> From: djd@apache.org To: derby-cvs@incubator.apache.org Subject: svn commit: r124455 - in incubator/derby/code/trunk/java: engine/org/apache/derby/iapi/types engine/org/apache/derby/impl/sql/compile engine/org/apache/derby/impl/sql/execute testing/org/apache/derbyTesting/functionTests/master MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked Author: djd Date: Thu Jan 6 13:45:32 2005 New Revision: 124455 URL: http://svn.apache.org/viewcvs?view=rev&rev=124455 Log: Incremental step to isolating SQLDecimal and BigDecimal from the majority of the code, for J2ME/CDC/Foundation/JSR169. Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java Thu Jan 6 13:45:32 2005 @@ -22,7 +22,6 @@ import org.apache.derby.iapi.types.TypeId; -import org.apache.derby.iapi.types.DataValueFactory; import org.apache.derby.iapi.types.NumberDataValue; import org.apache.derby.iapi.types.BooleanDataValue; import org.apache.derby.iapi.types.BitDataValue; Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java Thu Jan 6 13:45:32 2005 @@ -298,7 +298,26 @@ setValue(theValue.booleanValue()); } - + /** + Return the precision of this specific DECIMAL value. + If the value does not represent a SQL DECIMAL then + the return is undefined. + */ + public int getDecimalValuePrecision() + { + return -1; + } + + /** + Return the scale of this specific DECIMAL value. + If the value does not represent a SQL DECIMAL then + the return is undefined. + */ + public int getDecimalValueScale() + { + return -1; + } + protected final boolean objectNull(Object o) { if (o == null) Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataValue.java Thu Jan 6 13:45:32 2005 @@ -258,6 +258,20 @@ * */ public void setValue(Boolean theValue) throws StandardException; + + /** + Return the precision of this specific DECIMAL value. + If the value does not represent a SQL DECIMAL then + the return is undefined. + */ + public int getDecimalValuePrecision(); + + /** + Return the scale of this specific DECIMAL value. + If the value does not represent a SQL DECIMAL then + the return is undefined. + */ + public int getDecimalValueScale(); } Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java Thu Jan 6 13:45:32 2005 @@ -65,12 +65,12 @@ * * @author jamie */ -public final class SQLDecimal extends NumberDataType implements VariableSizeDataValue +final class SQLDecimal extends NumberDataType implements VariableSizeDataValue { - public static final BigDecimal ZERO = BigDecimal.valueOf(0L); - public static final BigDecimal ONE = BigDecimal.valueOf(1L); - public static final BigDecimal MAXLONG_PLUS_ONE = BigDecimal.valueOf(Long.MAX_VALUE).add(ONE); - public static final BigDecimal MINLONG_MINUS_ONE = BigDecimal.valueOf(Long.MIN_VALUE).subtract(ONE); + static final BigDecimal ZERO = BigDecimal.valueOf(0L); + static final BigDecimal ONE = BigDecimal.valueOf(1L); + static final BigDecimal MAXLONG_PLUS_ONE = BigDecimal.valueOf(Long.MAX_VALUE).add(ONE); + static final BigDecimal MINLONG_MINUS_ONE = BigDecimal.valueOf(Long.MIN_VALUE).subtract(ONE); @@ -385,7 +385,7 @@ public int getLength() { - return getPrecision(); + return getDecimalValuePrecision(); } // this is for DataType's error generator @@ -1040,7 +1040,7 @@ return this; } - public int getPrecision() + public int getDecimalValuePrecision() { return getPrecision(getBigDecimal()); } @@ -1050,7 +1050,7 @@ * * @return the precision */ - public static int getPrecision(BigDecimal decimalValue) + private static int getPrecision(BigDecimal decimalValue) { if ((decimalValue == null) || decimalValue.equals(ZERO)) @@ -1061,18 +1061,18 @@ return getWholeDigits(decimalValue) + decimalValue.scale(); } - public int getScale() + public int getDecimalValueScale() { BigDecimal localValue = getBigDecimal(); return (localValue == null) ? 0 : localValue.scale(); } - public int getWholeDigits() + private int getWholeDigits() { return getWholeDigits(getBigDecimal()); } - public static int getWholeDigits(BigDecimal decimalValue) + private static int getWholeDigits(BigDecimal decimalValue) { if ((decimalValue == null) || decimalValue.equals(ZERO)) @@ -1091,15 +1091,5 @@ String s = decimalValue.toString(); return (decimalValue.scale() == 0) ? s.length() : s.indexOf('.'); - } - - /** - * Return the value field - * - * @return BigDecimal - */ - public BigDecimal getValue() - { - return getBigDecimal(); } } Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java Thu Jan 6 13:45:32 2005 @@ -53,7 +53,7 @@ * @author Jeff */ -public abstract class BaseTypeCompiler implements TypeCompiler +abstract class BaseTypeCompiler implements TypeCompiler { TypeId correspondingTypeId; Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Thu Jan 6 13:45:32 2005 @@ -337,38 +337,23 @@ } break; + case Types.DECIMAL: + // ignore decimal -> decimal casts for now + if (destJDBCTypeId == Types.DECIMAL || + destJDBCTypeId == Types.NUMERIC) + break; + // fall through case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: - long longValue = ((NumericConstantNode) castOperand).getLong(); - retNode = getCastFromIntegralType( - longValue, - destJDBCTypeId); - break; - case Types.DOUBLE: case Types.REAL: - double doubleValue = ((NumericConstantNode) castOperand).getDouble(); - retNode = getCastFromNonIntegralType( - doubleValue, + retNode = getCastFromNumericType( + ((ConstantNode) castOperand).getValue(), destJDBCTypeId); break; - case Types.DECIMAL: - // ignore decimal -> decimal casts for now - if (destJDBCTypeId != Types.DECIMAL && - destJDBCTypeId != Types.NUMERIC) - { - /* SQLDecimal.getDouble() throws an exception if the - * BigDecimal is outside of the range of double. - */ - doubleValue = ((ConstantNode) castOperand).getValue().getDouble(); - retNode = getCastFromNonIntegralType( - doubleValue, - destJDBCTypeId); - } - break; } // Return the new constant if the cast was performed @@ -668,93 +653,67 @@ * * @exception StandardException Thrown on error */ - private ValueNode getCastFromNonIntegralType( - double doubleValue, + private ValueNode getCastFromNumericType( + DataValueDescriptor constantValue, int destJDBCTypeId) throws StandardException { - String stringValue = null; - ValueNode retNode = this; + int nodeType = -1; + Object constantObject = null; switch (destJDBCTypeId) { case Types.CHAR: + nodeType = C_NodeTypes.CHAR_CONSTANT_NODE; + constantObject = constantValue.getString(); return (ValueNode) getNodeFactory().getNode( - C_NodeTypes.CHAR_CONSTANT_NODE, - Double.toString(doubleValue), + nodeType, + constantObject, ReuseFactory.getInteger( castTarget.getMaximumWidth()), getContextManager()); + case Types.TINYINT: - doubleValue = Math.floor(doubleValue); - if (doubleValue < Byte.MIN_VALUE || - doubleValue > Byte.MAX_VALUE) - { - throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "TINYINT"); - } - return (ValueNode) getNodeFactory().getNode( - C_NodeTypes.TINYINT_CONSTANT_NODE, - ReuseFactory.getByte( - (byte) doubleValue), - getContextManager()); + nodeType = C_NodeTypes.TINYINT_CONSTANT_NODE; + constantObject = new Byte(constantValue.getByte()); + break; case Types.SMALLINT: - doubleValue = Math.floor(doubleValue); - if (doubleValue < Short.MIN_VALUE || - doubleValue > Short.MAX_VALUE) - { - throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "SMALLINT"); - } - return (ValueNode) getNodeFactory().getNode( - C_NodeTypes.SMALLINT_CONSTANT_NODE, - ReuseFactory.getShort( - (short) doubleValue), - getContextManager()); + nodeType = C_NodeTypes.SMALLINT_CONSTANT_NODE; + constantObject = ReuseFactory.getShort(constantValue.getShort()); + break; case Types.INTEGER: - doubleValue = Math.floor(doubleValue); - if (doubleValue < Integer.MIN_VALUE || - doubleValue > Integer.MAX_VALUE) - { - throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "INTEGER"); - } - return (ValueNode) getNodeFactory().getNode( - C_NodeTypes.INT_CONSTANT_NODE, - ReuseFactory.getInteger( - (int) doubleValue), - getContextManager()); + nodeType = C_NodeTypes.INT_CONSTANT_NODE; + constantObject = ReuseFactory.getInteger(constantValue.getInt()); + break; case Types.BIGINT: - doubleValue = Math.floor(doubleValue); - if (doubleValue < Long.MIN_VALUE || - doubleValue > Long.MAX_VALUE) - { - throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "BIGINT"); - } - return (ValueNode) getNodeFactory().getNode( - C_NodeTypes.LONGINT_CONSTANT_NODE, - ReuseFactory.getLong((long) doubleValue), - getContextManager()); + nodeType = C_NodeTypes.LONGINT_CONSTANT_NODE; + constantObject = ReuseFactory.getLong(constantValue.getLong()); + break; case Types.REAL: -// System.out.println("cast to real!"); -// if (Math.abs(doubleValue) > Float.MAX_VALUE) -// throw... -// SQLReal.check(doubleValue); -// jsk: rounding problem??? - return (ValueNode) getNodeFactory().getNode( - C_NodeTypes.FLOAT_CONSTANT_NODE, - new Float(NumberDataType.normalizeREAL(doubleValue)), - getContextManager()); + nodeType = C_NodeTypes.FLOAT_CONSTANT_NODE; + constantObject = new Float(NumberDataType.normalizeREAL(constantValue.getDouble())); + break; case Types.DOUBLE: - return (ValueNode) getNodeFactory().getNode( - C_NodeTypes.DOUBLE_CONSTANT_NODE, - new Double(doubleValue), - getContextManager()); + // no need to normalize here because no constant could be out of range for a double + nodeType = C_NodeTypes.DOUBLE_CONSTANT_NODE; + constantObject = new Double(constantValue.getDouble()); + break; } - return retNode; + if (nodeType == -1) + return this; + + + return (ValueNode) getNodeFactory().getNode( + nodeType, + constantObject, + getContextManager()); + } /** Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java Thu Jan 6 13:45:32 2005 @@ -995,7 +995,7 @@ TypeId ctid = mapToTypeID( jsqlType ); - if (ctid.isNumericTypeId() || ctid.isBooleanTypeId()) + if ((ctid.isNumericTypeId() && !ctid.isDecimalTypeId()) || ctid.isBooleanTypeId()) { TypeCompiler tc = getTypeCompiler(ctid); primParmTypeNames[i] = tc.getCorrespondingPrimitiveTypeName(); Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java Thu Jan 6 13:45:32 2005 @@ -32,13 +32,13 @@ import org.apache.derby.iapi.types.TypeId; import org.apache.derby.iapi.types.DataTypeUtilities; +import org.apache.derby.iapi.types.NumberDataValue; import org.apache.derby.impl.sql.compile.ExpressionClassBuilder; import org.apache.derby.iapi.util.ReuseFactory; import java.sql.Types; -import java.math.BigDecimal; public final class NumericConstantNode extends ConstantNode { @@ -61,7 +61,6 @@ boolean valueInP; // value in Predicate-- if TRUE a value was passed in TypeId typeId = null; int typeid = 0; - Object val = null; if (arg1 instanceof TypeId) { @@ -74,7 +73,6 @@ else { isNullable = Boolean.FALSE; - val = arg1; valueInP = true; } @@ -88,8 +86,7 @@ { maxwidth = TypeId.SMALLINT_MAXWIDTH; typeid = Types.TINYINT; - setValue(getDataValueFactory().getDataValue( - ((Byte)val).byteValue())); + setValue(getDataValueFactory().getDataValue((Byte) arg1)); } break; @@ -100,9 +97,7 @@ { maxwidth = TypeId.INT_MAXWIDTH; typeid = Types.INTEGER; - setValue( - getDataValueFactory().getDataValue( - ((Integer) val).intValue())); + setValue(getDataValueFactory().getDataValue((Integer) arg1)); } break; @@ -113,9 +108,7 @@ { maxwidth = TypeId.SMALLINT_MAXWIDTH; typeid = Types.SMALLINT; - setValue( - getDataValueFactory().getDataValue( - ((Short) val).shortValue())); + setValue(getDataValueFactory().getDataValue((Short) arg1)); } break; @@ -126,23 +119,24 @@ { maxwidth = TypeId.LONGINT_MAXWIDTH; typeid = Types.BIGINT; - setValue(getDataValueFactory().getDataValue(((Long) arg1).longValue())); + setValue(getDataValueFactory().getDataValue((Long) arg1)); } break; case C_NodeTypes.DECIMAL_CONSTANT_NODE: if (valueInP) { - BigDecimal dVal = (BigDecimal)val; + + NumberDataValue constantDecimal = getDataValueFactory().getDecimalDataValue((String) arg1); typeid = Types.DECIMAL; - precision = org.apache.derby.iapi.types.SQLDecimal.getPrecision(dVal); - scal = (dVal == null) ? 0 : dVal.scale(); + precision = constantDecimal.getDecimalValuePrecision(); + scal = constantDecimal.getDecimalValueScale(); /* be consistent with our convention on maxwidth, see also * exactNumericType(), otherwise we get format problem, b 3923 */ - maxwidth = DataTypeUtilities.computeMaxWidth( precision, scal); - setValue(getDataValueFactory().getDataValue(dVal)); + maxwidth = DataTypeUtilities.computeMaxWidth(precision, scal); + setValue(constantDecimal); } else { @@ -159,8 +153,7 @@ { maxwidth = TypeId.DOUBLE_MAXWIDTH; typeid = Types.DOUBLE; - setValue(getDataValueFactory().getDataValue( - ((Double) arg1).doubleValue())); + setValue(getDataValueFactory().getDataValue((Double) arg1)); } break; @@ -172,8 +165,7 @@ maxwidth = TypeId.REAL_MAXWIDTH; typeid = Types.REAL; setValue( - getDataValueFactory().getDataValue( - ((Float) arg1).floatValue())); + getDataValueFactory().getDataValue((Float) arg1)); } break; @@ -197,24 +189,6 @@ isNullable, ReuseFactory.getInteger(maxwidth)); } - - long getLong() throws StandardException - { - return value.getLong(); - } - - /** - * Return the value from this DoubleConstantNode - * - * @return The value of this DoubleConstantNode. - * - * @exception StandardException Thrown on error - */ - - double getDouble() throws StandardException - { - return value.getDouble(); - } /** * Return an Object representing the bind time value of this @@ -265,13 +239,13 @@ mb.pushNewComplete(1); break; case C_NodeTypes.DOUBLE_CONSTANT_NODE: - mb.push(getDouble()); + mb.push(value.getDouble()); break; case C_NodeTypes.FLOAT_CONSTANT_NODE: mb.push(value.getFloat()); break; case C_NodeTypes.LONGINT_CONSTANT_NODE: - mb.push(getLong()); + mb.push(value.getLong()); break; default: if (SanityManager.DEBUG) Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java Thu Jan 6 13:45:32 2005 @@ -68,9 +68,6 @@ int formatId = getStoredFormatIdFromTypeId(); switch (formatId) { - case StoredFormatIds.DECIMAL_TYPE_ID: - return "double"; - case StoredFormatIds.DOUBLE_TYPE_ID: return "double"; @@ -89,6 +86,7 @@ case StoredFormatIds.TINYINT_TYPE_ID: return "byte"; + case StoredFormatIds.DECIMAL_TYPE_ID: default: if (SanityManager.DEBUG) { @@ -111,9 +109,6 @@ int formatId = getStoredFormatIdFromTypeId(); switch (formatId) { - case StoredFormatIds.DECIMAL_TYPE_ID: - return "getDouble"; - case StoredFormatIds.DOUBLE_TYPE_ID: return "getDouble"; @@ -132,6 +127,7 @@ case StoredFormatIds.TINYINT_TYPE_ID: return "getByte"; + case StoredFormatIds.DECIMAL_TYPE_ID: default: if (SanityManager.DEBUG) { Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Thu Jan 6 13:45:32 2005 @@ -148,8 +148,6 @@ import java.sql.Types; import java.util.Properties; import java.util.Vector; -import java.util.Enumeration; -import java.math.BigDecimal; import java.lang.Character; public class SQLParser @@ -561,18 +559,14 @@ */ ValueNode getNumericNode(String num) throws StandardException { - BigDecimal bigDecimalValue = null; - Integer intValue; - Long longValue; ContextManager cm = getContextManager(); // first, see if it might be an integer try { - intValue = new Integer(num); return (ValueNode) nodeFactory.getNode( C_NodeTypes.INT_CONSTANT_NODE, - intValue, + new Integer(num), cm); } catch (NumberFormatException nfe) @@ -583,10 +577,9 @@ // next, see if it might be a long try { - longValue = new Long(num); return (ValueNode) nodeFactory.getNode( C_NodeTypes.LONGINT_CONSTANT_NODE, - longValue, + new Long(num), cm); } catch (NumberFormatException nfe) @@ -594,23 +587,9 @@ // we catch because we want to continue on below } - // check whether we can convert to a BigDecimal - try - { - bigDecimalValue = new BigDecimal(num); - } - catch (NumberFormatException nfe) - { - if (SanityManager.DEBUG) - { - SanityManager.THROWASSERT( - "String \"" + num + "\" cannot be converted to a BigDecimal: " + nfe); - } - } - return (ValueNode) nodeFactory.getNode( C_NodeTypes.DECIMAL_CONSTANT_NODE, - bigDecimalValue, + num, cm); } /** Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java&r1=124454&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java (original) +++ incubator/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/InsertResultSet.java Thu Jan 6 13:45:32 2005 @@ -98,7 +98,6 @@ import java.util.Hashtable; import java.util.Properties; import java.util.Vector; -//import java.math.BigDecimal; /** * Insert the rows from the source into the specified Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out?view=diff&rev=124455&p1=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out&r1=124454&p2=incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out&r2=124455 ============================================================================== --- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out (original) +++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/cast.out Thu Jan 6 13:45:32 2005 @@ -1426,7 +1426,7 @@ ij> values cast('99999' as smallint); ERROR 22003: The resulting value is outside the range for the data type SHORT. ij> values cast(99999 as smallint); -ERROR 22003: The resulting value is outside the range for the data type SHORT. +ERROR 22003: The resulting value is outside the range for the data type SMALLINT. ij> values cast(cast(99 as int) as char); ERROR 22001: A truncation error was encountered trying to shrink CHAR '99' to length 1. ij> values cast(cast(-9 as int) as char);