Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
55a7338f
Commit
55a7338f
authored
Oct 15, 2007
by
gluh@mysql.com/eagle.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug#30986 Character set introducer followed by a HEX string can return bad result(addon)
issue an error if string has illegal characters
parent
db39976a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
46 deletions
+31
-46
mysql-test/r/ctype_utf8.result
mysql-test/r/ctype_utf8.result
+8
-32
mysql-test/t/ctype_utf8.test
mysql-test/t/ctype_utf8.test
+8
-0
sql/item.cc
sql/item.cc
+9
-3
sql/item.h
sql/item.h
+1
-1
sql/sql_yacc.yy
sql/sql_yacc.yy
+5
-10
No files found.
mysql-test/r/ctype_utf8.result
View file @
55a7338f
...
@@ -1742,25 +1742,13 @@ NULL
...
@@ -1742,25 +1742,13 @@ NULL
Warnings:
Warnings:
Error 1300 Invalid utf8 character string: 'FF'
Error 1300 Invalid utf8 character string: 'FF'
select hex(_utf8 0x616263FF);
select hex(_utf8 0x616263FF);
hex(_utf8 0x616263FF)
ERROR HY000: Invalid utf8 character string: 'FF'
NULL
Warnings:
Error 1300 Invalid utf8 character string: 'FF'
select hex(_utf8 X'616263FF');
select hex(_utf8 X'616263FF');
hex(_utf8 X'616263FF')
ERROR HY000: Invalid utf8 character string: 'FF'
NULL
Warnings:
Error 1300 Invalid utf8 character string: 'FF'
select hex(_utf8 B'001111111111');
select hex(_utf8 B'001111111111');
hex(_utf8 B'001111111111')
ERROR HY000: Invalid utf8 character string: 'FF'
NULL
Warnings:
Error 1300 Invalid utf8 character string: 'FF'
select (_utf8 X'616263FF');
select (_utf8 X'616263FF');
(_utf8 X'616263FF')
ERROR HY000: Invalid utf8 character string: 'FF'
NULL
Warnings:
Error 1300 Invalid utf8 character string: 'FF'
set sql_mode=default;
set sql_mode=default;
select hex(char(0xFF using utf8));
select hex(char(0xFF using utf8));
hex(char(0xFF using utf8))
hex(char(0xFF using utf8))
...
@@ -1773,22 +1761,10 @@ hex(convert(0xFF using utf8))
...
@@ -1773,22 +1761,10 @@ hex(convert(0xFF using utf8))
Warnings:
Warnings:
Warning 1300 Invalid utf8 character string: 'FF'
Warning 1300 Invalid utf8 character string: 'FF'
select hex(_utf8 0x616263FF);
select hex(_utf8 0x616263FF);
hex(_utf8 0x616263FF)
ERROR HY000: Invalid utf8 character string: 'FF'
616263
Warnings:
Warning 1300 Invalid utf8 character string: 'FF'
select hex(_utf8 X'616263FF');
select hex(_utf8 X'616263FF');
hex(_utf8 X'616263FF')
ERROR HY000: Invalid utf8 character string: 'FF'
616263
Warnings:
Warning 1300 Invalid utf8 character string: 'FF'
select hex(_utf8 B'001111111111');
select hex(_utf8 B'001111111111');
hex(_utf8 B'001111111111')
ERROR HY000: Invalid utf8 character string: 'FF'
03
Warnings:
Warning 1300 Invalid utf8 character string: 'FF'
select (_utf8 X'616263FF');
select (_utf8 X'616263FF');
(_utf8 X'616263FF')
ERROR HY000: Invalid utf8 character string: 'FF'
abc
Warnings:
Warning 1300 Invalid utf8 character string: 'FF'
mysql-test/t/ctype_utf8.test
View file @
55a7338f
...
@@ -1411,14 +1411,22 @@ DROP TABLE t1, t2;
...
@@ -1411,14 +1411,22 @@ DROP TABLE t1, t2;
set
sql_mode
=
traditional
;
set
sql_mode
=
traditional
;
select
hex
(
char
(
0xFF
using
utf8
));
select
hex
(
char
(
0xFF
using
utf8
));
select
hex
(
convert
(
0xFF
using
utf8
));
select
hex
(
convert
(
0xFF
using
utf8
));
--
error
ER_INVALID_CHARACTER_STRING
select
hex
(
_utf8
0x616263FF
);
select
hex
(
_utf8
0x616263FF
);
--
error
ER_INVALID_CHARACTER_STRING
select
hex
(
_utf8
X
'616263FF'
);
select
hex
(
_utf8
X
'616263FF'
);
--
error
ER_INVALID_CHARACTER_STRING
select
hex
(
_utf8
B
'001111111111'
);
select
hex
(
_utf8
B
'001111111111'
);
--
error
ER_INVALID_CHARACTER_STRING
select
(
_utf8
X
'616263FF'
);
select
(
_utf8
X
'616263FF'
);
set
sql_mode
=
default
;
set
sql_mode
=
default
;
select
hex
(
char
(
0xFF
using
utf8
));
select
hex
(
char
(
0xFF
using
utf8
));
select
hex
(
convert
(
0xFF
using
utf8
));
select
hex
(
convert
(
0xFF
using
utf8
));
--
error
ER_INVALID_CHARACTER_STRING
select
hex
(
_utf8
0x616263FF
);
select
hex
(
_utf8
0x616263FF
);
--
error
ER_INVALID_CHARACTER_STRING
select
hex
(
_utf8
X
'616263FF'
);
select
hex
(
_utf8
X
'616263FF'
);
--
error
ER_INVALID_CHARACTER_STRING
select
hex
(
_utf8
B
'001111111111'
);
select
hex
(
_utf8
B
'001111111111'
);
--
error
ER_INVALID_CHARACTER_STRING
select
(
_utf8
X
'616263FF'
);
select
(
_utf8
X
'616263FF'
);
sql/item.cc
View file @
55a7338f
...
@@ -4247,7 +4247,7 @@ bool Item::is_datetime()
...
@@ -4247,7 +4247,7 @@ bool Item::is_datetime()
}
}
String
*
Item
::
check_well_formed_result
(
String
*
str
)
String
*
Item
::
check_well_formed_result
(
String
*
str
,
bool
send_error
)
{
{
/* Check whether we got a well-formed string */
/* Check whether we got a well-formed string */
CHARSET_INFO
*
cs
=
str
->
charset
();
CHARSET_INFO
*
cs
=
str
->
charset
();
...
@@ -4263,8 +4263,14 @@ String *Item::check_well_formed_result(String *str)
...
@@ -4263,8 +4263,14 @@ String *Item::check_well_formed_result(String *str)
uint
diff
=
str
->
length
()
-
wlen
;
uint
diff
=
str
->
length
()
-
wlen
;
set_if_smaller
(
diff
,
3
);
set_if_smaller
(
diff
,
3
);
octet2hex
(
hexbuf
,
str
->
ptr
()
+
wlen
,
diff
);
octet2hex
(
hexbuf
,
str
->
ptr
()
+
wlen
,
diff
);
if
(
thd
->
variables
.
sql_mode
&
if
(
send_error
)
(
MODE_STRICT_TRANS_TABLES
|
MODE_STRICT_ALL_TABLES
))
{
my_error
(
ER_INVALID_CHARACTER_STRING
,
MYF
(
0
),
cs
->
csname
,
hexbuf
);
return
0
;
}
if
((
thd
->
variables
.
sql_mode
&
(
MODE_STRICT_TRANS_TABLES
|
MODE_STRICT_ALL_TABLES
)))
{
{
level
=
MYSQL_ERROR
::
WARN_LEVEL_ERROR
;
level
=
MYSQL_ERROR
::
WARN_LEVEL_ERROR
;
null_value
=
1
;
null_value
=
1
;
...
...
sql/item.h
View file @
55a7338f
...
@@ -870,7 +870,7 @@ public:
...
@@ -870,7 +870,7 @@ public:
*/
*/
virtual
bool
result_as_longlong
()
{
return
FALSE
;
}
virtual
bool
result_as_longlong
()
{
return
FALSE
;
}
bool
is_datetime
();
bool
is_datetime
();
String
*
check_well_formed_result
(
String
*
str
);
String
*
check_well_formed_result
(
String
*
str
,
bool
send_error
=
0
);
};
};
...
...
sql/sql_yacc.yy
View file @
55a7338f
...
@@ -7720,15 +7720,11 @@ literal:
...
@@ -7720,15 +7720,11 @@ literal:
str ? str->ptr() : "",
str ? str->ptr() : "",
str ? str->length() : 0,
str ? str->length() : 0,
Lex->underscore_charset);
Lex->underscore_charset);
if ($$)
if (!$$ || !$$->check_well_formed_result(&$$->str_value, TRUE))
{
((Item_string *) $$)->set_repertoire_from_value();
if (!$$->check_well_formed_result(&$$->str_value))
{
{
$$= new Item_null();
MYSQL_YYABORT;
$$->set_name(NULL, 0, system_charset_info);
}
}
}
((Item_string *) $$)->set_repertoire_from_value();
}
}
| UNDERSCORE_CHARSET BIN_NUM
| UNDERSCORE_CHARSET BIN_NUM
{
{
...
@@ -7744,10 +7740,9 @@ literal:
...
@@ -7744,10 +7740,9 @@ literal:
str ? str->ptr() : "",
str ? str->ptr() : "",
str ? str->length() : 0,
str ? str->length() : 0,
Lex->underscore_charset);
Lex->underscore_charset);
if (
$$ && !$$->check_well_formed_result(&$$->str_value
))
if (
!$$ || !$$->check_well_formed_result(&$$->str_value, TRUE
))
{
{
$$= new Item_null();
MYSQL_YYABORT;
$$->set_name(NULL, 0, system_charset_info);
}
}
}
}
| DATE_SYM text_literal { $$ = $2; }
| DATE_SYM text_literal { $$ = $2; }
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment