Below is the list of changes that have just been committed into a local
5.0 repository of gluh. When gluh does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-08 17:19:10+05:00, gluh@stripped +4 -0
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
Item Item_func_hex: added the check for well formed string
if result string has illegal symbols we cut off the string
until last legal symbol.
mysql-test/r/ctype_utf8.result@stripped, 2007-10-08 17:19:08+05:00, gluh@stripped +54 -2
test result
mysql-test/t/ctype_utf8.test@stripped, 2007-10-08 17:19:08+05:00, gluh@stripped +17 -0
test case
sql/item_strfunc.cc@stripped, 2007-10-08 17:19:08+05:00, gluh@stripped +5 -0
Item Item_func_hex: added the check for well formed string
if result string has illegal symbols we cut off the string until last valid symbol
sql/sql_yacc.yy@stripped, 2007-10-08 17:19:09+05:00, gluh@stripped +1 -1
use Lex->underscore_charset instead of Lex->charset
diff -Nrup a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
--- a/mysql-test/r/ctype_utf8.result 2007-08-03 15:28:37 +05:00
+++ b/mysql-test/r/ctype_utf8.result 2007-10-08 17:19:08 +05:00
@@ -1538,12 +1538,12 @@ char(53647 using utf8)
я
select char(0xff,0x8f using utf8);
char(0xff,0x8f using utf8)
-ÿ
+
Warnings:
Warning 1300 Invalid utf8 character string: 'FF8F'
select convert(char(0xff,0x8f) using utf8);
convert(char(0xff,0x8f) using utf8)
-ÿ
+
Warnings:
Warning 1300 Invalid utf8 character string: 'FF8F'
set sql_mode=traditional;
@@ -1730,3 +1730,55 @@ i
1
н1234567890
DROP TABLE t1, t2;
+set sql_mode=traditional;
+select hex(char(0xFF using utf8));
+hex(char(0xFF using utf8))
+NULL
+Warnings:
+Error 1300 Invalid utf8 character string: 'FF'
+select hex(convert(0xFF using utf8));
+hex(convert(0xFF using utf8))
+NULL
+Warnings:
+Error 1300 Invalid utf8 character string: 'FF'
+select hex(_utf8 0x616263FF);
+hex(_utf8 0x616263FF)
+NULL
+Warnings:
+Error 1300 Invalid utf8 character string: 'FF'
+select hex(_utf8 X'616263FF');
+hex(_utf8 X'616263FF')
+NULL
+Warnings:
+Error 1300 Invalid utf8 character string: 'FF'
+select hex(_utf8 B'001111111111');
+hex(_utf8 B'001111111111')
+NULL
+Warnings:
+Error 1300 Invalid utf8 character string: 'FF'
+set sql_mode=default;
+select hex(char(0xFF using utf8));
+hex(char(0xFF using utf8))
+
+Warnings:
+Warning 1300 Invalid utf8 character string: 'FF'
+select hex(convert(0xFF using utf8));
+hex(convert(0xFF using utf8))
+
+Warnings:
+Warning 1300 Invalid utf8 character string: 'FF'
+select hex(_utf8 0x616263FF);
+hex(_utf8 0x616263FF)
+616263
+Warnings:
+Warning 1300 Invalid utf8 character string: 'FF'
+select hex(_utf8 X'616263FF');
+hex(_utf8 X'616263FF')
+616263
+Warnings:
+Warning 1300 Invalid utf8 character string: 'FF'
+select hex(_utf8 B'001111111111');
+hex(_utf8 B'001111111111')
+03
+Warnings:
+Warning 1300 Invalid utf8 character string: 'FF'
diff -Nrup a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
--- a/mysql-test/t/ctype_utf8.test 2007-08-03 15:28:37 +05:00
+++ b/mysql-test/t/ctype_utf8.test 2007-10-08 17:19:08 +05:00
@@ -1403,3 +1403,20 @@ SELECT b FROM t2 UNION SELECT c FROM t1;
SELECT i FROM t2 UNION SELECT c FROM t1;
DROP TABLE t1, t2;
+
+#
+# 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
+#
+set sql_mode=traditional;
+select hex(char(0xFF using utf8));
+select hex(convert(0xFF using utf8));
+select hex(_utf8 0x616263FF);
+select hex(_utf8 X'616263FF');
+select hex(_utf8 B'001111111111');
+set sql_mode=default;
+select hex(char(0xFF using utf8));
+select hex(convert(0xFF using utf8));
+select hex(_utf8 0x616263FF);
+select hex(_utf8 X'616263FF');
+select hex(_utf8 B'001111111111');
diff -Nrup a/sql/item_strfunc.cc b/sql/item_strfunc.cc
--- a/sql/item_strfunc.cc 2007-08-03 15:28:38 +05:00
+++ b/sql/item_strfunc.cc 2007-10-08 17:19:08 +05:00
@@ -62,7 +62,10 @@ String *Item_str_func::check_well_formed
str= 0;
}
else
+ {
level= MYSQL_ERROR::WARN_LEVEL_WARN;
+ str->length(wlen);
+ }
push_warning_printf(thd, level, ER_INVALID_CHARACTER_STRING,
ER(ER_INVALID_CHARACTER_STRING), cs->csname, hexbuf);
}
@@ -2768,6 +2771,8 @@ String *Item_func_hex::val_str(String *s
/* Convert given string to a hex string, character by character */
res= args[0]->val_str(str);
+ if (res)
+ res= check_well_formed_result(res);
if (!res || tmp_value.alloc(res->length()*2+1))
{
null_value=1;
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy 2007-09-12 23:39:32 +05:00
+++ b/sql/sql_yacc.yy 2007-10-08 17:19:09 +05:00
@@ -7734,7 +7734,7 @@ literal:
(String*) 0;
$$= new Item_string(str ? str->ptr() : "",
str ? str->length() : 0,
- Lex->charset);
+ Lex->underscore_charset);
}
| DATE_SYM text_literal { $$ = $2; }
| TIME_SYM text_literal { $$ = $2; }
| Thread |
|---|
| • bk commit into 5.0 tree (gluh:1.2534) BUG#30982 | gluh | 8 Oct |