|
[
Permlink
| « Hide
]
Dyre Tjeldvoll added a comment - 20/Apr/06 06:06 PM
Attaching vti.java which is a simple repro for the problem (the name vti is not meaningful).
Simple fix to Like.lessThanString. It should not return null when the pattern has zero length, but proceed to the comparision logic.
Another small issue caught while studying the logic of this. Like.isOptimizable should return true if the pattern has zero length. Slight optimization if the user does a lot of blabla LIKE '' QUESTION: Is the tweak in the second last line in metadata.properties: AND (V."COLUMN_NAME" LIKE ? OR V."COLUMN_NAME" = ?) \ a consequence of this bug and could now be changed to AND V."COLUMN_NAME" LIKE ? \ is part of this fix? Thanks for looking at this Bernt! :) Patch looks good to me. +1 to commit.
Wrt, your question above: Yes, I think the tweak in metadata.properties was to added as a workaround for this bug. It was added in revision 395414 which was Rick Hillegas' checkin of the work I did on 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." Dyre wrote:
> I'll let you figure out if it is safe to change metadata.properties now, or if that could cause problems during upgrade It is safe to make this change to metadata.properties on trunk. However, it is not safe to make this change on the 10.2 branch. If one creates a database with Derby 10.2.X.Y which includes that change, the query will not work correctly if one moves back to 10.2.1.6 which doesn't include the change. Thanks Knut! lessThanString will never be called with pattern==null since null is not allowed as a literal for pattern. When using a parameter, null is allowed, but the check is done in lessThanStringFromParameter and lessThanStringFromParameterWithEsc before lessThanString is called. I'l incorporate the comments in the patch.
Dyre: You're right. I'll create an separate issue for a change to metadata.properties that should NOT be ported to the 10.2 branch. New version. Ready for commit.
Looks good, +1 to commit. You could also remove "NOTE: This may be null if the pattern is an empty string." from lessThanString's javadoc before you commit.
Thanks Knut. Here's the final patch
Committed revision 482983.
Committed revision 483042.
This issue has been resolved for over a year with no further movement. Closing.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||