diff options
author | unknown <bar@mysql.com> | 2004-08-13 15:04:10 +0500 |
---|---|---|
committer | unknown <bar@mysql.com> | 2004-08-13 15:04:10 +0500 |
commit | e2cfe7b60771610aff0d287ad243249099f4f629 (patch) | |
tree | 3aa503a2465a0a4b7cfb2777273d09a137837d96 /sql/item_strfunc.cc | |
parent | da60f1973db490601ca9b96efe7cd8d1a1517260 (diff) | |
download | mariadb-git-e2cfe7b60771610aff0d287ad243249099f4f629.tar.gz |
ctype_utf8.result, ctype_utf8.test, item_strfunc.cc:
LEFT() didn't work well in some cases.
sql/item_strfunc.cc:
LEFT() didn't work well in some cases.
mysql-test/t/ctype_utf8.test:
LEFT() didn't work well in some cases.
mysql-test/r/ctype_utf8.result:
LEFT() didn't work well in some cases.
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r-- | sql/item_strfunc.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 995627766c0..ecfeff02cac 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -977,17 +977,19 @@ String *Item_func_left::val_str(String *str) DBUG_ASSERT(fixed == 1); String *res =args[0]->val_str(str); long length =(long) args[1]->val_int(); + uint char_pos; if ((null_value=args[0]->null_value)) return 0; if (length <= 0) return &my_empty_string; - if (res->length() <= (uint) length) + if (res->length() <= (uint) length || + res->length() <= (char_pos= res->charpos(length))) return res; if (&str_value == res) - str_value.length(res->charpos(length)); + str_value.length(char_pos); else - str_value.set(*res, 0, res->charpos(length)); + str_value.set(*res, 0, char_pos); return &str_value; } |