Bug #28807 Mysql parse several blackslashes in "like" clause not correct!
Submitted: 31 May 2007 13:34 Modified: 30 Jun 2007 14:12
Reporter: zhou xiaowei Email Updates:
Status: No Feedback Impact on me:
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.41 OS:Any
Assigned to: CPU Architecture:Any

[31 May 2007 13:34] zhou xiaowei
the 2 sqls below get the same result.Is there sth wrong with mysql parse several blackslashes in "like" clause?

select * from myTable where name like '%\\\\\\%';    (5 blackslashes)

select * from myTable where name like '%\\\\\\\%';    (6 blackslashes)

How to repeat:
[31 May 2007 14:12] Valeriy Kravchuk
Thank you for a problem report. Please, send CREATE TABLE for your myTable and some data to demonstrate the problem. Read the manual, http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html, also:

"Note: Because MySQL uses C escape syntax in strings (for example, ‘\n’ to represent a newline character), you must double any ‘\’ that you use in LIKE strings. For example, to search for ‘\n’, specify it as ‘\\n’. To search for ‘\’, specify it as ‘\\\\’; this is because the backslashes are stripped once by the parser and again when the pattern match is made, leaving a single backslash to be matched against. (Exception: At the end of the pattern string, backslash can be specified as ‘\\’. At the end of the string, backslash stands for itself because there is nothing following to escape.)"

I hope it explains your results.
[1 Jul 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".