diff options
author | unknown <gluh@mysql.com/eagle.(none)> | 2007-10-11 16:07:10 +0500 |
---|---|---|
committer | unknown <gluh@mysql.com/eagle.(none)> | 2007-10-11 16:07:10 +0500 |
commit | f30eacb223f581ece4bce02b3c4dfac1310f9f72 (patch) | |
tree | 8789a2b0f9db5501bfb30bb5adfb6ccb9efeb7ef /sql/item_strfunc.cc | |
parent | 6146c0c75d013b15ea2c6656ee0d774498734fd2 (diff) | |
download | mariadb-git-f30eacb223f581ece4bce02b3c4dfac1310f9f72.tar.gz |
Bug#30981 CHAR(0x41 USING ucs2) doesn't add leading zero
Bug#30982 CHAR(..USING..) can return a not-well-formed string
Bug#30986 Character set introducer followed by a HEX string can return bad result
check_well_formed_result moved to Item from Item_str_func
fixed Item_func_char::val_str for proper ucs symbols converting
added check for well formed strings for correct conversion of constants with underscore
charset
mysql-test/r/ctype_ucs.result:
test result
mysql-test/r/ctype_utf8.result:
test result
mysql-test/t/ctype_ucs.test:
test case
mysql-test/t/ctype_utf8.test:
test case
sql/item.cc:
check_well_formed_result() moved from Item_str_func
sql/item.h:
check_well_formed_result() moved from Item_str_func
sql/item_strfunc.cc:
check_well_formed_result moved to Item
fixed Item_func_char::val_str for proper ucs symbols converting
sql/item_strfunc.h:
check_well_formed_result moved to Item
sql/sql_yacc.yy:
added check for well formed string
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r-- | sql/item_strfunc.cc | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 0c11c9eece8..4e72f117869 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -38,36 +38,6 @@ C_MODE_END String my_empty_string("",default_charset_info); -String *Item_str_func::check_well_formed_result(String *str) -{ - /* Check whether we got a well-formed string */ - CHARSET_INFO *cs= str->charset(); - int well_formed_error; - uint wlen= cs->cset->well_formed_len(cs, - str->ptr(), str->ptr() + str->length(), - str->length(), &well_formed_error); - if (wlen < str->length()) - { - THD *thd= current_thd; - char hexbuf[7]; - enum MYSQL_ERROR::enum_warning_level level; - uint diff= str->length() - wlen; - set_if_smaller(diff, 3); - octet2hex(hexbuf, str->ptr() + wlen, diff); - if (thd->variables.sql_mode & - (MODE_STRICT_TRANS_TABLES | MODE_STRICT_ALL_TABLES)) - { - level= MYSQL_ERROR::WARN_LEVEL_ERROR; - null_value= 1; - str= 0; - } - else - level= MYSQL_ERROR::WARN_LEVEL_WARN; - push_warning_printf(thd, level, ER_INVALID_CHARACTER_STRING, - ER(ER_INVALID_CHARACTER_STRING), cs->csname, hexbuf); - } - return str; -} bool Item_str_func::fix_fields(THD *thd, Item **ref) @@ -2229,11 +2199,13 @@ String *Item_func_char::val_str(String *str) { DBUG_ASSERT(fixed == 1); str->length(0); + str->set_charset(collation.collation); for (uint i=0 ; i < arg_count ; i++) { int32 num=(int32) args[i]->val_int(); if (!args[i]->null_value) { + char char_num= (char) num; if (num&0xFF000000L) { str->append((char)(num>>24)); goto b2; @@ -2243,10 +2215,9 @@ String *Item_func_char::val_str(String *str) } else if (num&0xFF00L) { b1: str->append((char)(num>>8)); } - str->append((char) num); + str->append(&char_num, 1); } } - str->set_charset(collation.collation); str->realloc(str->length()); // Add end 0 (for Purify) return check_well_formed_result(str); } |