From: Date: August 31 2005 11:04am Subject: bk commit into 4.1 tree (bar:1.2399) BUG#12611 List-Archive: http://lists.mysql.com/internals/29086 X-Bug: 12611 Message-Id: <200508310904.j7V94x8Z024044@bar.intranet.mysql.r18.ru> Below is the list of changes that have just been committed into a local 4.1 repository of bar. When bar does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2399 05/08/31 14:04:54 bar@stripped +3 -0 Bug#12611: ESCAPE + LIKE do not work when the escape char is a multibyte one item_cmpfunc.cc: Pass unicode value as "escape" argument to my_wildcmp if a multibyte character set is used. For single byte character set nothing has changed: native (non-unicode) character code is still passed. ctype_utf8.result, ctype_utf8.test: adding test case mysql-test/r/ctype_utf8.result 1.64 05/08/31 14:01:25 bar@stripped +4 -0 adding test mysql-test/t/ctype_utf8.test 1.66 05/08/31 14:01:19 bar@stripped +6 -0 adding test sql/item_cmpfunc.cc 1.193 05/08/31 14:00:23 bar@stripped +19 -1 Bug#12611: ESCAPE + LIKE do not work when the escape char is a multibyte one Pass unicode code instead of native code as "escape" argument to my_wildcmp. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: bar # Host: bar.intranet.mysql.r18.ru # Root: /usr/home/bar/mysql-4.1 --- 1.192/sql/item_cmpfunc.cc 2005-08-09 04:46:50 +05:00 +++ 1.193/sql/item_cmpfunc.cc 2005-08-31 14:00:23 +05:00 @@ -2293,7 +2293,25 @@ { /* If we are on execution stage */ String *escape_str= escape_item->val_str(&tmp_value1); - escape= escape_str ? *(escape_str->ptr()) : '\\'; + if (escape_str) + { + CHARSET_INFO *cs= cmp.cmp_collation.collation; + if (use_mb(cs)) + { + my_wc_t wc; + int rc= cs->cset->mb_wc(cs, &wc, + (const uchar*) escape_str->ptr(), + (const uchar*) escape_str->ptr() + + escape_str->length()); + escape= (int) (rc > 0 ? wc : '\\'); + } + else + { + escape= *(escape_str->ptr()); + } + } + else + escape= '\\'; /* We could also do boyer-more for non-const items, but as we would have to --- 1.63/mysql-test/r/ctype_utf8.result 2005-08-29 16:48:25 +05:00 +++ 1.64/mysql-test/r/ctype_utf8.result 2005-08-31 14:01:25 +05:00 @@ -955,6 +955,10 @@ 2 4 ан drop table t1; set names utf8; +select 'andre%' like 'andreñ%' escape 'ñ'; +'andre%' like 'andreñ%' escape 'ñ' +1 +set names utf8; select 'a\\' like 'a\\'; 'a\\' like 'a\\' 1 --- 1.65/mysql-test/t/ctype_utf8.test 2005-08-29 16:48:16 +05:00 +++ 1.66/mysql-test/t/ctype_utf8.test 2005-08-31 14:01:19 +05:00 @@ -810,6 +810,12 @@ select char_length(a), length(a), a from t1 order by a; drop table t1; +# +# Bugs#12611 +# ESCAPE + LIKE do not work when the escape char is a multibyte one +# +set names utf8; +select 'andre%' like 'andreñ%' escape 'ñ'; # # Bugs#11754: SET NAMES utf8 followed by SELECT "A\\" LIKE "A\\" returns 0