db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r617162 - in /db/derby/code/trunk/java/engine/org/apache/derby: catalog/ iapi/sql/dictionary/ iapi/types/ impl/sql/catalog/ impl/sql/compile/
Date Thu, 31 Jan 2008 17:12:45 GMT
Author: djd
Date: Thu Jan 31 09:12:30 2008
New Revision: 617162

URL: http://svn.apache.org/viewvc?rev=617162&view=rev
Log:
DERBY-2775 Make DataTypeDescriptor immutable by removing the set methods for collation type and derivation.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/catalog/TypeDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.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/catalog/DataDictionaryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.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/CharConstantNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.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/sql/compile/TableElementList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.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=617162&r1=617161&r2=617162&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 Thu Jan 31 09:12:30 2008
@@ -58,15 +58,7 @@
     TypeDescriptor SMALLINT = 
         DataTypeDescriptor.getBuiltInDataTypeDescriptor(
             Types.SMALLINT).getCatalogType();
- 
-    
-    /**
-     * Catalog type for nullable VARCHAR(128) used for types representing
-     * system catalogs.
-     */
-    TypeDescriptor VARCHAR128 =
-        DataTypeDescriptor.getBuiltInDataTypeDescriptor(
-                Types.VARCHAR, 128).getCatalogType();
+
 
 	///////////////////////////////////////////////////////////////////////
 	//

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java Thu Jan 31 09:12:30 2008
@@ -32,6 +32,7 @@
 import org.apache.derby.iapi.types.NumberDataValue;
 import org.apache.derby.iapi.types.DataValueFactory;
 import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.sql.compile.CostEstimate;
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
 import org.apache.derby.iapi.sql.execute.ExecutionFactory;
@@ -39,9 +40,11 @@
 import org.apache.derby.iapi.store.access.TransactionController;
 import org.apache.derby.iapi.types.RowLocation;
 
+import org.apache.derby.catalog.TypeDescriptor;
 import org.apache.derby.catalog.UUID;
 import org.apache.derby.iapi.services.uuid.UUIDFactory;
 
+import java.sql.Types;
 import java.util.List;
 import java.util.Hashtable;
 import java.util.Properties;
@@ -133,6 +136,21 @@
 	 */
 	public  static  final   String  SOFT_DATA_DICTIONARY_VERSION = "derby.softDataDictionaryVersion";
     public  static  final   String  PROPERTY_CONGLOMERATE_VERSION = "PropertyConglomerateVersion";
+    
+    /**
+     * An immutable runtime type that describes the type VARCHAR(128) NOT NULL
+     * with collation type UCS_BASIC and derivation IMPLICIT.
+     */
+    public static final DataTypeDescriptor TYPE_SYSTEM_IDENTIFIER =
+        DataTypeDescriptor.getBuiltInDataTypeDescriptor(
+                Types.VARCHAR, false, 128);
+      
+    /**
+     * An immutable catalog type that describes the type VARCHAR(128) NOT NULL
+     * with collation type UCS_BASIC.
+     */
+    public static final TypeDescriptor CATALOG_TYPE_SYSTEM_IDENTIFIER =
+        TYPE_SYSTEM_IDENTIFIER.getCatalogType();
 
 	/*
 	** CORE TABLES

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=617162&r1=617161&r2=617162&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 Thu Jan 31 09:12:30 2008
@@ -74,6 +74,10 @@
 	*/
 	/**
 	 * Get a descriptor that corresponds to a nullable builtin JDBC type.
+     * If a variable length type then the size information will be set 
+     * to the maximum possible.
+     * 
+     * Collation type will be UCS_BASIC and derivation IMPLICIT.
 	 *
 	 * @param jdbcType	The int type of the JDBC type for which to get
 	 *						a corresponding SQL DataTypeDescriptor
@@ -88,7 +92,20 @@
 	{
 		return DataTypeDescriptor.getBuiltInDataTypeDescriptor(jdbcType, true);
 	}
-	public static DataTypeDescriptor getBuiltInDataTypeDescriptor
+    
+    /**
+     * Get a descriptor that corresponds to a nullable builtin variable
+     * length JDBC type.
+     *
+     * Collation type will be UCS_BASIC and derivation IMPLICIT.
+     * 
+     * @param jdbcType  The int type of the JDBC type for which to get
+     *                      a corresponding SQL DataTypeDescriptor
+     *
+     * @return  A new DataTypeDescriptor that corresponds to the Java type.
+     *          A null return value means there is no corresponding SQL type
+     */
+    public static DataTypeDescriptor getBuiltInDataTypeDescriptor
 	(
 		int	jdbcType,
 		int length
@@ -162,6 +179,8 @@
 	}
 	/**
 	 * Get a descriptor that corresponds to a builtin JDBC type.
+     * 
+     * Collation type will be UCS_BASIC and derivation IMPLICIT.
 	 *
 	 * @param jdbcType	The int type of the JDBC type for which to get
 	 *						a corresponding SQL DataTypeDescriptor
@@ -187,7 +206,9 @@
 		return new DataTypeDescriptor(typeId, isNullable, maxLength);
 	}
 	/**
-	 * Get a DataTypeServices that corresponds to a builtin SQL type
+	 * Get a DataTypeServices that corresponds to a nullable builtin SQL type.
+     * 
+     * Collation type will be UCS_BASIC and derivation IMPLICIT.
 	 *
 	 * @param sqlTypeName	The name of the type for which to get
 	 *						a corresponding SQL DataTypeDescriptor
@@ -204,6 +225,8 @@
 	}
 	/**
 	 * Get a DataTypeServices that corresponds to a builtin SQL type
+     * 
+     * Collation type will be UCS_BASIC and derivation IMPLICIT.
 	 *
 	 * @param sqlTypeName	The name of the type for which to get
 	 *						a corresponding SQL DataTypeDescriptor
@@ -631,7 +654,7 @@
 		boolean				nullable;
 		TypeId				thisType;
 		TypeId				otherType;
-		DataTypeDescriptor	higherType = null;
+		DataTypeDescriptor	higherType;
 		DataTypeDescriptor	lowerType = null;
 		int					maximumWidth;
 		int					precision = getPrecision();
@@ -832,23 +855,31 @@
 			if (getCollationDerivation() != otherDTS.getCollationDerivation()) {
 				if (getCollationDerivation() == StringDataValue.COLLATION_DERIVATION_NONE) {
 					//Step 2
-					higherType.setCollationDerivation(otherDTS.getCollationDerivation());					
-					higherType.setCollationType(otherDTS.getCollationType());					
+                    higherType = higherType.getCollatedType(
+                            otherDTS.getCollationType(),
+                            otherDTS.getCollationDerivation());                                      
+
 				} else if (otherDTS.getCollationDerivation() == StringDataValue.COLLATION_DERIVATION_NONE) {
 					//Step 2
-					higherType.setCollationDerivation(getCollationDerivation());					
-					higherType.setCollationType(getCollationType());										
+                    higherType = higherType.getCollatedType(
+                            getCollationType(),
+                            getCollationDerivation());										
 				} else {
 					//Step 3
-					higherType.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_NONE);					
+                    higherType = higherType.getCollatedType(
+                            StringDataValue.COLLATION_TYPE_UCS_BASIC, // ignored
+                            StringDataValue.COLLATION_DERIVATION_NONE);					
 				}
 			} else if (getCollationType() != otherDTS.getCollationType())
 				//Step 4
-				higherType.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_NONE);	
+                higherType = higherType.getCollatedType(
+                        StringDataValue.COLLATION_TYPE_UCS_BASIC, // ignored
+                        StringDataValue.COLLATION_DERIVATION_NONE);                 
 			else {
 				//Step 1
-				higherType.setCollationDerivation(getCollationDerivation());					
-				higherType.setCollationType(getCollationType());									
+                higherType = higherType.getCollatedType(
+                        getCollationType(),
+                        getCollationDerivation());
 			}
 		}
 
@@ -1030,19 +1061,6 @@
     }
 
     /**
-     * Set the collation type of this TypeDescriptor
-     * @param collationTypeValue This will be COLLATION_TYPE_UCS_BASIC
-     * or COLLATION_TYPE_TERRITORY_BASED
-     * 
-     * @see StringDataValue#COLLATION_TYPE_UCS_BASIC
-     * @see StringDataValue#COLLATION_TYPE_TERRITORY_BASED
-     */
-    public void	setCollationType(int collationTypeValue)
-	{
-		typeDescriptor.setCollationType(collationTypeValue);
-	}
-
-    /**
      * Get the collation derivation for this type. This applies only for
      * character string types. For the other types, this api should be
      * ignored.
@@ -1070,7 +1088,8 @@
      * 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.
+     * Collation derivation will be initialized to COLLATION_DERIVATION_IMPLICIT
+     * if not explicitly set.
      *  
      * @return Should be COLLATION_DERIVATION_NONE or COLLATION_DERIVATION_IMPLICIT
      * 
@@ -1089,22 +1108,6 @@
 	public	boolean isRowMultiSet()
 	{
 		return getTypeId().isRowMultiSetTypeId();
-	}
-
-    /**
-     * Set the collation derivation of this DTD
-     * @param collationDerivationValue This will be 
-     * COLLATION_DERIVATION_NONE/COLLATION_DERIVATION_IMPLICIT/COLLATION_DERIVATION_EXPLICIT
-     * In Derby 10.3, we do not expect to get value COLLATION_DERIVATION_EXPLICIT.
-     * 
-     * @see StringDataValue#COLLATION_DERIVATION_NONE
-     * @see StringDataValue#COLLATION_DERIVATION_IMPLICIT
-     * @see StringDataValue#COLLATION_DERIVATION_EXPLICIT
-
-     */
-	public void	setCollationDerivation(int collationDerivationValue)
-	{
-        collationDerivation = collationDerivationValue;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java Thu Jan 31 09:12:30 2008
@@ -9039,7 +9039,7 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 DataTypeDescriptor.getCatalogType(
                     Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH)
             };
@@ -9064,8 +9064,8 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                     TypeDescriptor.SMALLINT
 
             };
@@ -9253,7 +9253,7 @@
             String[] arg_names = {"KEY"};
 
             // procedure argument types
-            TypeDescriptor[] arg_types = {TypeDescriptor.VARCHAR128};
+            TypeDescriptor[] arg_types = {CATALOG_TYPE_SYSTEM_IDENTIFIER};
 
             createSystemProcedureOrFunction(
                 "SYSCS_GET_DATABASE_PROPERTY",
@@ -9275,8 +9275,8 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER
             };
 
             createSystemProcedureOrFunction(
@@ -9332,7 +9332,7 @@
             TypeDescriptor[] arg_types = {
 				DataTypeDescriptor.getCatalogType(
                     Types.VARCHAR, 256),
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                     TypeDescriptor.INTEGER
             };
 
@@ -9355,7 +9355,7 @@
             TypeDescriptor[] arg_types = {
 				DataTypeDescriptor.getCatalogType(
                     Types.VARCHAR, 256),
-                    TypeDescriptor.VARCHAR128
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER
             };
 
             createSystemProcedureOrFunction(
@@ -9375,7 +9375,7 @@
             String[] arg_names = {"JAR", "UNDEPLOY"};
 
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                     TypeDescriptor.INTEGER
             };
 
@@ -9406,14 +9406,14 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128, 
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER, 
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                     varchar32672Type,
 				DataTypeDescriptor.getCatalogType(
 				Types.CHAR, 1),
 				DataTypeDescriptor.getCatalogType(
 				Types.CHAR, 1),
-                TypeDescriptor.VARCHAR128
+                CATALOG_TYPE_SYSTEM_IDENTIFIER
             };
 
             createSystemProcedureOrFunction(
@@ -9448,7 +9448,7 @@
 				Types.CHAR, 1),
 				DataTypeDescriptor.getCatalogType(
 				Types.CHAR, 1),
-                TypeDescriptor.VARCHAR128
+                CATALOG_TYPE_SYSTEM_IDENTIFIER
             };
 
             createSystemProcedureOrFunction(
@@ -9479,14 +9479,14 @@
 			
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128, 
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER, 
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                     varchar32672Type,
 				DataTypeDescriptor.getCatalogType(
 				Types.CHAR, 1),
 				DataTypeDescriptor.getCatalogType(
 				Types.CHAR, 1),
-                TypeDescriptor.VARCHAR128,
+                CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 TypeDescriptor.SMALLINT,
             };
 
@@ -9520,8 +9520,8 @@
 			
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128, 
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER, 
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                     varchar32672Type,
                     varchar32672Type,
                     varchar32672Type,
@@ -9529,7 +9529,7 @@
 				Types.CHAR, 1),
 				DataTypeDescriptor.getCatalogType(
 				Types.CHAR, 1),
-                TypeDescriptor.VARCHAR128,
+                CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 TypeDescriptor.SMALLINT,
             };
 
@@ -9561,8 +9561,8 @@
 			
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128, 
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER, 
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                     varchar32672Type,
                     varchar32672Type,
             };
@@ -9680,9 +9680,9 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
             createSystemProcedureOrFunction(
@@ -9709,9 +9709,9 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
             createSystemProcedureOrFunction(
@@ -9738,9 +9738,9 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
             createSystemProcedureOrFunction(
@@ -9768,9 +9768,9 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000),
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
@@ -9800,10 +9800,10 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
             createSystemProcedureOrFunction(
@@ -9831,10 +9831,10 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
             createSystemProcedureOrFunction(
@@ -9862,10 +9862,10 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
             createSystemProcedureOrFunction(
@@ -9893,10 +9893,10 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
             createSystemProcedureOrFunction(
@@ -9927,12 +9927,12 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
             createSystemProcedureOrFunction(
@@ -9964,9 +9964,9 @@
             // procedure argument types
             TypeDescriptor[] arg_types = {
                     TypeDescriptor.SMALLINT,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 TypeDescriptor.SMALLINT,
                 TypeDescriptor.SMALLINT,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
@@ -10023,9 +10023,9 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
-				TypeDescriptor.VARCHAR128,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
+				CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 TypeDescriptor.SMALLINT,
                 TypeDescriptor.SMALLINT,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
@@ -10198,8 +10198,8 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                TypeDescriptor.VARCHAR128,
-                TypeDescriptor.VARCHAR128,
+                CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 TypeDescriptor.SMALLINT,
                 TypeDescriptor.SMALLINT,
                 TypeDescriptor.SMALLINT
@@ -10306,9 +10306,9 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
             createSystemProcedureOrFunction(
@@ -10337,10 +10337,10 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
 				DataTypeDescriptor.getCatalogType(Types.VARCHAR, 4000)};
 
             createSystemProcedureOrFunction(
@@ -10771,15 +10771,15 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128, 
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER, 
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 DataTypeDescriptor.getCatalogType(
                 Types.VARCHAR, 32672),
                 DataTypeDescriptor.getCatalogType(
                 Types.CHAR, 1),
                 DataTypeDescriptor.getCatalogType(
                 Types.CHAR, 1),
-                TypeDescriptor.VARCHAR128,
+                CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 DataTypeDescriptor.getCatalogType(
                 Types.VARCHAR, 32672)
             };
@@ -10819,7 +10819,7 @@
                 Types.CHAR, 1),
                 DataTypeDescriptor.getCatalogType(
                 Types.CHAR, 1),
-                TypeDescriptor.VARCHAR128,
+                CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 DataTypeDescriptor.getCatalogType(
                 Types.VARCHAR, 32672)
             };
@@ -10850,15 +10850,15 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128, 
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER, 
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 DataTypeDescriptor.getCatalogType(
                 Types.VARCHAR, 32672),
                 DataTypeDescriptor.getCatalogType(
                 Types.CHAR, 1),
                 DataTypeDescriptor.getCatalogType(
                 Types.CHAR, 1),
-                TypeDescriptor.VARCHAR128,
+                CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 TypeDescriptor.SMALLINT,
             };
 
@@ -10890,8 +10890,8 @@
 
             // procedure argument types
             TypeDescriptor[] arg_types = {
-                    TypeDescriptor.VARCHAR128, 
-                    TypeDescriptor.VARCHAR128,
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER, 
+                    CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 DataTypeDescriptor.getCatalogType(
                 Types.VARCHAR, 32672),
                 DataTypeDescriptor.getCatalogType(
@@ -10902,7 +10902,7 @@
                 Types.CHAR, 1),
                 DataTypeDescriptor.getCatalogType(
                 Types.CHAR, 1),
-                TypeDescriptor.VARCHAR128,
+                CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 TypeDescriptor.SMALLINT,
             };
 
@@ -10937,7 +10937,7 @@
         // void SYSCS_UTIL.SYSCS_SET_USER_ACCESS(USER_NAME VARCHAR(128),
         // CONNECTION_PERMISSION VARCHAR(128))
         {
-            TypeDescriptor[] arg_types = {TypeDescriptor.VARCHAR128, TypeDescriptor.VARCHAR128};
+            TypeDescriptor[] arg_types = {CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER};
 
             createSystemProcedureOrFunction(
                 "SYSCS_SET_USER_ACCESS",
@@ -10953,7 +10953,7 @@
         
         // VARCHAR(128) SYSCS_UTIL.SYSCS_SET_USER_ACCESS(USER_NAME VARCHAR(128))
         {               
-            TypeDescriptor[] arg_types = { TypeDescriptor.VARCHAR128 };
+            TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER };
 
             createSystemProcedureOrFunction(
                 "SYSCS_GET_USER_ACCESS",
@@ -10963,7 +10963,7 @@
                 0,
                 0,
                 RoutineAliasInfo.READS_SQL_DATA,
-                TypeDescriptor.VARCHAR128,
+                CATALOG_TYPE_SYSTEM_IDENTIFIER,
                 tc);
         }
         

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java Thu Jan 31 09:12:30 2008
@@ -245,8 +245,7 @@
 							//collation type of this column to be the same as
 							//schema descriptor's collation. Set the collation
 							//derivation as implicit
-							cdn.getType().setCollationType(schemaDescriptor.getCollationType());
-							cdn.getType().setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+							cdn.setCollationType(schemaDescriptor.getCollationType());
 			        	}						
 					}
 				}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?rev=617162&r1=617161&r2=617162&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 Thu Jan 31 09:12:30 2008
@@ -374,8 +374,7 @@
 		if (externallyGeneratedCastNode && getTypeId().isStringTypeId()) {
 			//set the collation type to be same as the compilation schema's 
 			//collation type. Collation derivation will be set to "IMPLICIT".
-			setCollationUsingCompilationSchema(
-					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+			setCollationUsingCompilationSchema();
 		}
 		/* 
 		** If it is a java cast, do some work to make sure

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharConstantNode.java Thu Jan 31 09:12:30 2008
@@ -155,8 +155,7 @@
 	{
 		//The DTD for this character constant should get its collation type
 		//from the schema it is getting compiled in.
-		setCollationUsingCompilationSchema(
-				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+		setCollationUsingCompilationSchema();
 	    //Once we have the collation type, we should check if the value
 	    //associated with this node should change from 
 	    //SQLChar/SQLVarchar/SQLLongvarchar/SQLClob

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java Thu Jan 31 09:12:30 2008
@@ -37,6 +37,7 @@
 
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.types.TypeId;
 
 import org.apache.derby.iapi.sql.depend.DependencyManager;
@@ -217,6 +218,16 @@
     void setNullability(boolean nullable)
     {
         type = getType().getNullabilityType(nullable);
+    }
+    
+    /**
+     * Set the collation type, note derivation is always
+     * implicit for any catalog item.
+     */
+    void setCollationType(int collationType)
+    {
+        type = getType().getCollatedType(collationType,
+                StringDataValue.COLLATION_DERIVATION_IMPLICIT);
     }
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java Thu Jan 31 09:12:30 2008
@@ -196,16 +196,17 @@
 			DataTypeDescriptor dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(
 					Types.VARCHAR, true, tc
 					.getCastToCharWidth(leftOperand							.getTypeServices()));	
-			// DERBY-2910 - Match current schema collation for implicit cast as we do for
-			// explicit casts per SQL Spec 6.12 (10)									
-			dtd.setCollationType(getSchemaDescriptor(null).getCollationType());
-			dtd.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
 
 			leftOperand = (ValueNode) getNodeFactory().getNode(
 					C_NodeTypes.CAST_NODE,
 					leftOperand,
 					dtd,
 					getContextManager());
+
+			// DERBY-2910 - Match current schema collation for implicit cast as we do for
+			// explicit casts per SQL Spec 6.12 (10)			
+			leftOperand.setCollationUsingCompilationSchema();
+						
 			((CastNode) leftOperand).bindCastNodeOnly();
 		}
 		tc = rightOperand.getTypeCompiler();
@@ -215,16 +216,17 @@
 					Types.VARCHAR, true, tc
 							.getCastToCharWidth(rightOperand
 									.getTypeServices()));
-			// DERBY-2910 - Match current schema collation for implicit cast as we do for
-			// explicit casts per SQL Spec 6.12 (10)					
-			dtd.setCollationType(getSchemaDescriptor(null).getCollationType());
-			dtd.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
 
 			rightOperand = (ValueNode) getNodeFactory().getNode(
 					C_NodeTypes.CAST_NODE,
 					rightOperand,
 					dtd,
 					getContextManager());
+			
+			// DERBY-2910 - Match current schema collation for implicit cast as we do for
+			// explicit casts per SQL Spec 6.12 (10)					
+			rightOperand.setCollationUsingCompilationSchema();
+			
 			((CastNode) rightOperand).bindCastNodeOnly();
 		}
 
@@ -494,11 +496,14 @@
 		if (leftType.getCollationDerivation() != rightType
 				.getCollationDerivation()
 				|| leftType.getCollationType() != rightType.getCollationType())
-			returnDTD
-					.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_NONE);
+            
+            returnDTD = returnDTD.getCollatedType(
+                    returnDTD.getCollationDerivation(),
+                    StringDataValue.COLLATION_DERIVATION_NONE);
 		else {
-			returnDTD.setCollationDerivation(leftType.getCollationDerivation());
-			returnDTD.setCollationType(leftType.getCollationType());
+            returnDTD = returnDTD.getCollatedType(
+                    leftType.getCollationType(),
+                    leftType.getCollationDerivation());
 		}
 		return returnDTD;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java Thu Jan 31 09:12:30 2008
@@ -287,6 +287,7 @@
 		//the passed parameter is null and if so, then simply return.
 		if (changeTD == null) 
 			return changeTD;
+        
 		TypeId compTypeId = TypeId.getBuiltInTypeId(changeTD.getTypeName());
 		//No work to do if type id does not correspond to a character string
 		if (compTypeId != null && compTypeId.isStringTypeId()) {
@@ -296,11 +297,11 @@
 						changeTD.getMaximumWidth());
 			//Use the collation type and info of the schema in which this
 			//function is defined for the return value of the function
-			newTDWithCorrectCollation.setCollationType(
-					getSchemaDescriptor().getCollationType());
-			newTDWithCorrectCollation.setCollationDerivation(
-	        		StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			return newTDWithCorrectCollation;
+            newTDWithCorrectCollation =
+                newTDWithCorrectCollation.getCollatedType(
+					getSchemaDescriptor().getCollationType(),
+                    StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+			return newTDWithCorrectCollation.getCatalogType();
 		}
 		return changeTD;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java Thu Jan 31 09:12:30 2008
@@ -251,15 +251,17 @@
 			throw StandardException.newException(SQLState.LANG_NO_CORRESPONDING_S_Q_L_TYPE, 
 				javaNode.getJavaTypeName());
 		}
-                // For functions returning string types we should set the collation to match the 
-                // java method's schema DERBY-2972. This is propogated from 
-                // RoutineAliasInfo to javaNode.
-                       if (dts.getTypeId().isStringTypeId()){                           
-                           dts.setCollationType(javaNode.getCollationType());
-                           dts.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-                       }
-		setType(dts);
-         
+        
+        setType(dts);
+		
+        // For functions returning string types we should set the collation to match the 
+        // java method's schema DERBY-2972. This is propogated from 
+        // RoutineAliasInfo to javaNode.
+        if (dts.getTypeId().isStringTypeId()) {
+            this.setCollationInfo(javaNode.getCollationType(),
+                    StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+        }
+
 		return this;
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java Thu Jan 31 09:12:30 2008
@@ -198,8 +198,7 @@
             } else if (rightOperand != null && !rightOperand.requiresTypeFromContext()) {
                 receiver.setCollationInfo(rightOperand.getTypeServices());          	
             } else {
-    			receiver.setCollationUsingCompilationSchema(
-    					StringDataValue.COLLATION_DERIVATION_IMPLICIT);            	
+    			receiver.setCollationUsingCompilationSchema();            	
             }
         }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ModifyColumnNode.java Thu Jan 31 09:12:30 2008
@@ -215,7 +215,7 @@
 
 	/**
 	 * If the column being modified is of character string type, then it should
-	 * get it's collation from the corresponding column in the TableDescriptor.
+	 * get its collation from the corresponding column in the TableDescriptor.
 	 * This will ensure that at alter table time, the existing character string
 	 * type columns do not loose their collation type. If the alter table is 
 	 * doing a drop column, then we do not need to worry about collation info.
@@ -238,9 +238,7 @@
 		//no need to worry about collation info
 		if (getType() != null) {
 			if (getType().getTypeId().isStringTypeId()) {
-				this.getType().setCollationType(cd.getType().getCollationType());
-				this.getType().setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			
+				setCollationType(cd.getType().getCollationType());			
 			}
 		}
     }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java Thu Jan 31 09:12:30 2008
@@ -106,10 +106,6 @@
 							  operand.getTypeCompiler().
 								getCastToCharWidth(
 									operand.getTypeServices()));
-				// DERBY-2910 - Match current schema collation for implicit cast as we do for
-				// explicit casts per SQL Spec 6.12 (10)					
-				dtd.setCollationType(getSchemaDescriptor(null).getCollationType());
-				dtd.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
 			
 					operand =  (ValueNode)
 						getNodeFactory().getNode(
@@ -117,6 +113,11 @@
 							operand,
 							dtd,
 							getContextManager());
+					
+				// DERBY-2910 - Match current schema collation for implicit cast as we do for
+				// explicit casts per SQL Spec 6.12 (10)					
+			    operand.setCollationUsingCompilationSchema();
+			    
 				((CastNode) operand).bindCastNodeOnly();
 					operandType = operand.getTypeId();
 		}
@@ -155,8 +156,7 @@
 
 		operand.setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR));
 		//collation of ? operand should be same as the compilation schema
-		operand.setCollationUsingCompilationSchema(
-				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+		operand.setCollationUsingCompilationSchema();
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SpecialFunctionNode.java Thu Jan 31 09:12:30 2008
@@ -41,6 +41,7 @@
 import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
 import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
 
 import java.sql.Types;
 
@@ -134,27 +135,25 @@
 			}
 			methodName = "getAuthorizationId";
 			methodType = "java.lang.String";
-			dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, false, 128);
+            
 			//SQL spec Section 6.4 Syntax Rule 4 says that the collation type 
 			//of these functions will be the collation of character set 
 			//SQL_IDENTIFIER. In Derby's case, that will mean, the collation of
 			//these functions will be UCS_BASIC. The collation derivation will 
 			//be implicit. 
-			dtd.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			dtd.setCollationType(StringDataValue.COLLATION_TYPE_UCS_BASIC);
+            dtd = DataDictionary.TYPE_SYSTEM_IDENTIFIER;
 			break;
 
 		case C_NodeTypes.CURRENT_SCHEMA_NODE:
 			sqlName = "CURRENT SCHEMA";
 			methodName = "getCurrentSchemaName";
 			methodType = "java.lang.String";
-			dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, false, 128);
-			//This is a Derby specific function but it's collation type will
+			
+			//This is a Derby specific function but its collation type will
 			//be based on the same rules as for SESSION_USER/CURRENT_USER etc. 
 			//ie there collation type will be UCS_BASIC. The collation 
 			//derivation will be implicit. 
-			dtd.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			dtd.setCollationType(StringDataValue.COLLATION_TYPE_UCS_BASIC);
+            dtd = DataDictionary.TYPE_SYSTEM_IDENTIFIER;
 			break;
 
 		case C_NodeTypes.CURRENT_ROLE_NODE:
@@ -167,10 +166,7 @@
 			//of these functions will be the collation of character set
 			//SQL_IDENTIFIER. In Derby's case, that will mean, the collation of
 			//these functions will be UCS_BASIC. The collation derivation will
-			//be implicit.
-			dtd.setCollationDerivation(
-				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			dtd.setCollationType(StringDataValue.COLLATION_TYPE_UCS_BASIC);
+			//be implicit. (set by default)
 			break;
 
 		case C_NodeTypes.IDENTITY_VAL_NODE:
@@ -188,9 +184,7 @@
 			//This is a Derby specific function but it's collation type will
 			//be based on the same rules as for SESSION_USER/CURRENT_USER etc. 
 			//ie there collation type will be UCS_BASIC. The collation 
-			//derivation will be implicit. 
-			dtd.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
-			dtd.setCollationType(StringDataValue.COLLATION_TYPE_UCS_BASIC);
+			//derivation will be implicit. (set by default).
 			break;
 		default:
 			if (SanityManager.DEBUG)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java?rev=617162&r1=617161&r2=617162&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 Thu Jan 31 09:12:30 2008
@@ -278,9 +278,8 @@
 								returnType.isNullable(),
 								returnType.getMaximumWidth()
 							);
-					// DERBY-2972  Match the collation of the RoutineAliasInfo		
-					returnValueDtd.setCollationType(returnType.getCollationType());
-                                        returnValueDtd.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+							
+
 					ValueNode returnValueToSQL = (ValueNode) getNodeFactory().getNode(
 								C_NodeTypes.JAVA_TO_SQL_VALUE_NODE,
 								this, 
@@ -291,6 +290,11 @@
 									returnValueToSQL, 
 									returnValueDtd,
 									getContextManager());
+                    
+                    // DERBY-2972  Match the collation of the RoutineAliasInfo
+                    returnValueCastNode.setCollationInfo(
+                            returnType.getCollationType(),
+                            StringDataValue.COLLATION_DERIVATION_IMPLICIT);
 
 
 					JavaValueNode returnValueToJava = (JavaValueNode) getNodeFactory().getNode(

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java Thu Jan 31 09:12:30 2008
@@ -124,8 +124,7 @@
 			{
 				ColumnDefinitionNode cdn = (ColumnDefinitionNode) elementAt(index);
 				if (cdn.getType().getTypeId().isStringTypeId()) {
-					cdn.getType().setCollationType(collationType);
-					cdn.getType().setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+					cdn.setCollationType(collationType);
 				}
 			}
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java Thu Jan 31 09:12:30 2008
@@ -534,8 +534,7 @@
             if (!leftOperand.requiresTypeFromContext()) {
                 receiver.setCollationInfo(leftOperand.getTypeServices());
             } else {
-    			receiver.setCollationUsingCompilationSchema(
-    					StringDataValue.COLLATION_DERIVATION_IMPLICIT);            	
+    			receiver.setCollationUsingCompilationSchema();            	
             }
 		}
 
@@ -633,8 +632,7 @@
 				receiver.setType(getVarcharDescriptor());
 	            //Since both receiver and leftOperands are parameters, use the
 				//collation of compilation schema for receiver.
-				receiver.setCollationUsingCompilationSchema(
-						StringDataValue.COLLATION_DERIVATION_IMPLICIT);            	
+				receiver.setCollationUsingCompilationSchema();            	
 			}
 			else
 			{
@@ -719,16 +717,18 @@
 			DataTypeDescriptor dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, true,
 	                vnTC.getCastToCharWidth(
 		                    vn.getTypeServices()));
-			// DERBY-2910 - Match current schema collation for implicit cast as we do for
-			// explicit casts per SQL Spec 6.12 (10)							                    
-			dtd.setCollationType(getSchemaDescriptor(null).getCollationType());
-			dtd.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+
 			ValueNode newNode = (ValueNode)
 						getNodeFactory().getNode(
 							C_NodeTypes.CAST_NODE,
 							vn,
 							dtd,
 							getContextManager());
+            
+            // DERBY-2910 - Match current schema collation for implicit cast as we do for
+            // explicit casts per SQL Spec 6.12 (10)                                                
+            newNode.setCollationUsingCompilationSchema();
+            
 			((CastNode) newNode).bindCastNodeOnly();
 			return newNode;
 		}
@@ -765,8 +765,7 @@
 			//because that is the only context available for us to pick up the
 			//collation. There are no other character operands to SUBSTR method
 			//to pick up the collation from.
-			receiver.setCollationUsingCompilationSchema(
-					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+			receiver.setCollationUsingCompilationSchema();
 		}
 
 		/* Is there a ? parameter on the left? */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java Thu Jan 31 09:12:30 2008
@@ -448,8 +448,7 @@
         setType(targetType);
 		//Set the collation type to be same as the current schema's 
 		//collation type. 
-        setCollationUsingCompilationSchema(
-				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+        setCollationUsingCompilationSchema();
     }
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java Thu Jan 31 09:12:30 2008
@@ -36,6 +36,7 @@
 import org.apache.derby.iapi.store.access.Qualifier;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.DataValueFactory;
+import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.util.JBitSet;
 
@@ -289,6 +290,18 @@
 	}
 	
 	/**
+	 * Set the collation based upon the current schema with derivation
+	 * type implicit.
+	 * 
+	 * @throws StandardException
+	 */
+	protected final void setCollationUsingCompilationSchema()
+	throws StandardException {
+		setCollationUsingCompilationSchema(
+				StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+	}	
+	
+	/**
 	 * There are many subclasses of ValueNode where we want the 
 	 * DataTypeDescriptor of the node to have the same collation type as the 
 	 * compilation schema's collation type. For that purpose, this method in 
@@ -303,7 +316,7 @@
 	 * 
 	 * @throws StandardException
 	 */
-	protected void setCollationUsingCompilationSchema(int collationDerivation)
+	protected final void setCollationUsingCompilationSchema(int collationDerivation)
 	throws StandardException {
         setCollationInfo(
                 getSchemaDescriptor(null, false).getCollationType(),

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?rev=617162&r1=617161&r2=617162&view=diff
==============================================================================
--- 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 Thu Jan 31 09:12:30 2008
@@ -236,7 +236,10 @@
 				//do not have matching collation information on them. Hence the
 				//resultant dominant DTD should have collation derivation of 
 				//NONE.
-				dominantDTS.setCollationDerivation(StringDataValue.COLLATION_DERIVATION_NONE);
+				dominantDTS =
+                    dominantDTS.getCollatedType(
+                            dominantDTS.getCollationType(),
+                            StringDataValue.COLLATION_DERIVATION_NONE);
 			}			
 			//if we didn't find any collation mismatch, then resultant dominant
 			//DTD already has the correct collation information on it and hence



Mime
View raw message