db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-1231) LIKE does not match empty strings when used with a prepared statement
Date Tue, 05 Dec 2006 09:27:24 GMT
    [ http://issues.apache.org/jira/browse/DERBY-1231?page=comments#action_12455556 ] 
            
Knut Anders Hatlen commented on DERBY-1231:
-------------------------------------------

The patch looks correct to me. Some minor comments:

In lessThanString() the following is changed:

-		if (pattern.length() == 0)
+		if (pattern == null)
 		{
-			// pattern is ""
 			return null;
 		}

Couldn't the entire if be removed? If pattern could be null, we would have got a NullPointerException
here with the old code, so I don't think it ever will be null.

Some comments should be updated:
  - javadoc for lessThanString says: (NOTE: This may be null if the pattern is an empty string.)
  - a comment in lessThanString says:
		/* Find the last non-wildcard character in the pattern
		 * and increment it.  In the most common case,
		 * "asdf%" becomes "asdg".  However, we need to 
		 * handle the following:
		 *
		 *	pattern			return
		 *	-------			------
		 *	""				null
		 *	"%..."			SUPER_STRING (match against super string)
		 *	"_..."			SUPER_STRING (match against super string)
		 *	"asdf%"			"asdg"
		 */
       -> null should be replaced with SUPER_STRING
  - this comment in lessThanString should also be changed:
		// Pattern starts with wildcard.
		if (upperLimit.length() == 0) {
			return SUPER_STRING;
		}
       -- > Should say "Pattern is empty or starts with wildcard."

> LIKE does not match empty strings when used with a prepared statement
> ---------------------------------------------------------------------
>
>                 Key: DERBY-1231
>                 URL: http://issues.apache.org/jira/browse/DERBY-1231
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, SQL
>    Affects Versions: 10.2.1.6, 10.1.2.1, 10.3.0.0, 10.1.3.1
>            Reporter: Dyre Tjeldvoll
>         Assigned To: Bernt M. Johnsen
>             Fix For: 10.2.2.0
>
>         Attachments: DERBY-1231.diff, vti.java
>
>
> LIKE should give true for two 0-length strings. See SQL 2003 Ch. 8.5
> General Rules 3)c)i)
> The query SELECT * FROM t WHERE v like ''
> appears to give me all rows where v is an empty
> string, as expected.
> But a prepared statement
> SELECT * FROM t WHERE v like ?, with setString(1, "")
> always returns an empty result set. See attached repro for the full example.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message