You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ma...@apache.org on 2007/04/20 22:38:39 UTC
svn commit: r530910 - in /db/derby/code/trunk/java/engine/org/apache/derby:
catalog/types/ iapi/sql/compile/ iapi/types/ impl/sql/compile/
Author: mamta
Date: Fri Apr 20 13:38:37 2007
New Revision: 530910
URL: http://svn.apache.org/viewvc?view=rev&rev=530910
Log:
DERBY-2569 Basically, this commit moves the logic for comparable method from various TypeCompiler implementations into DTD. This is because
now we need collation information also to determine if 2 types are comparable or not and that information is not available to TypeCompilers.
In addition, ofcourse, all the callers of TypeCompiler's comparable method now call DTD.comparable.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java Fri Apr 20 13:38:37 2007
@@ -57,7 +57,7 @@
/** @see TypeDescriptor#getCollationType() */
private int collationType;
/** @see TypeDescriptor#getCollationDerivation() */
- private int collationDerivation = StringDataValue.COLLATION_DERIVATION_NONE;
+ private int collationDerivation = StringDataValue.COLLATION_DERIVATION_IMPLICIT;
/**
* Public niladic constructor. Needed for Formatable interface to work.
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -96,24 +96,6 @@
throws StandardException;
/**
- * Determine if this type can be compared to some other type
- *
- * @param otherType The CompilationType of the other type to compare
- * this type to
- * @param forEquals True if this is an = or <> comparison, false otherwise.
- * @param cf A ClassFactory
- *
- * @return true if the types can be compared, false if comparisons between
- * the types are not allowed
- */
-
- boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf);
-
-
-
- /**
* Determine if this type can be CONVERTed to some other type
*
* @param otherType The CompilationType of the other type to compare
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java Fri Apr 20 13:38:37 2007
@@ -42,6 +42,7 @@
import org.apache.derby.iapi.services.loader.ClassInspector;
+import org.apache.derby.iapi.reference.JDBC30Translation;
import org.apache.derby.iapi.reference.SQLState;
import java.io.ObjectOutput;
@@ -833,6 +834,158 @@
return typeDescriptor.equals(aTypeDescriptor);
}
+ /**
+ * Check if this type is comparable with the passed type.
+ *
+ * @param compareWithDTD the type of the instance to compare with this type.
+ * @param forEquals True if this is an = or <> comparison, false
+ * otherwise.
+ * @param cf A ClassFactory
+ * @return true if compareWithDTD is comparable to this type, else false.
+ */
+ public boolean comparable(DataTypeDescriptor compareWithDTD,
+ boolean forEquals,
+ ClassFactory cf){
+
+ TypeId compareWithTypeID = compareWithDTD.getTypeId();
+ int compareWithJDBCTypeId = compareWithTypeID.getJDBCTypeId();
+
+ // Long types cannot be compared
+ if (compareWithTypeID.isLongConcatableTypeId() || typeId.isLongConcatableTypeId())
+ return false;
+
+ // Ref types cannot be compared
+ if (typeId.isRefTypeId() || compareWithTypeID.isRefTypeId())
+ return false;
+
+ //If this DTD is not user defined type but the DTD to be compared with
+ //is user defined type, then let the other DTD decide what should be the
+ //outcome of the comparable method.
+ if (!(typeId.isUserDefinedTypeId()) &&
+ (compareWithTypeID.isUserDefinedTypeId()))
+ return compareWithDTD.comparable(this, forEquals, cf);
+
+ switch (typeId.getJDBCTypeId())
+ {
+ case Types.DECIMAL:
+ case Types.BIGINT:
+ case Types.DOUBLE:
+ case Types.INTEGER:
+ case Types.NUMERIC:
+ case Types.REAL:
+ case Types.SMALLINT:
+ case Types.TINYINT:
+ // Numeric types are comparable to numeric types, boolean
+ //types and to comparable user types
+ return (compareWithTypeID.isNumericTypeId() ||
+ compareWithTypeID.isBooleanTypeId());
+
+ case Types.CHAR:
+ case Types.LONGVARCHAR:
+ case Types.VARCHAR:
+ // CHAR and VARCHAR are comparable to strings, boolean,
+ // DATE/TIME/TIMESTAMP and to comparable user types
+ if((compareWithTypeID.isDateTimeTimeStampTypeID() ||
+ compareWithTypeID.isBooleanTypeId()))
+ return true;
+ //If both the types are string types, then we need to make
+ //sure they have the same collation set on them
+ if (compareWithTypeID.isStringTypeId() && typeId.isStringTypeId()) {
+ if (getCollationDerivation() == compareWithDTD.getCollationDerivation() &&
+ getCollationType() == compareWithDTD.getCollationType())
+ return true;
+ else
+ return false;
+ } else
+ return false;
+
+
+ case Types.BIT:
+ case JDBC30Translation.SQL_TYPES_BOOLEAN:
+ /* Are comparable to Boolean, string, numeric and to
+ * comparable user types */
+ return (compareWithTypeID.getSQLTypeName().equals(typeId.getSQLTypeName()) ||
+ compareWithTypeID.isStringTypeId() ||
+ compareWithTypeID.isNumericTypeId());
+
+ case Types.DATE:
+ /*
+ * Dates are comparable to dates, strings and to comparable
+ * user types.
+ */
+ if (compareWithJDBCTypeId == Types.DATE ||
+ compareWithTypeID.isStringTypeId())
+ return true;
+ else
+ return false;
+
+ case Types.TIME:
+ /*
+ * Times are comparable to times, strings and to comparable
+ * user types.
+ */
+ if (compareWithJDBCTypeId == Types.TIME ||
+ compareWithTypeID.isStringTypeId())
+ return true;
+ else
+ return false;
+
+ case Types.TIMESTAMP:
+ /*
+ * Timestamps are comparable to timestamps, strings and to
+ * comparable user types.
+ */
+ if (compareWithJDBCTypeId == Types.TIMESTAMP ||
+ compareWithTypeID.isStringTypeId())
+ return true;
+ else
+ return false;
+
+ case Types.BINARY:
+ case Types.LONGVARBINARY:
+ case Types.VARBINARY:
+ //Are comparable to other bit types and comparable user types
+ return (compareWithTypeID.isBitTypeId());
+
+ case org.apache.derby.iapi.reference.JDBC20Translation.SQL_TYPES_JAVA_OBJECT:
+ case Types.OTHER:
+ /*
+ * User types are comparable to other user types only if
+ * (for now) they are the same type and are being used to
+ * implement some JDBC type. This is sufficient for
+ * date/time types; it may be generalized later for e.g.
+ * comparison of any user type with one of its subtypes.
+ */
+ if (forEquals)
+ return true;
+ try {
+
+ Class thisClass = cf.getClassInspector().getClass(
+ typeId.getCorrespondingJavaTypeName());
+
+ return java.lang.Comparable.class.isAssignableFrom(thisClass);
+ } catch (ClassNotFoundException cnfe) {
+ return false;
+ }
+
+ case StoredFormatIds.XML_TYPE_ID:
+ /*
+ * Tell whether this type (XML) can be compared to the given type.
+ * Says SQL/XML[2003] spec:
+ *
+ * 4.2.2 XML comparison and assignment
+ * "XML values are not comparable."
+ *
+ * An XML value cannot be compared to any type--
+ * not even to other XML values.
+ */
+ return false;
+ }
+
+ return false;
+ }
+
+
/**
* Converts this data type descriptor (including length/precision)
* to a string. E.g.
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -183,29 +183,6 @@
return false;
}
-
- /**
- * Tell whether this numeric type can be compared to the given type.
- *
- * @param otherType The TypeId of the other type.
- */
-
- public boolean numberComparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
- TypeCompiler otherTC = getTypeCompiler(otherType);
-
- /* Numbers can be compared to other numbers,
- * boolean and objects
- */
- return otherType.isNumericTypeId() ||
- otherType.isBooleanTypeId() ||
- (otherType.userType() && otherTC.comparable(otherType,
- forEquals,
- cf));
- }
-
/**
* Tell whether this numeric type can be converted to the given type.
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryComparisonOperatorNode.java Fri Apr 20 13:38:37 2007
@@ -240,9 +240,10 @@
*/
boolean forEquals = operator.equals("=") || operator.equals("<>");
- boolean cmp = leftOperand.getTypeCompiler().comparable(rightType,
- forEquals,
- getClassFactory());
+ boolean cmp = leftOperand.getTypeServices().comparable(
+ rightOperand.getTypeServices(),
+ forEquals,
+ getClassFactory());
// Bypass the comparable check if this is a rewrite from the
// optimizer. We will assume Mr. Optimizer knows what he is doing.
if (!cmp && !forQueryRewrite) {
@@ -431,8 +432,8 @@
*/
if (leftTypeId.userType())
{
- if (leftOperand.getTypeCompiler().comparable(leftTypeId, false,
- getClassFactory()))
+ if (leftOperand.getTypeServices().comparable(leftOperand.getTypeServices(),
+ false, getClassFactory()))
return this;
leftOperand = leftOperand.genSQLJavaSQLTree();
@@ -442,8 +443,8 @@
if (rightTypeId.userType())
{
- if (rightOperand.getTypeCompiler().comparable(rightTypeId, false,
- getClassFactory()))
+ if (rightOperand.getTypeServices().comparable(rightOperand.getTypeServices(),
+ false, getClassFactory()))
return this;
rightOperand = rightOperand.genSQLJavaSQLTree();
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -50,29 +50,6 @@
public class BitTypeCompiler extends BaseTypeCompiler
{
/**
- * Tell whether this type (bit) can be compared to the given type. //
- *
- * Bit Types can only be compared to Bit Types.
- * Long Bit Types can not be compared
- * @param otherType The TypeId of the other type.
- */
-
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
-
- if (getTypeId().isLongConcatableTypeId() ||
- otherType.isLongConcatableTypeId())
- return false;
-
- TypeCompiler otherTC = getTypeCompiler(otherType);
- return (otherType.isBitTypeId() ||
- (otherType.userType() &&
- otherTC.comparable(getTypeId(), forEquals, cf)));
- }
-
- /**
* Tell whether this type (bit) can be converted to the given type.
*
* @see TypeCompiler#convertible
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BooleanTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -46,27 +46,6 @@
public class BooleanTypeCompiler extends BaseTypeCompiler
{
/**
- * Tell whether this type (boolean) can be compared to the given type.
- *
- * @param otherType The TypeId of the other type.
- */
-
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
- TypeId thisTypeId = getTypeId();
- TypeCompiler otherTypeCompiler = getTypeCompiler(otherType);
-
- /* Only allow comparison of Boolean with Boolean or string types */
- return otherType.getSQLTypeName().equals(thisTypeId.getSQLTypeName()) ||
- otherType.isStringTypeId() ||
- otherType.isNumericTypeId() ||
- (otherType.userType() &&
- otherTypeCompiler.comparable(thisTypeId, forEquals, cf));
- }
-
- /**
* Tell whether this type (boolean) can be converted to the given type.
*
* @see TypeCompiler#convertible
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -51,21 +51,6 @@
public class CLOBTypeCompiler extends BaseTypeCompiler
{
/**
- * Tell whether this type (LOB) can be compared to the given type.
- * Clobs are not comparable.
- *
- * @param otherType The TypeId of the other type.
- */
-
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
- return false;
- }
-
-
- /**
* Tell whether this type (LOB) can be converted to the given type.
*
* @see TypeCompiler#convertible
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -51,38 +51,6 @@
public final class CharTypeCompiler extends BaseTypeCompiler
{
- /**
- * Tell whether this type (char) can be compared to the given type.
- * Long types can not be compared.
- * VARCHAR AND CHAR can be compared to CHAR/VARCHAR/DATE/TIME/TIMESTAMP
- *
- *
- * @param otherType The TypeId of the other type.
- */
-
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
-
- // Long Types cannot be compared
- if (getTypeId().isLongConcatableTypeId() ||
- otherType.isLongConcatableTypeId())
- return false;
-
- // CHAR and VARCHAR can compare to Strings or DATE/TIME/TIMESTAMP
- if((otherType.isStringTypeId() ||
- otherType.isDateTimeTimeStampTypeID() ||
- otherType.isBooleanTypeId()))
- return true;
-
-
- TypeCompiler otherTC = getTypeCompiler(otherType);
- return (otherType.userType() && otherTC.comparable(getTypeId(),
- forEquals, cf));
- }
-
-
/**
* Tell whether this type (char) can be converted to the given type.
*
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java Fri Apr 20 13:38:37 2007
@@ -457,8 +457,8 @@
// RESOLVE DJDOI - this looks wrong, why should the then expression
// be comparable to the then expression ??
- if (! thenExpression.getTypeCompiler().
- comparable(elseExpression.getTypeId(), false, getClassFactory()) &&
+ if (! thenExpression.getTypeServices().
+ comparable(elseExpression.getTypeServices(), false, getClassFactory()) &&
! cu.assignableTo(thenExpression.getTypeId().getCorrespondingJavaTypeName(),
elseExpression.getTypeId().getCorrespondingJavaTypeName()) &&
! cu.assignableTo(elseExpression.getTypeId().getCorrespondingJavaTypeName(),
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DateTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -41,40 +41,6 @@
public class DateTypeCompiler extends BaseTypeCompiler
{
/* TypeCompiler methods */
-
- /**
- * Dates are comparable to timestamps and to comparable
- * user types.
- *
- * @param otherType the type of the instance to compare with this type.
- * @param forEquals True if this is an = or <> comparison, false
- * otherwise.
- * @param cf A ClassFactory
- * @return true if otherType is comparable to this type, else false.
- */
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
- int otherJDBCTypeId = otherType.getJDBCTypeId();
- TypeCompiler otherTC = getTypeCompiler(otherType);
-
- // Long types cannot be compared
- if (otherType.isLongConcatableTypeId())
- return false;
-
- if (otherJDBCTypeId == Types.DATE || otherType.isStringTypeId())
- return true;
-
- /* User types know the rules for what can be compared to them */
- if (otherType.userType())
- {
- return otherTC.comparable(getTypeId(), forEquals, cf);
- }
-
- return false;
- }
-
/**
* User types are convertible to other user types only if
* (for now) they are the same type and are being used to
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LOBTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -49,22 +49,6 @@
public class LOBTypeCompiler extends BaseTypeCompiler
{
- /**
- * Tell whether this type (BLOB) can be compared to the given type. //
- * BLOBS are not comparable.
- *
- * @param otherType The TypeId of the other type.
- */
-
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
- return false;
- }
-
-
-
/**
* Tell whether this type (LOB) can be converted to the given type.
*
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -304,14 +304,6 @@
maximumWidth
);
}
- /** @see TypeCompiler#comparable */
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
- return numberComparable(otherType, forEquals, cf);
- }
-
/** @see TypeCompiler#convertible */
public boolean convertible(TypeId otherType, boolean forDataTypeFunction)
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RefTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -79,15 +79,6 @@
return convertible(otherType,false);
}
-
- /** @see TypeCompiler#comparable */
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
- return false;
- }
-
/** @see TypeCompiler#storable */
public boolean storable(TypeId otherType, ClassFactory cf)
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimeTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -41,41 +41,6 @@
public class TimeTypeCompiler extends BaseTypeCompiler
{
/* TypeCompiler methods */
-
- /**
- * Dates are comparable to timestamps and to comparable
- * user types.
- *
- * @param otherType the type of the instance to compare with this type.
- * @param forEquals True if this is an = or <> comparison, false
- * otherwise.
- * @param cf A ClassFactory
- * @return true if otherType is comparable to this type, else false.
- */
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
- int otherJDBCTypeId = otherType.getJDBCTypeId();
-
- // Long types cannot be compared
- if (otherType.isLongConcatableTypeId())
- return false;
-
- if (otherJDBCTypeId == Types.TIME || otherType.isStringTypeId())
- return true;
-
- TypeCompiler otherTC = getTypeCompiler(otherType);
-
- /* User types know the rules for what can be compared to them */
- if (otherType.userType())
- {
- return otherTC.comparable(getTypeId(), forEquals, cf);
- }
-
- return false;
- }
-
/**
* User types are convertible to other user types only if
* (for now) they are the same type and are being used to
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -39,50 +39,7 @@
public class TimestampTypeCompiler extends BaseTypeCompiler
{
- /* TypeCompiler methods */
-
- /**
- * Timestamps are comparable to timestamps and to comparable
- * user types.
- *
- * @param otherType the type of the instance to compare with this type.
- * @param forEquals True if this is an = or <> comparison, false
- * otherwise.
- * @param cf A ClassFactory
- * @return true if otherType is comparable to this type, else false.
- */
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
- return comparable(getTypeId(), otherType, forEquals, cf);
- }
-
- boolean comparable(TypeId leftType,
- TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
-
- int otherJDBCTypeId = otherType.getJDBCTypeId();
-
- // Long types cannot be compared
- if (otherType.isLongConcatableTypeId())
- return false;
-
- TypeCompiler otherTC = getTypeCompiler(otherType);
- if (otherJDBCTypeId == Types.TIMESTAMP || otherType.isStringTypeId())
- return true;
-
- /* User types know the rules for what can be compared to them */
- if (otherType.userType())
- {
- return otherTC.comparable(getTypeId(), forEquals, cf);
- }
-
- return false;
- }
-
+ /* TypeCompiler methods */
/**
* User types are convertible to other user types only if
* (for now) they are the same type and are being used to
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -42,37 +42,6 @@
/* TypeCompiler methods */
/**
- * User types are comparable to other user types only if
- * (for now) they are the same type and are being used to
- * implement some JDBC type. This is sufficient for
- * date/time types; it may be generalized later for e.g.
- * comparison of any user type with one of its subtypes.
- *
- * @param otherType the type of the instance to compare with this type.
- * @param forEquals True if this is an = or <> comparison, false
- * otherwise.
- * @param cf A ClassFactory
- * @return true if otherType is comparable to this type, else false.
- */
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cf)
- {
- if (forEquals)
- return true;
-
- try {
- Class thisClass = cf.getClassInspector().getClass(
- getTypeId().getCorrespondingJavaTypeName());
-
- return java.lang.Comparable.class.isAssignableFrom(thisClass);
-
- } catch (ClassNotFoundException cnfe) {
- return false;
- }
- }
-
- /**
* User types are convertible to other user types only if
* (for now) they are the same type and are being used to
* implement some JDBC type. This is sufficient for
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java Fri Apr 20 13:38:37 2007
@@ -291,10 +291,8 @@
int size = size();
TypeId leftType;
ValueNode valueNode;
- TypeCompiler leftTC;
leftType = leftOperand.getTypeId();
- leftTC = leftOperand.getTypeCompiler();
for (int index = 0; index < size; index++)
{
@@ -304,7 +302,7 @@
** Can the types be compared to each other? If not, throw an
** exception.
*/
- if (! leftTC.comparable(valueNode.getTypeId(),
+ if (! leftOperand.getTypeServices().comparable(valueNode.getTypeServices(),
false,
getClassFactory()))
{
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java?view=diff&rev=530910&r1=530909&r2=530910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLTypeCompiler.java Fri Apr 20 13:38:37 2007
@@ -40,24 +40,6 @@
public class XMLTypeCompiler extends BaseTypeCompiler
{
/**
- * Tell whether this type (XML) can be compared to the given type.
- * Says SQL/XML[2003] spec:
- *
- * 4.2.2 XML comparison and assignment
- * "XML values are not comparable."
- *
- * @param otherType The TypeId of the other type.
- */
- public boolean comparable(TypeId otherType,
- boolean forEquals,
- ClassFactory cs)
- {
- // An XML value cannot be compared to any type--
- // not even to other XML values.
- return false;
- }
-
- /**
* Tell whether this type (XML) can be converted to the given type.
*
* An XML value can't be converted to any other type, per