diff options
author | bar@mysql.com <> | 2005-08-31 14:04:54 +0500 |
---|---|---|
committer | bar@mysql.com <> | 2005-08-31 14:04:54 +0500 |
commit | 5d8c5e799e11e33b6caebba5c0d3cf85bedd6c21 (patch) | |
tree | 4261d2df1536106002fda0ce69941a03f35b815e /sql | |
parent | b5c01d79716ff24c1b103085fe3287d29ad5dcb9 (diff) | |
download | mariadb-git-5d8c5e799e11e33b6caebba5c0d3cf85bedd6c21.tar.gz |
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
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_cmpfunc.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 9146b3c3b9e..c869e7f5c65 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2293,7 +2293,25 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) { /* 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 |