Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 8431 invoked from network); 31 Aug 2007 20:38:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Aug 2007 20:38:23 -0000 Received: (qmail 8103 invoked by uid 500); 31 Aug 2007 20:38:19 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 8068 invoked by uid 500); 31 Aug 2007 20:38:18 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 8057 invoked by uid 99); 31 Aug 2007 20:38:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Aug 2007 13:38:18 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Aug 2007 20:38:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AFAF01A9832; Fri, 31 Aug 2007 13:38:01 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r571567 - in /db/derby/code/trunk/java/engine/org/apache/derby: catalog/TypeDescriptor.java catalog/types/TypeDescriptorImpl.java iapi/types/DataTypeDescriptor.java Date: Fri, 31 Aug 2007 20:38:01 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070831203801.AFAF01A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djd Date: Fri Aug 31 13:38:00 2007 New Revision: 571567 URL: http://svn.apache.org/viewvc?rev=571567&view=rev Log: DERBY-2917 (partial) Move collation derivation to DataTypeDescriptor from TypeDescriptor as it is only a runtime attribute. Derivation has no meaning within a catalog type. Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java?rev=571567&r1=571566&r2=571567&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java Fri Aug 31 13:38:00 2007 @@ -180,54 +180,6 @@ public int getCollationType(); /** - * Get the collation derivation for this type. This applies only for - * character string types. For the other types, this api should be - * ignored. - * - * SQL spec talks about character string types having collation type and - * collation derivation associated with them (SQL spec Section 4.2.2 - * Comparison of character strings). If collation derivation says explicit - * or implicit, then it means that there is a valid collation type - * associated with the charcter string type. If the collation derivation is - * none, then it means that collation type can't be established for the - * character string type. - * - * 1)Collation derivation will be explicit if SQL COLLATE clause has been - * used for character string type (this is not a possibility for Derby 10.3 - * because we are not planning to support SQL COLLATE clause in the 10.3 - * release). - * - * 2)Collation derivation will be implicit if the collation can be - * determined w/o the COLLATE clause eg CREATE TABLE t1(c11 char(4)) then - * c11 will have collation of USER character set. Another eg, TRIM(c11) - * then the result character string of TRIM operation will have collation - * of the operand, c11. - * - * 3)Collation derivation will be none if the aggregate methods are dealing - * with character strings with different collations (Section 9.3 Data types - * of results of aggregations Syntax Rule 3aii). - * - * Collation derivation will be initialized to COLLATION_DERIVATION_NONE. - * - * @return Should be COLLATION_DERIVATION_NONE or COLLATION_DERIVATION_IMPLICIT - * - * @see StringDataValue#COLLATION_DERIVATION_NONE - * @see StringDataValue#COLLATION_DERIVATION_IMPLICIT - * @see StringDataValue#COLLATION_DERIVATION_EXPLICIT - */ - public int getCollationDerivation(); - - /** - * Gets the name of the collation type in this descriptor. - *

- * Used to generate strings decribing collation type for error messages. - * - * - * @return the name of the collation being used in this type. - */ - public String getCollationName(); - - /** * Return true if this is a Row Multiset type */ public boolean isRowMultiSet(); 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?rev=571567&r1=571566&r2=571567&view=diff ============================================================================== --- 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 Aug 31 13:38:00 2007 @@ -58,8 +58,6 @@ private int maximumWidth; /** @see TypeDescriptor#getCollationType() */ private int collationType = StringDataValue.COLLATION_TYPE_UCS_BASIC; - /** @see TypeDescriptor#getCollationDerivation() */ - private int collationDerivation = StringDataValue.COLLATION_DERIVATION_IMPLICIT; /** * Public niladic constructor. Needed for Formatable interface to work. @@ -116,8 +114,7 @@ int scale, boolean isNullable, int maximumWidth, - int collationType, - int collationDerivation) + int collationType) { this.typeId = typeId; this.precision = precision; @@ -125,7 +122,6 @@ this.isNullable = isNullable; this.maximumWidth = maximumWidth; this.collationType = collationType; - this.collationDerivation = collationDerivation; } /** @@ -178,8 +174,7 @@ int scale, boolean isNullable, int maximumWidth, - int collationType, - int collationDerivation) + int collationType) { this.typeId = source.typeId; this.precision = precision; @@ -187,7 +182,6 @@ this.isNullable = isNullable; this.maximumWidth = maximumWidth; this.collationType = collationType; - this.collationDerivation = collationDerivation; } @@ -411,39 +405,6 @@ collationType = collationTypeValue; } - /** @see TypeDescriptor#getCollationDerivation() */ - public int getCollationDerivation() - { - return collationDerivation; - } - - /** @see DataTypeDescriptor#setCollationDerivation(int) */ - public void setCollationDerivation(int collationDerivationValue) - { - collationDerivation = collationDerivationValue; - } - - /** - * Gets the name of the collation type in this descriptor if the collation - * derivation is not NONE. If the collation derivation is NONE, then this - * method will return "NONE". - *

- * This method is used for generating error messages which will use correct - * string describing collation type/derivation. - * - * - * @return the name of the collation being used in this type. - */ - public String getCollationName() - { - return( - collationDerivation == StringDataValue.COLLATION_DERIVATION_NONE ? - Property.COLLATION_NONE : - collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC ? - Property.UCS_BASIC_COLLATION : - Property.TERRITORY_BASED_COLLATION); - } - /** * Converts this data type descriptor (including length/precision) * to a string. E.g. @@ -501,8 +462,7 @@ case Types.CLOB: //if we are dealing with character types, then we should //also compare the collation information on them. - if(this.collationDerivation != typeDescriptor.getCollationDerivation() || - this.collationType != typeDescriptor.getCollationType()) + if(this.collationType != typeDescriptor.getCollationType()) return false; else return true; @@ -547,17 +507,10 @@ case Types.CLOB: scale = 0; collationType = in.readInt(); - //I am assuming that the readExternal gets called only on - //persistent columns. Since all persistent character string type - //columns always have the collation derivation of implicit, I will - //simply use that value for collation derivation here for character - //string type columns. - collationDerivation = StringDataValue.COLLATION_DERIVATION_IMPLICIT; break; default: scale = in.readInt(); collationType = 0; - collationDerivation = StringDataValue.COLLATION_DERIVATION_IMPLICIT; break; } 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?rev=571567&r1=571566&r2=571567&view=diff ============================================================================== --- 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 Aug 31 13:38:00 2007 @@ -32,6 +32,7 @@ import org.apache.derby.catalog.types.RowMultiSetImpl; import org.apache.derby.catalog.types.TypeDescriptorImpl; import org.apache.derby.iapi.error.StandardException; +import org.apache.derby.iapi.reference.Property; import org.apache.derby.iapi.reference.SQLState; import org.apache.derby.iapi.services.io.Formatable; import org.apache.derby.iapi.services.io.StoredFormatIds; @@ -42,6 +43,12 @@ /** * DataTypeDescriptor describes a runtime SQL type. + * It consists of a catalog type (TypeDescriptor) + * and runtime attributes. The list of runtime + * attributes is: + *

    + *
  • Collation Derivation + *
*/ public final class DataTypeDescriptor implements TypeDescriptor, Formatable @@ -311,6 +318,10 @@ private TypeDescriptorImpl typeDescriptor; private TypeId typeId; + + /** @see TypeDescriptor#getCollationDerivation() */ + private int collationDerivation = StringDataValue.COLLATION_DERIVATION_IMPLICIT; + /** * Public niladic constructor. Needed for Formatable interface to work. @@ -368,8 +379,8 @@ scale, isNullable, maximumWidth, - collationType, - collationDerivation); + collationType); + this.collationDerivation = collationDerivation; } /** @@ -413,8 +424,9 @@ source.getScale(), isNullable, source.getMaximumWidth(), - source.getCollationType(), - source.getCollationDerivation()); + source.getCollationType() + ); + this.collationDerivation = source.getCollationDerivation(); } /** @@ -441,8 +453,9 @@ scale, isNullable, maximumWidth, - source.getCollationType(), - source.getCollationDerivation()); + source.getCollationType() + ); + this.collationDerivation = source.getCollationDerivation(); } /** @@ -462,8 +475,9 @@ source.getScale(), isNullable, maximumWidth, - source.getCollationType(), - source.getCollationDerivation()); + source.getCollationType() + ); + this.collationDerivation = source.getCollationDerivation(); } @@ -959,10 +973,26 @@ * * @return the name of the collation being used in this type. */ - public String getCollationName() - { - return(typeDescriptor.getCollationName()); - } + /** + * Gets the name of the collation type in this descriptor if the collation + * derivation is not NONE. If the collation derivation is NONE, then this + * method will return "NONE". + *

+ * This method is used for generating error messages which will use correct + * string describing collation type/derivation. + * + * + * @return the name of the collation being used in this type. + */ + public String getCollationName() + { + return( + getCollationDerivation() == StringDataValue.COLLATION_DERIVATION_NONE ? + Property.COLLATION_NONE : + getCollationType() == StringDataValue.COLLATION_TYPE_UCS_BASIC ? + Property.UCS_BASIC_COLLATION : + Property.TERRITORY_BASED_COLLATION); + } /** * Set the collation type of this TypeDescriptor @@ -977,10 +1007,45 @@ typeDescriptor.setCollationType(collationTypeValue); } - /** @see TypeDescriptor#getCollationDerivation() */ + /** + * Get the collation derivation for this type. This applies only for + * character string types. For the other types, this api should be + * ignored. + * + * SQL spec talks about character string types having collation type and + * collation derivation associated with them (SQL spec Section 4.2.2 + * Comparison of character strings). If collation derivation says explicit + * or implicit, then it means that there is a valid collation type + * associated with the charcter string type. If the collation derivation is + * none, then it means that collation type can't be established for the + * character string type. + * + * 1)Collation derivation will be explicit if SQL COLLATE clause has been + * used for character string type (this is not a possibility for Derby 10.3 + * because we are not planning to support SQL COLLATE clause in the 10.3 + * release). + * + * 2)Collation derivation will be implicit if the collation can be + * determined w/o the COLLATE clause eg CREATE TABLE t1(c11 char(4)) then + * c11 will have collation of USER character set. Another eg, TRIM(c11) + * then the result character string of TRIM operation will have collation + * of the operand, c11. + * + * 3)Collation derivation will be none if the aggregate methods are dealing + * with character strings with different collations (Section 9.3 Data types + * of results of aggregations Syntax Rule 3aii). + * + * Collation derivation will be initialized to COLLATION_DERIVATION_NONE. + * + * @return Should be COLLATION_DERIVATION_NONE or COLLATION_DERIVATION_IMPLICIT + * + * @see StringDataValue#COLLATION_DERIVATION_NONE + * @see StringDataValue#COLLATION_DERIVATION_IMPLICIT + * @see StringDataValue#COLLATION_DERIVATION_EXPLICIT + */ public int getCollationDerivation() { - return typeDescriptor.getCollationDerivation(); + return collationDerivation; } /** @@ -1004,7 +1069,7 @@ */ public void setCollationDerivation(int collationDerivationValue) { - typeDescriptor.setCollationDerivation(collationDerivationValue); + collationDerivation = collationDerivationValue; } /** @@ -1046,12 +1111,17 @@ } /** - Compare if two TypeDescriptors are exactly the same - @param aTypeDescriptor the typeDescriptor to compare to. + Compare if two DataTypeDescriptors are exactly the same + @param other the type to compare to. */ - public boolean equals(Object aTypeDescriptor) + public boolean equals(Object other) { - return typeDescriptor.equals(aTypeDescriptor); + if (!(other instanceof DataTypeDescriptor)) + return false; + + DataTypeDescriptor odtd = (DataTypeDescriptor) other; + return typeDescriptor.equals(odtd.typeDescriptor) + && collationDerivation == odtd.collationDerivation; } /**