Bug #18740222: CRASH IN GET_INTERVAL_INFO WITH WEIRDO

               INTERVALS

ISSUE:
------
Some string functions return one or a combination of the
parameters as their result. Here the resultant string's
charset could be incorrectly set to that of the chosen
parameter.

This results in incorrect behavior when an ascii string is
expected.

SOLUTION:
---------
Since an ascii string is expected, val_str_ascii should
explicitly convert the string.

Part of the fix is a backport of Bug#22340858 for mysql-5.5
and mysql-5.6.
parent 32d6db3b
......@@ -227,9 +227,6 @@ bool Item::val_bool()
*/
String *Item::val_str_ascii(String *str)
{
if (!(collation.collation->state & MY_CS_NONASCII))
return val_str(str);
DBUG_ASSERT(str != &str_value);
uint errors;
......@@ -237,11 +234,15 @@ String *Item::val_str_ascii(String *str)
if (!res)
return 0;
if ((null_value= str->copy(res->ptr(), res->length(),
collation.collation, &my_charset_latin1,
&errors)))
return 0;
if (!(res->charset()->state & MY_CS_NONASCII))
str= res;
else
{
if ((null_value= str->copy(res->ptr(), res->length(), collation.collation,
&my_charset_latin1, &errors)))
return 0;
}
return str;
}
......
/* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -179,7 +179,7 @@ String *Item_func_geometry_type::val_str_ascii(String *str)
/* String will not move */
str->copy(geom->get_class_info()->m_name.str,
geom->get_class_info()->m_name.length,
default_charset());
&my_charset_latin1);
return str;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment