diff options
author | unknown <bar@mysql.com> | 2005-09-16 10:24:37 +0500 |
---|---|---|
committer | unknown <bar@mysql.com> | 2005-09-16 10:24:37 +0500 |
commit | 149b3761f26080afa7cfb3d289cc30b47918943e (patch) | |
tree | 0ba6bac6fd72f07908ee95a39ef2031d8ea4080a /sql/item_strfunc.cc | |
parent | 97bea9092e7e2834e8b81899ff085280647587d7 (diff) | |
download | mariadb-git-149b3761f26080afa7cfb3d289cc30b47918943e.tar.gz |
Bug#10504
Character set does not support traditional mode
ctype_utf8.result, ctype_utf8.test:
adding test case.
password.c, mysql_com.h
Changeing octet2hex availability from static to public.
item_strfunc.cc:
Result string is now checked to be well-formed.
Warning/error is generated, depending on sql_mode.
include/mysql_com.h:
Bug#10504
Character set does not support traditional mode
Changeing octet2hex from static to public.
sql/item_strfunc.cc:
Result string is now checked to be well-formed.
Warning/error is generated, depending on sql_mode.
sql/password.c:
Changeing octet2hex from static to public.
mysql-test/t/ctype_utf8.test:
adding test case.
mysql-test/r/ctype_utf8.result:
adding test case.
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r-- | sql/item_strfunc.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 4fd33c06095..309e6dcdcd2 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1980,6 +1980,33 @@ b1: str->append((char)(num>>8)); } str->set_charset(collation.collation); str->realloc(str->length()); // Add end 0 (for Purify) + + /* Check whether we got a well-formed string */ + CHARSET_INFO *cs= collation.collation; + 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, (const uchar*) 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; } |