db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From be...@apache.org
Subject svn commit: r483042 - /db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/types/Like.java
Date Wed, 06 Dec 2006 11:45:19 GMT
Author: bernt
Date: Wed Dec  6 03:45:17 2006
New Revision: 483042

URL: http://svn.apache.org/viewvc?view=rev&rev=483042
Log:
DERBY-1231 Did svn merge -r 482982:482983 https://svn.apache.org/repos/asf/db/derby/code/trunk

Modified:
    db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/types/Like.java

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/types/Like.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/types/Like.java?view=diff&rev=483042&r1=483041&r2=483042
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/types/Like.java (original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/types/Like.java Wed Dec
 6 03:45:17 2006
@@ -668,7 +668,7 @@
 
 	/**
 	 * Determine whether or not this LIKE can be transformed into optimizable
-	 * clauses.  It can if the pattern is non-null, of length > 0 and
+	 * clauses.  It can if the pattern is non-null and if the length == 0 or
 	 * the first character is not a wild card.
 	 *
 	 * @param pattern	The right side of the LIKE
@@ -678,11 +678,15 @@
 
 	public static boolean isOptimizable(String pattern)
 	{
-		if (pattern == null || (pattern.length() == 0))
+		if (pattern == null)
 		{
 			return false;
 		}
 
+        if (pattern.length() == 0) {
+            return true;
+        }
+
 		// if we have pattern matching at start of string, no optimization
 		char firstChar = pattern.charAt(0);
 
@@ -871,7 +875,6 @@
 
 	/**
 	 * Return the substring from the pattern for the < clause.
-	 * (NOTE: This may be null if the pattern is an empty string.)
 	 *
 	 * @param pattern	The right side of the LIKE
 	 * @param escape	The escape clause
@@ -888,12 +891,6 @@
 		char	newLastChar;
 		final int escChar;
 
-		if (pattern.length() == 0)
-		{
-			// pattern is ""
-			return null;
-		}
-
 		if ((escape != null) && (escape.length() !=0))
 		{
 			escChar = escape.charAt(0);
@@ -911,7 +908,7 @@
 		 *
 		 *	pattern			return
 		 *	-------			------
-		 *	""				null
+		 *	""				SUPER_STRING (match against super string)
 		 *	"%..."			SUPER_STRING (match against super string)
 		 *	"_..."			SUPER_STRING (match against super string)
 		 *	"asdf%"			"asdg"
@@ -934,7 +931,7 @@
 			upperLimit.append(c);
 		}
 
-		// Pattern starts with wildcard.
+		// Pattern is empty or starts with wildcard.
 		if (upperLimit.length() == 0) {
 			return SUPER_STRING;
 		}



Mime
View raw message