some comments on this commit:

[EMAIL PROTECTED] wrote:
Author: mamta
Date: Mon May 21 11:59:28 2007
New Revision: 540237

URL: http://svn.apache.org/viewvc?view=rev&rev=540237
Log:
DERBY-2599
Commiting patch DERBY2599_Set_collation_for_aggregates_v1_diff.txt attached to 
DERBY-2599. This patch sets correct collation type for
MAX and MIN aggregate functions. These 2 aggregate functions can return string 
datatype and this return datatype should take it's collation
from it's operand. It appears that these 2 functions can't be used in where clause but even then, I think they should have correct collation set on them.

Can the result of these functions be a column in a select list which then can be a column used in an order by?



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

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=540237&r1=540236&r2=540237
==============================================================================
--- 
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
 Mon May 21 11:59:28 2007
@@ -90,6 +90,39 @@
        }
/**
+        * 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.
Could you fix the above comment, I can't figure out what it is trying to say.
+        *
+        * @param typeId        The typeId of the type being described
+        * @param precision     The number of decimal digits.
+        * @param scale         The number of digits after the decimal point.
+        * @param isNullable    TRUE means it could contain NULL, FALSE means
+        *                      it definitely cannot contain NULL.
+        * @param maximumWidth  The maximum number of bytes for this datatype
+        * @param collationType The collation type of a string data type
+        * @param collationDerivation Collation Derivation of a string data type
+        */
+       public TypeDescriptorImpl(
+               BaseTypeIdImpl typeId,
+               int precision,
+               int scale,
+               boolean isNullable,
+               int maximumWidth,
+               int collationType,
+               int collationDerivation)
+       {
+               this.typeId = typeId;
+               this.precision = precision;
+               this.scale = scale;
+               this.isNullable = isNullable;
+               this.maximumWidth = maximumWidth;
+               this.collationType = collationType;
+               this.collationDerivation = collationDerivation;
+       }
+
+       /**
         * Constructor for use with non-numeric types
         *
         * @param typeId        The typeId of the type being described

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=540237&r1=540236&r2=540237
==============================================================================
--- 
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
 Mon May 21 11:59:28 2007
@@ -302,6 +302,35 @@
        }
/**
+        * 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.
Same as above comment.

+        *
+        * @param typeId        The typeId of the type being described
+        * @param precision     The number of decimal digits.
+        * @param scale         The number of digits after the decimal point.
+        * @param isNullable    TRUE means it could contain NULL, FALSE means
+        *                      it definitely cannot contain NULL.
+        * @param maximumWidth  The maximum number of bytes for this datatype
+        * @param collationType The collation type of a string data type
+        * @param collationDerivation Collation Derivation of a string data type
+        */
+       public DataTypeDescriptor(TypeId typeId, int precision, int scale,
+               boolean isNullable, int maximumWidth, int collationType,
+               int collationDerivation)
+       {
+               this.typeId = typeId;
+               typeDescriptor = new TypeDescriptorImpl(typeId.getBaseTypeId(),
+                                                                               
                precision,
+                                                                               
                scale,
+                                                                               
                isNullable,
+                                                                               
                maximumWidth,
+                                                                               
                collationType,
+                                                                               
                collationDerivation);
+       }
+
+       /**
         * Constructor for use with non-numeric types
         *
         * @param typeId        The typeId of the type being described

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=540237&r1=540236&r2=540237
==============================================================================
--- 
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
 Mon May 21 11:59:28 2007
@@ -409,7 +409,9 @@
                                                        
resultType.getPrecision(),
                                                        resultType.getScale(),
                                                        resultType.isNullable(),
-                                                       
resultType.getMaximumWidth()
+                                                       
resultType.getMaximumWidth(),
+                                                       
resultType.getCollationType(),
+                                                       
resultType.getCollationDerivation()
                                                )
                                );




Reply via email to