summaryrefslogtreecommitdiff
path: root/sql/item_strfunc.cc
diff options
context:
space:
mode:
authorGeorgi Kodinov <joro@sun.com>2009-01-09 13:50:18 +0200
committerGeorgi Kodinov <joro@sun.com>2009-01-09 13:50:18 +0200
commit7c3ae5164738c931938195fd2184a1fff754be1c (patch)
treed2c700b58b3a495ae4d568d4c8e77e8e32bffe14 /sql/item_strfunc.cc
parent8d16eb71b348830529ef9f1f8e528b3d0abd2967 (diff)
downloadmariadb-git-7c3ae5164738c931938195fd2184a1fff754be1c.tar.gz
Bug #41437: Value stored in 'case' lacks charset, causes segfault
When substituting system constant functions with a constant result the server was not expecting that the function may return NULL. Fixed by checking for NULL and returning Item_null (in the relevant collation) if the result of the system constant function was NULL.
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r--sql/item_strfunc.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index d1e3f45bba1..34f974042a5 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1696,6 +1696,12 @@ Item *Item_func_sysconst::safe_charset_converter(CHARSET_INFO *tocs)
Item_string *conv;
uint conv_errors;
String tmp, cstr, *ostr= val_str(&tmp);
+ if (null_value)
+ {
+ Item *null_item= new Item_null((char *) fully_qualified_func_name());
+ null_item->collation.set (tocs);
+ return null_item;
+ }
cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors);
if (conv_errors ||
!(conv= new Item_static_string_func(fully_qualified_func_name(),