summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSreeharsha Ramanavarapu <sreeharsha.ramanavarapu@oracle.com>2016-03-03 06:42:12 +0530
committerSreeharsha Ramanavarapu <sreeharsha.ramanavarapu@oracle.com>2016-03-03 06:42:12 +0530
commit767bab4abe7666ee861984bc74ce87200ba23b5d (patch)
tree4343acf6505a575c296059d26b6784af5428e667 /sql
parent32d6db3bfa00e437fbd232b80b73b82a0d30c4ae (diff)
downloadmariadb-git-767bab4abe7666ee861984bc74ce87200ba23b5d.tar.gz
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.
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc17
-rw-r--r--sql/item_geofunc.cc4
2 files changed, 11 insertions, 10 deletions
diff --git a/sql/item.cc b/sql/item.cc
index c482f0e1a04..f4917448dda 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -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;
}
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 621ddcb1a30..983491211c3 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -1,4 +1,4 @@
-/* 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;
}