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/20 18:17:04 UTC

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

Author: mamta
Date: Fri Jul 20 09:17:02 2007
New Revision: 558036

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

"select" query failed because we were generating SQLVarchar rather than CollatorSQLVarchar
create table alltypes (c char(10), v varchar(50)); 
insert into alltypes values ('duplicate', 'is duplicated'); 
select substr(c||v, 1, 4), count(*) from alltypes group by substr(c||v, 1, 4) ; 

To fix the problem, I needed to override StringDataValue getNewVarchar() in CollatorSQLVarchar. Without this new method, we were generating SQLVarchar in territory based databased when the collation type was territory based.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLVarchar.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/CollatorSQLVarchar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLVarchar.java?view=diff&rev=558036&r1=558035&r2=558036
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLVarchar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLVarchar.java Fri Jul 20 09:17:02 2007
@@ -120,6 +120,13 @@
 		return result;
 	}
 
+	protected StringDataValue getNewVarchar() throws StandardException
+	{
+		CollatorSQLVarchar result = new CollatorSQLVarchar(
+				holderForCollationSensitiveInfo.getCollatorForCollation());
+		return result;
+	}
+
 	/**
 	 * We do not anticipate this method on collation sensitive DVD to be
 	 * ever called in Derby 10.3 In future, when Derby will start supporting

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=558036&r1=558035&r2=558036
==============================================================================
--- 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 20 09:17:02 2007
@@ -967,6 +967,15 @@
     //incorrect exception about collation mismatch for the LIKE clause
     s.execute("CREATE TABLE DERBY_2955 (EMPNAME CHAR(20), CONSTRAINT " +
     		" STAFF9_EMPNAME CHECK (EMPNAME NOT LIKE 'T%'))");
+    
+    //DERBY-2960
+    //Following group by was failing earlier because we were generating
+    //SQLVarchar rather than CollatorSQLVarchar in territory based db 
+    s.execute("CREATE TABLE DERBY_2960 (C CHAR(10), V VARCHAR(50))");
+    s.execute("INSERT INTO DERBY_2960 VALUES ('duplicate', 'is duplicated')");
+    rs = s.executeQuery("SELECT SUBSTR(c||v, 1, 4), COUNT(*) FROM DERBY_2960" +
+    		" GROUP BY SUBSTR(c||v, 1, 4)");
+    JDBC.assertFullResultSet(rs,new String[][] {{"dupl","1"}});
 }
 
 private void setUpTable(Statement s) throws SQLException {