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/05 09:19:11 UTC

svn commit: r553399 - in /db/derby/code/branches/10.3/java: engine/org/apache/derby/catalog/types/ engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/iapi/types/ engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/fun...

Author: mamta
Date: Thu Jul  5 00:19:10 2007
New Revision: 553399

URL: http://svn.apache.org/viewvc?view=rev&rev=553399
Log:
Merging change 553395 from main codeline for DERBY-2793. The commit comments for that change were as follows

This method fixes LikeEscapeOperatorNode so that it will check the collation derivation too rather than only checking the
collation type. This fix will make sure that if one side of the LIKE operation has collation derivation of NONE and the
other side has collation derivation of IMPLICIT, then we should throw an exception.


Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/reference/Property.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java?view=diff&rev=553399&r1=553398&r2=553399
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java (original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/catalog/types/TypeDescriptorImpl.java Thu Jul  5 00:19:10 2007
@@ -416,9 +416,12 @@
 	}
 
 	/**
-	 * Gets the name of the collation type in this descriptor.
+	 * 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".
      * <p>
-     * Used to generate strings decribing collation type for error messages.
+     * 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.
@@ -426,9 +429,11 @@
 	public String getCollationName()
     {
         return(
-            collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC ? 
-                Property.UCS_BASIC_COLLATION : 
-                Property.TERRITORY_BASED_COLLATION);
+        		collationDerivation == StringDataValue.COLLATION_DERIVATION_NONE ?
+        				Property.COLLATION_NONE :
+        		collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC ?
+        				Property.UCS_BASIC_COLLATION :
+        				Property.TERRITORY_BASED_COLLATION);
     }
 
 	/**

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/reference/Property.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/reference/Property.java?view=diff&rev=553399&r1=553398&r2=553399
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/reference/Property.java (original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/reference/Property.java Thu Jul  5 00:19:10 2007
@@ -875,11 +875,16 @@
 	public static final String SERVICE_LOCALE = "derby.serviceLocale";
 
 	public static final String COLLATION = "derby.database.collation";
-	// These are the 2 possible values for collation
+	// These are the 2 possible values for collation type if the collation 
+	// derivation is not NONE. If collation derivation is NONE, then collation
+	// type should be ignored.
 	public static final String UCS_BASIC_COLLATION =
 								"UCS_BASIC";
 	public static final String TERRITORY_BASED_COLLATION =
 								"TERRITORY_BASED";
+	// Define a static string for collation derivation NONE
+	public static final String COLLATION_NONE =
+		"NONE";
 
     /**
      * db2j.storage.dataNotSyncedAtCheckPoint

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java?view=diff&rev=553399&r1=553398&r2=553399
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java (original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java Thu Jul  5 00:19:10 2007
@@ -488,7 +488,7 @@
 	 * If dealing with character string types, then make sure to set the
 	 * collation info on the dominant type. Following algorithm will be used 
 	 * for dominant DTD's collation determination. Each of the steps of the 
-	 * algorithem have been numbered in the comments below and those same 
+	 * algorithm have been numbered in the comments below and those same 
 	 * numbers are used in the actual algorithm below so it is easier to 
 	 * understand and maintain.
 	 * 

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java?view=diff&rev=553399&r1=553398&r2=553399
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java (original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java Thu Jul  5 00:19:10 2007
@@ -482,7 +482,7 @@
 				.getBuiltInTypeId(higherType), nullable, resultLength);
 
 		//Check if collation derivations and collation types of 2 operands
-		// match?
+		//match?
 		//If they do, then the result of the concatenation will get the smae
 		//collation information. But if not, then the collation derivation of
 		//the result will be NONE.

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java?view=diff&rev=553399&r1=553398&r2=553399
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java (original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java Thu Jul  5 00:19:10 2007
@@ -313,9 +313,13 @@
          *                collation types here.
          */
 
-        // The left and the pattern of the LIKE must be same collation type.
+        // The left and the pattern of the LIKE must be same collation type
+        // and derivation.
         if (receiver.getTypeServices().getCollationType() !=
-                leftOperand.getTypeServices().getCollationType())
+                leftOperand.getTypeServices().getCollationType() ||
+                receiver.getTypeServices().getCollationDerivation() !=
+                	leftOperand.getTypeServices().getCollationDerivation()
+                )
         {
             // throw error.
             throw StandardException.newException(

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java?view=diff&rev=553399&r1=553398&r2=553399
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java (original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java Thu Jul  5 00:19:10 2007
@@ -777,6 +777,17 @@
     ps = conn.prepareStatement("SELECT TABLENAME FROM SYS.SYSTABLES " +
     		" WHERE TABLENAME || ? LIKE 'SYSCOLUMNS'");   
     s.executeUpdate("set schema APP");
+    //The following will fail because the left hand side of LIKE has collation
+    //derivation of NONE where as the right hand side has collation derivation
+    //of IMPLICIT
+    assertStatementError("42ZA2", s, "SELECT TABLENAME FROM SYS.SYSTABLES " +
+    		" WHERE TABLENAME || 'AA' LIKE 'SYSCOLUMNS '");   
+    //To fix the problem, we can use CAST on the left hand side so it's 
+    //collation will be picked up from the compilation schema which is same as
+    //what happens for the right hand operand.
+    checkLangBasedQuery(s, "SELECT TABLENAME FROM SYS.SYSTABLES WHERE " +
+    		" CAST ((TABLENAME || 'AA') AS CHAR(12)) LIKE 'SYSCOLUMNS '",
+    		null );   
 
     //Do parameter testing for IS NULL
     //Following query will pass because it doesn't matter what the collation of