summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2005-09-07 16:32:15 +0500
committerunknown <bar@mysql.com>2005-09-07 16:32:15 +0500
commite8ba23fd0d1ca9b5f3a1366419f8351280b473bc (patch)
tree86be62125024f36215a902740ff80b67209bce8c /sql/item_cmpfunc.cc
parentd9732be25a2baaa8820f44598dec15e23bddc3cf (diff)
parent4fdf0ce3803f42d20681ed332888b16042b33f8f (diff)
downloadmariadb-git-e8ba23fd0d1ca9b5f3a1366419f8351280b473bc.tar.gz
Merge mysql.com:/usr/home/bar/mysql-4.1.b12611
into mysql.com:/usr/home/bar/mysql-5.0 mysql-test/r/ctype_utf8.result: Auto merged mysql-test/r/func_like.result: Auto merged mysql-test/t/ctype_utf8.test: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_cmpfunc.h: Auto merged
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc37
1 files changed, 36 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index cc2849ff7e6..31bfa9ba3b7 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2811,7 +2811,42 @@ bool Item_func_like::fix_fields(THD *thd, 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
+ {
+ /*
+ In the case of 8bit character set, we pass native
+ code instead of Unicode code as "escape" argument.
+ Convert to "cs" if charset of escape differs.
+ */
+ uint32 unused;
+ if (escape_str->needs_conversion(escape_str->length(),
+ escape_str->charset(), cs, &unused))
+ {
+ char ch;
+ uint errors;
+ uint32 cnvlen= copy_and_convert(&ch, 1, cs, escape_str->ptr(),
+ escape_str->length(),
+ escape_str->charset(), &errors);
+ escape= cnvlen ? ch : '\\';
+ }
+ else
+ escape= *(escape_str->ptr());
+ }
+ }
+ else
+ escape= '\\';
/*
We could also do boyer-more for non-const items, but as we would have to