db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1585983 - in /db/derby/code/branches/10.9: ./ java/engine/org/apache/derby/impl/sql/compile/ java/engine/org/apache/derby/impl/sql/execute/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Wed, 09 Apr 2014 14:30:06 GMT
Author: mamta
Date: Wed Apr  9 14:30:06 2014
New Revision: 1585983

URL: http://svn.apache.org/r1585983
Log:
DERBY-6025(Wrong results with IN lists and indexes in territory based collation)

backporting to 10.9

Modified:
    db/derby/code/branches/10.9/   (props changed)
    db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
    db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/execute/BaseExpressionActivation.java
    db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java

Propchange: db/derby/code/branches/10.9/
------------------------------------------------------------------------------
  Merged /db/derby/code/branches/10.10:r1577421

Modified: db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java?rev=1585983&r1=1585982&r2=1585983&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
(original)
+++ db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
Wed Apr  9 14:30:06 2014
@@ -701,8 +701,20 @@ public final class InListOperatorNode ex
 		/* left side of the "in" operator is our "judge" when we try to get
 		 * the min/max value of the operands on the right side.  Judge's type
 		 * is important for us, and is input parameter to min/maxValue.
+		 * We found in DERBY-6025(Wrong results with IN lists and indexes in 
+		 * territory based collation) that we need to make sure that we also
+		 * left operand's collation information with Judge object. The reason
+		 * we are sending precision/scale etc along with type id and collation
+		 * information is that DataTypeDescriptor constructor requires all
+		 * those properties too along with the collation information.
 		 */
 		int leftTypeFormatId = leftOperand.getTypeId().getTypeFormatId();
+		int leftPrecision = leftOperand.getTypeServices().getPrecision();
+		int leftScale = leftOperand.getTypeServices().getScale();
+		boolean leftIsNullable = leftOperand.getTypeServices().isNullable();
+		int leftMaximumWidth = leftOperand.getTypeServices().getMaximumWidth();
+		int leftCollationType = leftOperand.getTypeServices().getCollationType();
+		int leftCollationDerivation = leftOperand.getTypeServices().getCollationDerivation();
 		int leftJDBCTypeId = leftOperand.getTypeId().isUserDefinedTypeId() ?
 								leftOperand.getTypeId().getJDBCTypeId() : -1;
 
@@ -752,6 +764,12 @@ public final class InListOperatorNode ex
 			 */
 			mb.push(leftTypeFormatId);
 			mb.push(leftJDBCTypeId);
+			mb.push(leftPrecision);
+			mb.push(leftScale);
+			mb.push(leftIsNullable);
+			mb.push(leftMaximumWidth);
+			mb.push(leftCollationType);
+			mb.push(leftCollationDerivation);
 
 			/* decide to get min or max value
 			 */
@@ -761,7 +779,7 @@ public final class InListOperatorNode ex
 			else
 				methodName = "maxValue";
 		
-			mb.callMethod(VMOpcode.INVOKESTATIC, ClassName.BaseExpressionActivation, methodName, ClassName.DataValueDescriptor,
6);
+			mb.callMethod(VMOpcode.INVOKESTATIC, ClassName.BaseExpressionActivation, methodName, ClassName.DataValueDescriptor,
12);
 
 		}
 	}

Modified: db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/execute/BaseExpressionActivation.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/execute/BaseExpressionActivation.java?rev=1585983&r1=1585982&r2=1585983&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/execute/BaseExpressionActivation.java
(original)
+++ db/derby/code/branches/10.9/java/engine/org/apache/derby/impl/sql/execute/BaseExpressionActivation.java
Wed Apr  9 14:30:06 2014
@@ -23,6 +23,7 @@ package org.apache.derby.impl.sql.execut
 
 import org.apache.derby.catalog.types.UserDefinedTypeIdImpl;
 import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.TypeId;
 
@@ -67,6 +68,12 @@ public abstract class BaseExpressionActi
 	 * @param judgeTypeFormatId		type format id of the judge
 	 * @param judgeUserJDBCTypeId	JDBC type id if judge is user type;
 	 *								-1 if not user type
+	 * @param judgePrecision		precision of the judge
+	 * @param judgeScale		    scale of the judge
+	 * @param judgeIsNullable		nullability of the judge
+	 * @param judgeMaximumWidth		maximum width of the judge
+	 * @param judgeCollationType	collation type of the judge
+	 * @param judgeCollationDerivation		collation derivation of the judge
 	 *
 	 * @return	The minimum value of the 4.
 	 */
@@ -75,12 +82,22 @@ public abstract class BaseExpressionActi
 											  DataValueDescriptor v3,
 											  DataValueDescriptor v4,
 											  int judgeTypeFormatId,
-											  int judgeUserJDBCTypeId)
+											  int judgeUserJDBCTypeId,
+											  int judgePrecision,
+											  int judgeScale,
+											  boolean judgeIsNullable,
+											  int judgeMaximumWidth,
+											  int judgeCollationType,
+											  int judgeCollationDerivation)
 										throws StandardException
 	{
 		DataValueDescriptor judge;
 		if (judgeUserJDBCTypeId == -1)
-			judge = (DataValueDescriptor) new TypeId(judgeTypeFormatId, null).getNull();
+			judge = new DataTypeDescriptor(
+        			new TypeId(judgeTypeFormatId, null),
+        			judgePrecision,judgeScale,judgeIsNullable,
+        			judgeMaximumWidth,judgeCollationType,
+        			judgeCollationDerivation).getNull();
 		else
 			judge = (DataValueDescriptor) new TypeId(judgeTypeFormatId, new UserDefinedTypeIdImpl()).getNull();
 			
@@ -120,6 +137,12 @@ public abstract class BaseExpressionActi
 	 * @param judgeTypeFormatId		type format id of the judge
 	 * @param judgeUserJDBCTypeId	JDBC type id if judge is user type;
 	 *								-1 if not user type
+	 * @param judgePrecision		precision of the judge
+	 * @param judgeScale		    scale of the judge
+	 * @param judgeIsNullable		nullability of the judge
+	 * @param judgeMaximumWidth		maximum width of the judge
+	 * @param judgeCollationType	collation type of the judge
+	 * @param judgeCollationDerivation		collation derivation of the judge
 	 *
 	 * @return	The maximum value of the 4.
 	 */
@@ -128,12 +151,22 @@ public abstract class BaseExpressionActi
 											  DataValueDescriptor v3,
 											  DataValueDescriptor v4,
 											  int judgeTypeFormatId,
-											  int judgeUserJDBCTypeId)
+											  int judgeUserJDBCTypeId,
+											  int judgePrecision,
+											  int judgeScale,
+											  boolean judgeIsNullable,
+											  int judgeMaximumWidth,
+											  int judgeCollationType,
+											  int judgeCollationDerivation)
 										throws StandardException
 	{
 		DataValueDescriptor judge;
 		if (judgeUserJDBCTypeId == -1)
-			judge =  new TypeId(judgeTypeFormatId, null).getNull();
+			judge = new DataTypeDescriptor(
+        			new TypeId(judgeTypeFormatId, null),
+        			judgePrecision,judgeScale,judgeIsNullable,
+        			judgeMaximumWidth,judgeCollationType,
+        			judgeCollationDerivation).getNull();
 		else
 			judge =  new TypeId(judgeTypeFormatId, new UserDefinedTypeIdImpl()).getNull();
 

Modified: db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java?rev=1585983&r1=1585982&r2=1585983&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
(original)
+++ db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
Wed Apr  9 14:30:06 2014
@@ -81,6 +81,7 @@ public class CollationTest extends BaseJ
     /** Test cases to run with Norwegian case-sensitive collation. */
     private final static String[] NORWEGIAN_CASE_SENSITIVE = {
         "testNorwayCollation",
+        "testInListNorwayCollation",
         "testLikeEscapeClauseLengthRestriction",
     };
 
@@ -437,6 +438,31 @@ public void testPolishCollation() throws
       commonTestingForTerritoryBasedDB(s);
     
       }    
+/**
+ * Test in list with constant and non constant elements & Norwegian collation
+ * DERBY-6025(Wrong results with IN lists and indexes in territory based 
+ *   collation)
+ */
+public void testInListNorwayCollation() throws SQLException {
+    Statement s = createStatement();
+    s.execute("CREATE TABLE derby6025_T1( c1 varchar(40) )");
+    s.executeUpdate("INSERT INTO derby6025_T1 VALUES" +
+    		"'Stranda Idrottslag', 'Aalesunds Fotballklubb'");
+    ResultSet rs = s.executeQuery("select * from derby6025_T1 where C1 in "+
+    		"('Aalesunds Fotballklubb', cast('xyz' as char(3)))");
+    JDBC.assertFullResultSet(rs,
+      		new String[][] {{"Aalesunds Fotballklubb"}});
+    
+    s.executeUpdate("create index i1 on derby6025_T1(c1)");
+    //After an index is created on column c1, following query returned 
+    // 0 rows without the fix for DERBY-6025. After DERBY-6025 is fixed, 
+    // it correctly returns 1 row.
+    rs = s.executeQuery("select * from derby6025_T1 where C1 in "+
+    		"('Aalesunds Fotballklubb', cast('xyz' as char(3)))");
+    JDBC.assertFullResultSet(rs,
+      		new String[][] {{"Aalesunds Fotballklubb"}});
+    s.execute("DROP TABLE derby6025_T1");	
+    }
   
 
   /**



Mime
View raw message