[ 
https://issues.apache.org/jira/browse/DERBY-3166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539150
 ] 

Mamta A. Satoor commented on DERBY-3166:
----------------------------------------

Thanks for working on the documentation part of DERBY-2967. I hope following 
information will be useful to you

**********************************************************
The following applies to territory based database
For LIKE, when comparing a pattern against a value string, we do the comparison 
of collation elements(s) for one character at a time for non-metacharacters. 
This is different than what is done for = operation. For =, we compare the 
collation elements for the entire string on left hand with the collation 
elements of the entire string on the right hand side.
For eg say we are working with a territory where character 'z' has same 
collation elements as 'xy'. For such a territory consider 2 clauses in WHERE 
clause
1)'zcb' = 'xycb' 
2)'zcb' LIKE 'xy_b'
For case 1), we will return TRUE because the collation elements for the entire 
string 'zcb' will match the collation elements of the entire string 'xycb'.
For case 2) though, we will return FALSE because collation element(s) for 
character 'z' does not match the collation element(s) for character 'x'. So, as 
can be seen, the LIKE operation is one character at a time whereas = operation 
is the entire string at a time. 
In addition,  the metacharacter _ in pattern for LIKE will consume *one* 
character in the string value. So for an eg clause 'xycb' LIKE '_cb' will 
return FALSE because metacharacter _ will consume 'x' and since 'c' does not 
match 'y', we will return FALSE.
**********************************************************

**********************************************************
The following applies to UCS_BASIC database
Also, just to be clear, in a UCS_BASIC database, for all of the 3 cases above, 
we will return FALSE because the comparison in UCS_BASIC is based on code 
point. So for test cases 1 and 2, since the code point for 'z' does not match 
the code point for 'x', we will return FALSE. And for test case 3, 'x' will be 
consumed by '_' but the code point for 'y' does not match the code point for 
'c' and hence we will return FALSE.
**********************************************************

Hope this helps with your effort of documenting this.


> Update docs to address code improvments to LIKE (see Derby-2967)
> ----------------------------------------------------------------
>
>                 Key: DERBY-3166
>                 URL: https://issues.apache.org/jira/browse/DERBY-3166
>             Project: Derby
>          Issue Type: Bug
>          Components: Documentation
>            Reporter: Laura Stewart
>            Assignee: Laura Stewart
>
> Implement the required doc changes for collation to address the improvements 
> to the LIKE operator.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to