summaryrefslogtreecommitdiff
path: root/sql/strfunc.cc
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2004-12-06 20:45:32 +0400
committerunknown <bar@mysql.com>2004-12-06 20:45:32 +0400
commit8ec6cf2cd5ed54f1336784ffe548a813cbbde172 (patch)
treea397eb25eef58a660d9d2e554e7c8f8800bdb8f4 /sql/strfunc.cc
parent678fff408a8cd475555d3bbce3d77fd0a2c76a4a (diff)
downloadmariadb-git-8ec6cf2cd5ed54f1336784ffe548a813cbbde172.tar.gz
UCS2 support in ENUM and SET, which also fixes:
Bug #5174 SHOW CREATE TABLE hangs up if the table contains half-with katakana enum values UCS2 values are stored in HEX encoding in FRM file
Diffstat (limited to 'sql/strfunc.cc')
-rw-r--r--sql/strfunc.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index b5255e9be06..8ab6992a63a 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -53,8 +53,22 @@ ulonglong find_set(TYPELIB *lib, const char *str, uint length, CHARSET_INFO *cs,
{
const char *pos= start;
uint var_len;
+ int mblen= 1;
- for (; pos != end && *pos != field_separator; pos++) ;
+ if (cs && cs->mbminlen > 1)
+ {
+ for ( ; pos < end; pos+= mblen)
+ {
+ my_wc_t wc;
+ if ((mblen= cs->cset->mb_wc(cs, &wc, (const uchar *) pos,
+ (const uchar *) end)) < 1)
+ mblen= 1; // Not to hang on a wrong multibyte sequence
+ if (wc == (my_wc_t) field_separator)
+ break;
+ }
+ }
+ else
+ for (; pos != end && *pos != field_separator; pos++) ;
var_len= (uint) (pos - start);
uint find= cs ? find_type2(lib, start, var_len, cs) :
find_type(lib, start, var_len, (bool) 0);
@@ -66,9 +80,9 @@ ulonglong find_set(TYPELIB *lib, const char *str, uint length, CHARSET_INFO *cs,
}
else
found|= ((longlong) 1 << (find - 1));
- if (pos == end)
+ if (pos >= end)
break;
- start= pos + 1;
+ start= pos + mblen;
}
}
return found;