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/07/06 13:07:10 UTC

svn commit: r553834 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/DataTypeDescriptor.java testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java

Author: mamta
Date: Fri Jul  6 04:07:09 2007
New Revision: 553834

URL: http://svn.apache.org/viewvc?view=rev&rev=553834
Log:
DERBY-2725

If both the character string operands involved in DataTypeDescriptor.comparable() have collation derivation of NONE, then
such 2 DTDs can't be compared. I am adding code to implement that behavior and added a test case for this.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.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/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=553834&r1=553833&r2=553834
==============================================================================
--- 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 Jul  6 04:07:09 2007
@@ -1046,6 +1046,12 @@
     		//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()) {
+    			//both the operands can not have the collation derivation of 
+    			//NONE. This is because in that case, we do not know what kind 
+    			//of collation to use for comparison.
+    			if (getCollationDerivation() == compareWithDTD.getCollationDerivation() &&
+    					getCollationDerivation() == StringDataValue.COLLATION_DERIVATION_NONE)
+    				return false;
     			if (getCollationDerivation() == compareWithDTD.getCollationDerivation() &&
     					getCollationType() == compareWithDTD.getCollationType())
     				return true;//collation matches

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=553834&r1=553833&r2=553834
==============================================================================
--- 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 Fri Jul  6 04:07:09 2007
@@ -547,7 +547,11 @@
     checkLangBasedQuery(s, "SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
     		" CAST (TABLENAME || ' ' AS CHAR(12)) = " +
 			" 'SYSCOLUMNS '",
-    		new String[][] {{"SYSCOLUMNS"} });   
+    		new String[][] {{"SYSCOLUMNS"} });
+    //Following will fail because both sides of the = operator have collation
+    //derivation of NONE. DERBY-2725
+    assertStatementError("42818", s, "SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
+    		" TABLENAME || ' ' = TABLENAME || 'SYSCOLUMNS '");   
 
     //Do some testing using COALESCE
     //following will fail because result string of COALESCE has