public Type getAggregateType(Type other) throws HsqlException { if (this == other) { return this; } if (other.isCharacterType()) { return other.getAggregateType(this); } switch (other.typeCode) { case Types.SQL_ALL_TYPES: return this; case Types.SQL_REAL: case Types.SQL_FLOAT: case Types.SQL_DOUBLE: case Types.SQL_NUMERIC: case Types.SQL_DECIMAL: case Types.TINYINT: case Types.SQL_SMALLINT: case Types.SQL_INTEGER: case Types.SQL_BIGINT: break; default: throw Error.error(ErrorCode.X_42562); } if (typeWidth == DOUBLE_WIDTH) { return this; } if (((NumberType) other).typeWidth == DOUBLE_WIDTH) { return other; } if (typeWidth <= BIGINT_WIDTH && ((NumberType) other).typeWidth <= BIGINT_WIDTH) { return (typeWidth > ((NumberType) other).typeWidth) ? this : other; } int newScale = scale > other.scale ? scale : other.scale; long newDigits = precision - scale > other.precision - other.scale ? precision - scale : other.precision - other.scale; return getNumberType(Types.SQL_DECIMAL, newDigits + newScale, newScale); }
public boolean canConvertFrom(Type otherType) { if (otherType.typeCode == Types.SQL_ALL_TYPES) { return true; } if (otherType.isNumberType()) { return true; } if (otherType.isIntervalType()) { return true; } if (otherType.isCharacterType()) { return true; } return false; }