db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r540667 - in /db/derby/code/trunk/java: engine/org/apache/derby/catalog/types/ engine/org/apache/derby/iapi/types/ engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Tue, 22 May 2007 18:05:40 GMT
Author: mamta
Date: Tue May 22 11:05:38 2007
New Revision: 540667

URL: http://svn.apache.org/viewvc?view=rev&rev=540667
Log:
DERBY-2599
Committing patch DERBY2599_getNull_should_set_collation_info_v1_diff.txt attached to DERBY-2599.
This address the correct collation setting 
for ConstantNode created through QueryTreeNode's getNullNode method. This method currently
creates a ConstantNode using the passed typeId. 
We need to set the correct collation type and derivation on this ConstantNode. This is accomplished
by having the caller of this method 
pass the correct collation type and derivation. The junit tests have run fine with no problems.
derbyall is almost finished with no new 
failures.

In addition to the above change, this patch also fixes some comments in DataTypeDescriptor.java
and TypeDescriptorImpl.java


Modified:
    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
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.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=540667&r1=540666&r2=540667
==============================================================================
--- 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
Tue May 22 11:05:38 2007
@@ -90,10 +90,14 @@
 	}
 
 	/**
-	 * Constructor for use with numeric types/non-numeric types. For instance,
-	 * when dealing with MAX/MIN aggregrade operators, we do not if we are
-	 * working with numeric or non-numeric types. Such a constructor will be
-	 * used in those cases. 
+	 * Constructor to use when the caller doesn't know if it is requesting
+	 * numeric or no-numeric DTD. For instance, when dealing with MAX/MIN 
+	 * aggregrate operators, AggregateNode.bindExpression could be dealing
+	 * with a character string operand or a numeric operand. The result of
+	 * MAX/MIN will depend on the type of it's operand. And hence when this
+	 * constructor gets called by AggregateNode.bindExpression, we don't know 
+	 * what type we are constructing and hence this constructor supports 
+	 * arguments for both numeric and non-numeric types.
 	 *
 	 * @param typeId	The typeId of the type being described
 	 * @param precision	The number of decimal digits.

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=540667&r1=540666&r2=540667
==============================================================================
--- 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 Tue
May 22 11:05:38 2007
@@ -302,10 +302,14 @@
 	}
 
 	/**
-	 * Constructor for use with numeric types/non-numeric types. For instance,
-	 * when dealing with MAX/MIN aggregrade operators, we do not if we are
-	 * working with numeric or non-numeric types. Such a constructor will be
-	 * used in those cases. 
+	 * Constructor to use when the caller doesn't know if it is requesting
+	 * numeric or no-numeric DTD. For instance, when dealing with MAX/MIN 
+	 * aggregrate operators, AggregateNode.bindExpression could be dealing
+	 * with a character string operand or a numeric operand. The result of
+	 * MAX/MIN will depend on the type of it's operand. And hence when this
+	 * constructor gets called by AggregateNode.bindExpression, we don't know 
+	 * what type we are constructing and hence this constructor supports 
+	 * arguments for both numeric and non-numeric types.
 	 *
 	 * @param typeId	The typeId of the type being described
 	 * @param precision	The number of decimal digits.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java?view=diff&rev=540667&r1=540666&r2=540667
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java Tue
May 22 11:05:38 2007
@@ -553,8 +553,11 @@
 		** are created dynamically by the SortObservers
 		*/
 		ConstantNode nullNode = getNullNode(
-							compTypeId,
-							getContextManager());		// no params
+				compTypeId,
+				getContextManager(),
+				getTypeServices().getCollationType(),
+				getTypeServices().getCollationDerivation()
+				); // no params
 
 		nullNode.bindExpression(
 						null,	// from
@@ -620,7 +623,8 @@
 		** it.
 		*/
 		return getNullNode(this.getTypeId(),
-							getContextManager());
+							getContextManager(), this.getTypeServices().getCollationType(),
+							this.getTypeServices().getCollationDerivation());
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java?view=diff&rev=540667&r1=540666&r2=540667
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java Tue
May 22 11:05:38 2007
@@ -743,17 +743,20 @@
 	}
 
 	/**
-	 * Get a ConstantNode to represent a typed null value
+	 * Get a ConstantNode to represent a typed null value. Then set it's 
+	 * collation type and derivation
 	 *
 	 * @param typeId	The TypeId of the datatype of the null value
 	 * @param cm		The ContextManager
+	 * @param collationType The collation type of the ConstantNode
+	 * @param collationDerivation The Collation Derivation of the ConstantNode
 	 *
 	 * @return	A ConstantNode with the specified type, and a value of null
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
 	public  ConstantNode getNullNode(TypeId typeId,
-			ContextManager cm)
+			ContextManager cm, int collationType, int collationDerivation)
 		throws StandardException
 	{
 		QueryTreeNode constantNode = null;
@@ -907,7 +910,10 @@
 			}
 		}
 
-		return (ConstantNode) constantNode;
+		ConstantNode cn = (ConstantNode) constantNode;
+		cn.getTypeServices().setCollationType(collationType);
+		cn.getTypeServices().setCollationDerivation(collationDerivation);
+		return cn;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java?view=diff&rev=540667&r1=540666&r2=540667
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java Tue
May 22 11:05:38 2007
@@ -346,7 +346,8 @@
 		throws StandardException
 	{
 		expression = getNullNode(getTypeId(), 
-									getContextManager());
+									getContextManager(), getTypeServices().getCollationType(),
+									getTypeServices().getCollationDerivation());
 	}
 
 	/**
@@ -700,7 +701,14 @@
 		}
 
         if( expression instanceof UntypedNullConstantNode)
-            expression = getNullNode( typeId, getContextManager());
+        	//since we don't know the type of such a constant node, we just
+        	//use the default values for collation type and derivation.
+        	//eg insert into table1 values(1,null)
+        	//When this method is executed for the sql above, we don't know
+        	//the type of the null at this point.
+            expression = getNullNode( typeId, getContextManager(),
+            		StringDataValue.COLLATION_TYPE_UCS_BASIC,
+					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
         else if( ( expression instanceof ColumnReference) && expression.getTypeServices()
== null)
         {
             // The expression must be a reference to a null column in a values table.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java?view=diff&rev=540667&r1=540666&r2=540667
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java Tue
May 22 11:05:38 2007
@@ -1185,7 +1185,9 @@
                     colType,
                     getNullNode(
                         colType.getTypeId(),
-                        getContextManager()
+                        getContextManager(), 
+						colType.getCollationType(),
+                        colType.getCollationDerivation()
                         ),
                     getContextManager()
                     );

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java?view=diff&rev=540667&r1=540666&r2=540667
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
Tue May 22 11:05:38 2007
@@ -193,6 +193,12 @@
 			" 'SYSCOLUMNS'",
       		new String[][] {{"SYSCOLUMNS"} });   
 
+      //Do some testing with MAX/MIN operators
+      checkLangBasedQuery(s, "SELECT MAX(NAME) maxName FROM CUSTOMER ORDER BY maxName ",
+      		new String[][] {{"\u017Bebra"}});   
+      checkLangBasedQuery(s, "SELECT MIN(NAME) minName FROM CUSTOMER ORDER BY minName ",
+      		new String[][] {{"Acorn"}});   
+
       s.close();
       conn.commit();
 
@@ -348,6 +354,12 @@
 			" 'SYSCOLUMNS'",
       		new String[][] {{"SYSCOLUMNS"} });   
 
+      //Do some testing with MAX/MIN operators
+      checkLangBasedQuery(s, "SELECT MAX(NAME) maxName FROM CUSTOMER ORDER BY maxName ",
+      		new String[][] {{"\u017Bebra"}});   
+      checkLangBasedQuery(s, "SELECT MIN(NAME) minName FROM CUSTOMER ORDER BY minName ",
+      		new String[][] {{"aacorn"}});   
+
       s.close();
       conn.commit();
 
@@ -502,6 +514,12 @@
 			" 'SYSCOLUMNS'",
       		new String[][] {{"SYSCOLUMNS"} });   
 
+      //Do some testing with MAX/MIN operators
+      checkLangBasedQuery(s, "SELECT MAX(NAME) maxName FROM CUSTOMER ORDER BY maxName ",
+      		new String[][] {{"aacorn"}});   
+      checkLangBasedQuery(s, "SELECT MIN(NAME) minName FROM CUSTOMER ORDER BY minName ",
+      		new String[][] {{"Acorn"}});   
+
       s.close();
       conn.commit();
 
@@ -658,6 +676,12 @@
       		" NULLIF (CAST (TABLENAME AS CHAR(12)), 'c' ) = " +
 			" 'SYSCOLUMNS'",
       		new String[][] {{"SYSCOLUMNS"} });   
+
+      //Do some testing with MAX/MIN operators
+      checkLangBasedQuery(s, "SELECT MAX(NAME) maxName FROM CUSTOMER ORDER BY maxName ",
+      		new String[][] {{"\u017Bebra"}});   
+      checkLangBasedQuery(s, "SELECT MIN(NAME) minName FROM CUSTOMER ORDER BY minName ",
+      		new String[][] {{"aacorn"}});   
       
       s.close();
       conn.commit();



Mime
View raw message