db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r585261 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/lang/ testing/org/apache/derbyTesting/functionTests/tests/...
Date Tue, 16 Oct 2007 20:43:22 GMT
Author: mamta
Date: Tue Oct 16 13:43:21 2007
New Revision: 585261

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

Commiting the patch (DERBY2967_Oct11_07_diff.txt) attached to DERBY-2967. The implementation
of LIKE for UCS_BASIC and territory based character string types do not differ much(based
on SQL standard as explained in comments to 
this Jira entry). I have been able to change the existing code for LIKE (in Like.java) for
UCS_BASIC character strings to support territory based character strings. The existing method
in Like.java now gets a new parameter and it is RuleBasedCollator. For UCS_BASIC strings,
this will be passed as NULL. We check if the RuleBasedCollator is NULL and if so then we do
simple one character equality check for non-metacharacters in pattern and correspnding characters
in value string. But if RuleBasedCollator is not NULL, then we use it to get collation element(s)
for one character at a time for non-metacharacters in patterns and corresponding characters
in value string and do the collation element(s) comparison to establish equality. 

In addition to the above mentioned change in Like.java, I have changed the callers of the
method in Like.java to pass correct value for the RuleBasedCollator. 

Additionally, I have added a test to CollationTest.java for the code changes. Existing like
tests in CollationTest2.java were very useful in the testing of my changes. And lastly, I
changed few of the existing tests to use different character string values so that when we
run the full collation tests, we do not see some of the test failures which are genuine because
of the nature of their data. 


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/Like.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/WorkHorseForCollatorDatatypes.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dml068.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xts729.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DynamicLikeOptimizationTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StreamsTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/dml068.sql
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/xts729.sql
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/lang/T_Like.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/Like.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/Like.java?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/Like.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/Like.java Tue Oct 16 13:43:21
2007
@@ -53,6 +53,11 @@
 	}
 
 	/**
+	  
+	 This method gets called for UCS_BASIC and territory based character
+	 string types to look for a pattern in a value string. It also deals
+	 with escape character if user has provided one.
+	  
 		@param val value to compare. if null, result is null.
 		@param valLength length of val
 		@param pat pattern to compare. if null, result is null.
@@ -60,6 +65,10 @@
 		@param escape escape character. Must be 1 char long.
 			if null, no escape character is used.
 		@param escapeLength length of escape
+		@param collator null if we are dealing with UCS_BASIC 
+		    character string types. If not null, then we use it to 
+		    get collation elements for characters in val and 
+		    non-metacharacters in pat to do the comparison.
 
 		@return null if val or pat null, otherwise true if match
 		and false if not.
@@ -72,10 +81,12 @@
 		char[] 	pat, 
 		int 	patLength, 
 		char[] 	escape,
-		int 	escapeLength
+		int 	escapeLength,
+		RuleBasedCollator collator
 	) throws StandardException 
 	{
-		return like(val, 0, valLength, pat, 0, patLength, escape, escapeLength);
+		return like(val, 0, valLength, pat, 0, patLength, escape, 
+				escapeLength, collator);
 	}
 
 	/**
@@ -107,7 +118,8 @@
 		return like(val, 0, valLength, pat, 0, patLength, escape, escapeLength, collator);
 	}
 
-	/* non-national chars */
+	/* For character string types with UCS_BASIC and territory based
+	 * collation. There is a different method for non-national chars */
 	private static Boolean like
 	(
 		char[] 	val, 
@@ -117,7 +129,8 @@
 		int 	pLoc, 	// start at pat[pLoc]
 		int 	pEnd, 	// end at pat[pEnd]
 		char[] 	escape,
-		int 	escapeLength
+		int 	escapeLength,
+		RuleBasedCollator collator
 	) throws StandardException 
 	{
 		char escChar = ' ';
@@ -147,18 +160,14 @@
 			// go until we get a special char in the pattern or hit EOS
 			while (pat[pLoc] != anyChar && pat[pLoc] != anyString &&
 					((! haveEsc) || pat[pLoc] != escChar)) {
-				if (val[vLoc] == pat[pLoc]) 
-				{
+				if (checkEquality(val, vLoc, pat, pLoc, collator)) {
 					vLoc++; pLoc++;
-	
+					
 					result = checkLengths(vLoc, vEnd, pLoc, pat, pEnd);
 					if (result != null) 
 						return result;
-				}
-				else 
-				{
+				} else
 					return Boolean.FALSE;
-				}
 			}
 
 			// deal with escChar first, as it can be escaping a special char
@@ -174,7 +183,7 @@
 					throw StandardException.newException(SQLState.LANG_INVALID_ESCAPE_SEQUENCE);
 				}
 				// regardless of the char in pat, it must match exactly:
-				if (val[vLoc] == pat[pLoc]) {
+				if (checkEquality(val, vLoc, pat, pLoc, collator)) {
 					vLoc++; pLoc++;
 	
 					result = checkLengths(vLoc, vEnd, pLoc, pat, pEnd);
@@ -233,7 +242,8 @@
 				int minLen = getMinLen(pat, pLoc+1, pEnd, haveEsc, escChar);
 				for (int i=vRem; i>=minLen; i--) 
 				{
-					Boolean restResult = Like.like(val,vLoc+n,vLoc+n+i,pat,pLoc+1,pEnd,escape,escapeLength);
+					Boolean restResult = Like.like(val, vLoc+n, vLoc+n+i, pat,
+							pLoc+1, pEnd, escape, escapeLength, collator);
 					if (SanityManager.DEBUG)
 					{
 						if (restResult == null)
@@ -254,6 +264,60 @@
 		}
 	}
 
+	/**
+	 * Make sure that the character in val matches the character in pat.
+	 * If we are dealing with UCS_BASIC character string (ie collator is null)
+	 * then we can just do simple character equality check. But if we are
+	 * dealing with territory based character string type, then we need to 
+	 * convert the character in val and pat into it's collation element(s)
+	 * and then do collation element equality comparison.
+	 * 
+	 * @param val value to compare.
+	 * @param vLoc character position in val.
+	 * @param pat pattern to look for in val.
+	 * @param pLoc character position in pat.
+	 * @param collator null if we are dealing with UCS_BASIC character string
+	 * types. If not null, then we use it to get collation elements for 
+	 * character in val and pat to do the equality comparison.
+	 * @return
+	 */
+	private static boolean checkEquality(char[] val, int vLoc,
+			char[] pat, int pLoc, RuleBasedCollator collator) {
+		CollationElementIterator patternIterator;
+		int curCollationElementInPattern;
+		CollationElementIterator valueIterator;
+		int curCollationElementInValue;
+
+		if (collator == null) {//dealing with UCS_BASIC character string
+			if (val[vLoc] == pat[pLoc]) 
+				return true;
+			else 
+				return false;
+		} else {//dealing with territory based character string
+			patternIterator = collator.getCollationElementIterator(
+					new String(pat, pLoc, 1));
+			valueIterator = collator.getCollationElementIterator(
+					new String(val, vLoc, 1));
+			curCollationElementInPattern = patternIterator.next(); 
+			curCollationElementInValue = valueIterator.next();
+			while (curCollationElementInPattern == curCollationElementInValue)
+			{
+				if (curCollationElementInPattern == CollationElementIterator.NULLORDER)
+					break;
+				curCollationElementInPattern = patternIterator.next(); 
+				curCollationElementInValue = valueIterator.next(); 
+			}
+			//If the current collation element for the character in pattern 
+			//and value do not match, then we have found a mismatach and it
+			//is time to return FALSE from this method.
+			if (curCollationElementInPattern != curCollationElementInValue)
+				return false;
+			else
+				return true;
+		}
+		
+	}
+
 	/* national chars */
 	private static Boolean like
 	(
@@ -644,13 +708,17 @@
 		return true;
 	}
 
-
 	/*
-		Most typical interface for non-national chars
+		Most typical interface for character string types with UCS_BASIC and 
+		territory based collation. There is a different method for non-national 
+		chars.
 	 */
-	public static Boolean like(char[] value, int valueLength, char[] pattern, int patternLength)
throws StandardException { 
+	public static Boolean like(char[] value, int valueLength, char[] pattern, 
+			int patternLength, RuleBasedCollator collator) 
+	throws StandardException { 
 		if (value == null || pattern == null) return null;
-		return like(value, valueLength, pattern, patternLength, null, 0);
+		return like(value, valueLength, pattern, patternLength, null, 0, 
+				collator);
 	}
 
 	/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java Tue Oct 16 13:43:21
2007
@@ -1691,16 +1691,17 @@
 			likeResult = Like.like(evalCharArray, 
 								   getLength(),
  		    					   patternCharArray,
-								   pattern.getLength());
+								   pattern.getLength(),
+								   null);
 		}
 		else
 		{
 			SQLChar patternSQLChar = (SQLChar) pattern;
 			likeResult = Like.like(getIntArray(), 
-								   getIntLength(),
- 		    					   patternSQLChar.getIntArray(),
-								   patternSQLChar.getIntLength(),
-								   getLocaleFinder().getCollator());
+					getIntLength(), 
+					patternSQLChar.getIntArray(),
+					patternSQLChar.getIntLength(),
+					getLocaleFinder().getCollator());
 		}
 
 		return SQLBoolean.truthValue(this,
@@ -1774,7 +1775,8 @@
  		    					   patternCharArray,
 								   pattern.getLength(),
 								   escapeCharArray,
-								   escapeLength);
+								   escapeLength,
+								   null);
 		}
 		else
 		{
@@ -1788,13 +1790,13 @@
 				throw StandardException.newException(SQLState.LANG_INVALID_ESCAPE_CHARACTER,
 						new String(escapeSQLChar.getCharArray()));
 			}
-			likeResult = Like.like(getIntArray(), 
-								   getIntLength(),
- 		    					   patternSQLChar.getIntArray(),
-								   patternSQLChar.getIntLength(),
-								   escapeIntArray,
-								   escapeLength,
-								   getLocaleFinder().getCollator());
+			likeResult = Like.like(getIntArray(),
+					getIntLength(), 
+					patternSQLChar.getIntArray(),
+					patternSQLChar.getIntLength(),
+					escapeIntArray,
+					escapeLength,
+					getLocaleFinder().getCollator());
 		}
 
 		return SQLBoolean.truthValue(this,
@@ -2618,7 +2620,7 @@
 			return 0;
 		return tmpCKey.hashCode();
 	}
-
+	
 	private int[] getIntArray()
 		throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/WorkHorseForCollatorDatatypes.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/WorkHorseForCollatorDatatypes.java?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/WorkHorseForCollatorDatatypes.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/WorkHorseForCollatorDatatypes.java
Tue Oct 16 13:43:21 2007
@@ -125,15 +125,15 @@
 			SanityManager.ASSERT(
 				pattern instanceof CollationElementsInterface,
 				"Both the operands must be instances of CollationElementsInterface");
-		CollationElementsInterface patternToCheck = (CollationElementsInterface) pattern;
-		likeResult = Like.like(
-				getCollationElementsForString(),
-				getCountOfCollationElements(),
-				patternToCheck.getCollationElementsForString(),
-				patternToCheck.getCountOfCollationElements(),
+		likeResult = Like.like(stringData.getCharArray(), 
+				stringData.getLength(), 
+				((SQLChar)pattern).getCharArray(), 
+				pattern.getLength(), 
+				null, 
+				0,
 				collatorForCharacterDatatypes);
 
-		return SQLBoolean.truthValue(stringData,
+		return SQLBoolean.truthValue(stringData ,
 									 pattern,
 									 likeResult);
 	}
@@ -169,7 +169,6 @@
 			throw StandardException.newException(SQLState.LANG_ESCAPE_IS_NULL);
 		}
 
-		CollationElementsInterface patternToCheck = (CollationElementsInterface) pattern;
 		CollationElementsInterface escapeCharacter = (CollationElementsInterface) escape;
 
 		if (escapeCharacter.getCollationElementsForString() != null && 
@@ -178,13 +177,12 @@
 			throw StandardException.newException(SQLState.LANG_INVALID_ESCAPE_CHARACTER,
 					new String(escapeCharacter.toString()));
 		}
-		likeResult = Like.like(
-				getCollationElementsForString(),
-				getCountOfCollationElements(),
-				patternToCheck.getCollationElementsForString(),
-				patternToCheck.getCountOfCollationElements(),
-				escapeCharacter.getCollationElementsForString(),
-				escapeCharacter.getCountOfCollationElements(),
+		likeResult = Like.like(stringData.getCharArray(), 
+				stringData.getLength(), 
+				((SQLChar)pattern).getCharArray(), 
+				pattern.getLength(), 
+				((SQLChar)escape).getCharArray(), 
+				escape.getLength(),
 				collatorForCharacterDatatypes);
 
 		return SQLBoolean.truthValue(stringData,

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dml068.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dml068.out?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dml068.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dml068.out
Tue Oct 16 13:43:21 2007
@@ -51,7 +51,7 @@
 1 row inserted/updated/deleted
 ij> INSERT INTO AA VALUES('*ast');
 1 row inserted/updated/deleted
-ij> INSERT INTO AA VALUES('aaaa');
+ij> INSERT INTO AA VALUES('bbbb');
 1 row inserted/updated/deleted
 ij> INSERT INTO AA VALUES(':col');
 1 row inserted/updated/deleted
@@ -93,7 +93,7 @@
 1 row inserted/updated/deleted
 ij> INSERT INTO AA VALUES('_und');
 1 row inserted/updated/deleted
-ij> INSERT INTO AA VALUES('AAAA');
+ij> INSERT INTO AA VALUES('BBBB');
 1 row inserted/updated/deleted
 ij> INSERT INTO AA VALUES('0000');
 1 row inserted/updated/deleted
@@ -134,7 +134,7 @@
 > gt                
 ?que                
 @ at                
-AAAA                
+BBBB                
 ZZZZ                
 [lbk                
 \bsl                
@@ -142,7 +142,7 @@
 ^hat                
 _und                
 `-qt                
-aaaa                
+bbbb                
 zzzz                
 {lbc                
 |dvt                
@@ -171,7 +171,7 @@
 (lpr                
 )rpr                
 *ast                
-aaaa                
+bbbb                
 :col                
 +plu                
 ;sem                
@@ -192,7 +192,7 @@
 / sl                
 ?que                
 _und                
-AAAA                
+BBBB                
 0000                
 9999                
 zzzz                

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xts729.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xts729.out?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xts729.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xts729.out
Tue Oct 16 13:43:21 2007
@@ -72,7 +72,7 @@
    COMMIT WORK;
 ij> --O   INSERT INTO CTS1.TESTB6439
    INSERT INTO TESTB6439
-         VALUES('AA','BB',1,2);
+         VALUES('AB','BB',1,2);
 1 row inserted/updated/deleted
 ij> -- PASS:7029 If 1 row inserted successfully?
 
@@ -105,14 +105,14 @@
           ORDER BY cOlUmNoFNUMERIC123456789012_0;
 COL&|COL&|COLUM&|COLUM&
 -----------------------
-AA  |BB  |1     |2     
+AB  |BB  |1     |2     
 CC  |DD  |3     |4     
 EE  |FF  |5     |6     
 GG  |HH  |7     |8     
 II  |KK  |9     |0     
 ij> -- PASS:7029 If 5 rows selected in the following order?
 --                    ===  ===  === ===
--- PASS:7029   If      AA   BB   1   2?
+-- PASS:7029   If      AB   BB   1   2?
 -- PASS:7029   If      CC   DD   3   4?
 -- PASS:7029   If      EE   FF   5   6?
 -- PASS:7029   If      GG   HH   7   8?
@@ -187,7 +187,7 @@
    COMMIT WORK;
 ij> --O   INSERT INTO CTS1.TESTC6439
    INSERT INTO TESTC6439
-         VALUES('aaa','bbb');
+         VALUES('aba','bbb');
 1 row inserted/updated/deleted
 ij> -- PASS:7029 If 1 row inserted successfully?
 
@@ -208,12 +208,12 @@
          ORDER BY COLUMNOFCHARACTERSA;
 COL&|COL&
 ---------
-aaa |bbb 
+aba |bbb 
 ccc |ddd 
 eee |fff 
 ij> -- PASS:7029 If 3 rows selected in the following order?
 --                 ===    ===
--- PASS:7029 If    aaa    bbb?
+-- PASS:7029 If    aba    bbb?
 -- PASS:7029 If    ccc    ddd?
 -- PASS:7029 If    eee    fff? 
 

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?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- 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
Tue Oct 16 13:43:21 2007
@@ -252,13 +252,13 @@
       //End of parameter testing
       
       s.close();
-      compareAgrave(conn,1);
+      compareAgrave(conn,1,1);
       }
       
 
 public void testFrenchCollation() throws SQLException {
     Connection conn = getConnection();
-    compareAgrave(conn,2);    
+    compareAgrave(conn,2,1);    
 }
 
 
@@ -273,7 +273,8 @@
  * @param expectedMatchCount  number of rows we expect back. 2 for french, 1 for English

  * @throws SQLException
  */
-private void compareAgrave(Connection conn, int expectedMatchCount) throws SQLException {
+private void compareAgrave(Connection conn, int expectedMatchCountForEqual,
+		int expectedMatchCountForLike) throws SQLException {
       
       String agrave = "\u00C0";
       String agraveCombined ="A\u0300";
@@ -293,11 +294,11 @@
       ps = conn.prepareStatement("SELECT COUNT(*) FROM T WHERE VC = ?");
       ps.setString(1, agrave);
       ResultSet rs = ps.executeQuery();
-      JDBC.assertSingleValueResultSet(rs, Integer.toString(expectedMatchCount));
+      JDBC.assertSingleValueResultSet(rs, Integer.toString(expectedMatchCountForEqual));
       ps = conn.prepareStatement("SELECT COUNT(*) FROM T WHERE VC LIKE ?");
       ps.setString(1, agrave);
       rs = ps.executeQuery();
-      JDBC.assertSingleValueResultSet(rs, Integer.toString(expectedMatchCount));
+      JDBC.assertSingleValueResultSet(rs, Integer.toString(expectedMatchCountForLike));
       rs.close();
       ps.close();
       s.close();
@@ -1044,6 +1045,19 @@
     s.execute("ALTER TABLE DERBY_2973 ALTER V SET DATA TYPE VARCHAR(4096)");
     s.execute("INSERT INTO DERBY_2973 VALUES('hello')");
     
+    //DERBY-2967
+    //The special character _ should match one character and not just advance
+    //by number of collation elements that special character _ represents
+    s.executeUpdate("create table DERBY_2967(c11 int)"); 
+    s.executeUpdate("insert into DERBY_2967 values 1"); 
+    ps = conn.prepareStatement("select 1 from DERBY_2967 where '\uFA2D' like ?");
+    String[] match = { "%", "_", "\uFA2D" }; 
+    for (int i = 0; i < match.length; i++) { 
+        ps.setString(1, match[i]); 
+        rs = ps.executeQuery(); 
+        JDBC.assertFullResultSet(rs,new String[][] {{"1"}});
+    }
+
     //DERBY-2961
     //Should generate collation sensitive data type when working with something
     //like V AS CLOB insdie XMLSERIALIZE as shown below 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
Tue Oct 16 13:43:21 2007
@@ -321,11 +321,11 @@
     private static final int[] NORWAY_LIKE_RESULT =
     {
         0,
-        0,
+        -1,
         9,
-        9,
-        8,
+        -1,
         8,
+        -1,
         8,
         10
     };
@@ -1797,6 +1797,7 @@
           {"\u00ADa"}, 
           {"ekstra\u00ADarbeid"}, 
           {"ekstrabetaling"}, 
+          {"ekstraarbeid"}, 
           {"Wanvik"}, 
           {"W\u00E5gan"},
           {"Waagan"}, 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DynamicLikeOptimizationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DynamicLikeOptimizationTest.java?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DynamicLikeOptimizationTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DynamicLikeOptimizationTest.java
Tue Oct 16 13:43:21 2007
@@ -530,6 +530,15 @@
      */
     public void testDynamicLikeOptimization() throws SQLException {
         Statement s = createStatement();
+        ResultSet rs = s.executeQuery( 
+          		"VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('derby.database.collation')");
+        if (rs.next()){
+        	if (rs.getString(1).equals("TERRITORY_BASED")) {
+        		rs.close();
+        		s.close();
+        		return;
+        	}
+        }
         s.execute("CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1)");
         PreparedStatement ps =
             prepareStatement("select id from test where vc10 like ?");

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StreamsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StreamsTest.java?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StreamsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/StreamsTest.java
Tue Oct 16 13:43:21 2007
@@ -156,16 +156,16 @@
         s.executeUpdate("insert into t4 values (1, 'ccccc')");
         ps = prepareStatement("insert into t4 values(?, ?)");
         insertLongString(ps, 6, false);
-        s.executeUpdate("insert into t4 values (3, 'aaaaabbbbbb')");
+        s.executeUpdate("insert into t4 values (3, 'abbb')");
         s.executeUpdate("insert into t4 values (4, 'bbbbbb')");
         insertLongString(ps, 5, false);
         ps.close();
         ResultSet rs = s
         .executeQuery("select id, cast(longcol as varchar(8192)) lcol from t4 order by lcol");
         
-        assertTrue(rs.next()); // 3, aaaaabbbbbb
+        assertTrue(rs.next()); // 3, abbb
         assertEquals(3, rs.getInt(1));
-        assertEquals("aaaaabbbbbb", rs.getString(2));
+        assertEquals("abbb", rs.getString(2));
         
         assertTrue(rs.next()); // 4, bbbbbb
         assertEquals(4, rs.getInt(1));

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/dml068.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/dml068.sql?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/dml068.sql
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/dml068.sql
Tue Oct 16 13:43:21 2007
@@ -35,7 +35,7 @@
      INSERT INTO AA VALUES('(lpr');
      INSERT INTO AA VALUES(')rpr');
      INSERT INTO AA VALUES('*ast');
-     INSERT INTO AA VALUES('aaaa');
+     INSERT INTO AA VALUES('bbbb');
      INSERT INTO AA VALUES(':col');
      INSERT INTO AA VALUES('+plu');
      INSERT INTO AA VALUES(';sem');
@@ -56,7 +56,7 @@
      INSERT INTO AA VALUES('/ sl');
      INSERT INTO AA VALUES('?que');
      INSERT INTO AA VALUES('_und');
-     INSERT INTO AA VALUES('AAAA');
+     INSERT INTO AA VALUES('BBBB');
      INSERT INTO AA VALUES('0000');
      INSERT INTO AA VALUES('9999');
      INSERT INTO AA VALUES('zzzz');

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/xts729.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/xts729.sql?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/xts729.sql
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/xts729.sql
Tue Oct 16 13:43:21 2007
@@ -69,7 +69,7 @@
 
 --O   INSERT INTO CTS1.TESTB6439
    INSERT INTO TESTB6439
-         VALUES('AA','BB',1,2);
+         VALUES('AB','BB',1,2);
 -- PASS:7029 If 1 row inserted successfully?
 
 --O   INSERT INTO CTS1.TESTB6439
@@ -97,7 +97,7 @@
           ORDER BY cOlUmNoFNUMERIC123456789012_0;
 -- PASS:7029 If 5 rows selected in the following order?
 --                    ===  ===  === ===
--- PASS:7029   If      AA   BB   1   2?
+-- PASS:7029   If      AB   BB   1   2?
 -- PASS:7029   If      CC   DD   3   4?
 -- PASS:7029   If      EE   FF   5   6?
 -- PASS:7029   If      GG   HH   7   8?
@@ -170,7 +170,7 @@
 
 --O   INSERT INTO CTS1.TESTC6439
    INSERT INTO TESTC6439
-         VALUES('aaa','bbb');
+         VALUES('aba','bbb');
 -- PASS:7029 If 1 row inserted successfully?
 
 --O   INSERT INTO CTS1.TESTC6439
@@ -188,7 +188,7 @@
          ORDER BY COLUMNOFCHARACTERSA;
 -- PASS:7029 If 3 rows selected in the following order?
 --                 ===    ===
--- PASS:7029 If    aaa    bbb?
+-- PASS:7029 If    aba    bbb?
 -- PASS:7029 If    ccc    ddd?
 -- PASS:7029 If    eee    fff? 
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/lang/T_Like.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/lang/T_Like.java?rev=585261&r1=585260&r2=585261&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/lang/T_Like.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/lang/T_Like.java Tue
Oct 16 13:43:21 2007
@@ -107,15 +107,15 @@
 
 		REPORT("testing null combinations...");
 		try {
-		expect("null like null escape null", Like.like(caNull, 0, caNull, 0, caNull, 0), null);
-		expect("null like 'hello' escape null", Like.like(caNull, 0, caHello, caHello.length, caNull,
0), null);
-		expect("'hello' like null escape null", Like.like(caHello, caHello.length, caNull, 0, caNull,
0), null);
-		expect("null like null escape '\\'", Like.like(caNull, 0, caNull, 0, "\\".toCharArray(),
"\\".toCharArray().length), null);
+		expect("null like null escape null", Like.like(caNull, 0, caNull, 0, caNull, 0, null),
null);
+		expect("null like 'hello' escape null", Like.like(caNull, 0, caHello, caHello.length, caNull,
0, null), null);
+		expect("'hello' like null escape null", Like.like(caHello, caHello.length, caNull, 0, caNull,
0, null), null);
+		expect("null like null escape '\\'", Like.like(caNull, 0, caNull, 0, "\\".toCharArray(),
"\\".toCharArray().length, null), null);
 
 		// gets back a null before it evaluates the escape
-		expect("null like null escape 'hello'", Like.like(caNull, 0, caNull, 0, caHello, caHello.length),
null);
+		expect("null like null escape 'hello'", Like.like(caNull, 0, caNull, 0, caHello, caHello.length,
null), null);
 		// gets back a null before it evaluates the pattern
-		expect("null like 'hello\\' escape '\\'", Like.like(caNull, 0, "hello\\".toCharArray(),
"hello\\".toCharArray().length, "\\".toCharArray(), "\\".toCharArray().length), null);
+		expect("null like 'hello\\' escape '\\'", Like.like(caNull, 0, "hello\\".toCharArray(),
"hello\\".toCharArray().length, "\\".toCharArray(), "\\".toCharArray().length, null), null);
 
 		} catch(StandardException leOuter1) {
 			leOuter1.printStackTrace();
@@ -124,21 +124,21 @@
 
 		REPORT("testing valid match cases...");
 		try {
-		expect("'hello' like 'hello' escape null", Like.like(caHello, caHello.length, caHello,
caHello.length, caNull, 0), Boolean.TRUE);
-		expect("'hello' like 'h_llo' escape null", Like.like(caHello, caHello.length, "h_llo".toCharArray(),
"h_llo".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'hello' like '_ello' escape null", Like.like(caHello, caHello.length, "_ello".toCharArray(),
"_ello".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'hello' like 'hell_' escape null", Like.like(caHello, caHello.length, "hell_".toCharArray(),
"hell_".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'hello' like '_____' escape null", Like.like(caHello, caHello.length, "_____".toCharArray(),
"_____".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'hello' like 'h___e' escape null", Like.like(caHello, caHello.length, "h___o".toCharArray(),
"h___o".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'h' like 'h' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"h".toCharArray(), "h".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'h' like '_' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"_".toCharArray(), "_".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'h' like '%' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"%".toCharArray(), "%".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'h' like '_%' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"_%".toCharArray(), "_%".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'h' like '%_' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"%_".toCharArray(), "%_".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'h' like '%' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"%".toCharArray(), "%".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'' like '%' escape null", Like.like("".toCharArray(), "".toCharArray().length,
"%".toCharArray(), "%".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'' like '%%' escape null", Like.like("".toCharArray(), "".toCharArray().length,
"%%".toCharArray(), "%%".toCharArray().length, caNull, 0), Boolean.TRUE);
-		expect("'' like '%%%' escape null", Like.like("".toCharArray(), "".toCharArray().length,
"%%%".toCharArray(), "%%%".toCharArray().length, caNull, 0), Boolean.TRUE);
+		expect("'hello' like 'hello' escape null", Like.like(caHello, caHello.length, caHello,
caHello.length, caNull, 0, null), Boolean.TRUE);
+		expect("'hello' like 'h_llo' escape null", Like.like(caHello, caHello.length, "h_llo".toCharArray(),
"h_llo".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'hello' like '_ello' escape null", Like.like(caHello, caHello.length, "_ello".toCharArray(),
"_ello".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'hello' like 'hell_' escape null", Like.like(caHello, caHello.length, "hell_".toCharArray(),
"hell_".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'hello' like '_____' escape null", Like.like(caHello, caHello.length, "_____".toCharArray(),
"_____".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'hello' like 'h___e' escape null", Like.like(caHello, caHello.length, "h___o".toCharArray(),
"h___o".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'h' like 'h' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"h".toCharArray(), "h".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'h' like '_' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"_".toCharArray(), "_".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'h' like '%' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"%".toCharArray(), "%".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'h' like '_%' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"_%".toCharArray(), "_%".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'h' like '%_' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"%_".toCharArray(), "%_".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'h' like '%' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"%".toCharArray(), "%".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'' like '%' escape null", Like.like("".toCharArray(), "".toCharArray().length,
"%".toCharArray(), "%".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'' like '%%' escape null", Like.like("".toCharArray(), "".toCharArray().length,
"%%".toCharArray(), "%%".toCharArray().length, caNull, 0, null), Boolean.TRUE);
+		expect("'' like '%%%' escape null", Like.like("".toCharArray(), "".toCharArray().length,
"%%%".toCharArray(), "%%%".toCharArray().length, caNull, 0, null), Boolean.TRUE);
 		} catch(StandardException leOuter2) {
 			leOuter2.printStackTrace();
 			FAIL("unexpected exception");
@@ -146,15 +146,15 @@
 
 		REPORT("testing valid nonmatch cases...");
 		try {
-		expect("'hello' like 'hello ' escape null", Like.like(caHello, caHello.length, "hello ".toCharArray(),
"hello ".toCharArray().length, caNull, 0), Boolean.FALSE);
-		expect("'hello ' like 'hello' escape null", Like.like("hello ".toCharArray(), "hello ".toCharArray().length,
caHello, caHello.length, caNull, 0), Boolean.FALSE);
-		expect("'hello' like 'hellox' escape null", Like.like(caHello, caHello.length, "hellox".toCharArray(),
"hellox".toCharArray().length, caNull, 0), Boolean.FALSE);
-		expect("'hellox' like 'hello' escape null", Like.like("hellox".toCharArray(), "hellox".toCharArray().length,
caHello, caHello.length, caNull, 0), Boolean.FALSE);
-		expect("'xhellox' like 'hello' escape null", Like.like("xhellox".toCharArray(), "xhellox".toCharArray().length,
caHello, caHello.length, caNull, 0), Boolean.FALSE);
-		expect("'hello' like 'xhellox' escape null", Like.like(caHello, caHello.length, "xhellox".toCharArray(),
"xhellox".toCharArray().length, null, 0), Boolean.FALSE);
-		expect("'hello' like 'h___' escape null", Like.like(caHello, caHello.length, "h___".toCharArray(),
"h___".toCharArray().length, caNull, 0), Boolean.FALSE);
-		expect("'h' like '_%_' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"_%_".toCharArray(), "_%_".toCharArray().length, caNull, 0), Boolean.FALSE);
-		expect("'' like '_' escape null", Like.like("".toCharArray(), "".toCharArray().length,
"_".toCharArray(), "_".toCharArray().length, caNull, 0), Boolean.FALSE);
+		expect("'hello' like 'hello ' escape null", Like.like(caHello, caHello.length, "hello ".toCharArray(),
"hello ".toCharArray().length, caNull, 0, null), Boolean.FALSE);
+		expect("'hello ' like 'hello' escape null", Like.like("hello ".toCharArray(), "hello ".toCharArray().length,
caHello, caHello.length, caNull, 0, null), Boolean.FALSE);
+		expect("'hello' like 'hellox' escape null", Like.like(caHello, caHello.length, "hellox".toCharArray(),
"hellox".toCharArray().length, caNull, 0, null), Boolean.FALSE);
+		expect("'hellox' like 'hello' escape null", Like.like("hellox".toCharArray(), "hellox".toCharArray().length,
caHello, caHello.length, caNull, 0, null), Boolean.FALSE);
+		expect("'xhellox' like 'hello' escape null", Like.like("xhellox".toCharArray(), "xhellox".toCharArray().length,
caHello, caHello.length, caNull, 0, null), Boolean.FALSE);
+		expect("'hello' like 'xhellox' escape null", Like.like(caHello, caHello.length, "xhellox".toCharArray(),
"xhellox".toCharArray().length, null, 0, null), Boolean.FALSE);
+		expect("'hello' like 'h___' escape null", Like.like(caHello, caHello.length, "h___".toCharArray(),
"h___".toCharArray().length, caNull, 0, null), Boolean.FALSE);
+		expect("'h' like '_%_' escape null", Like.like("h".toCharArray(), "h".toCharArray().length,
"_%_".toCharArray(), "_%_".toCharArray().length, caNull, 0, null), Boolean.FALSE);
+		expect("'' like '_' escape null", Like.like("".toCharArray(), "".toCharArray().length,
"_".toCharArray(), "_".toCharArray().length, caNull, 0, null), Boolean.FALSE);
 		} catch(StandardException leOuter3) {
 			leOuter3.printStackTrace();
 			FAIL("unexpected exception");
@@ -166,7 +166,7 @@
 			msg = null;
 			gotLE=false;
 			desc="null like null escape 'hello'";
-			t=Like.like(caHello, caHello.length, caHello, caHello.length, caHello, caHello.length);
+			t=Like.like(caHello, caHello.length, caHello, caHello.length, caHello, caHello.length,
null);
 		} catch (StandardException le) {
 			gotLE=true;
 			msg = le.getMessage();
@@ -181,7 +181,7 @@
 			msg = null;
 			gotLE=false;
 			desc="'hello' like 'hhh' escape 'h'";
-			t=Like.like(caHello, caHello.length, "hhh".toCharArray(), "hhh".toCharArray().length,
"h".toCharArray(), "h".toCharArray().length);
+			t=Like.like(caHello, caHello.length, "hhh".toCharArray(), "hhh".toCharArray().length,
"h".toCharArray(), "h".toCharArray().length, null);
 		} catch (StandardException le) {
 			gotLE=true;
 			msg = le.getMessage();
@@ -196,7 +196,7 @@
 			msg = null;
 			gotLE=false;
 			desc="'hello' like 'he%' escape 'h'";
-			t=Like.like(caHello, caHello.length, "he%".toCharArray(), "he%".toCharArray().length,
"h".toCharArray(), "h".toCharArray().length);
+			t=Like.like(caHello, caHello.length, "he%".toCharArray(), "he%".toCharArray().length,
"h".toCharArray(), "h".toCharArray().length, null);
 		} catch (StandardException le) {
 			gotLE=true;
 			msg = le.getMessage();



Mime
View raw message