diff options
author | Alexander Barkov <bar@mnogosearch.org> | 2014-01-24 16:50:39 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mnogosearch.org> | 2014-01-24 16:50:39 +0400 |
commit | d106dc059746157239d951551093fec049a7b73a (patch) | |
tree | 61b1e9cb2cf21293196b23b7dcad345c6a41a930 /sql/item_timefunc.cc | |
parent | 519c7305ac4e1e4bafe0acc56764fa40a0e621ab (diff) | |
download | mariadb-git-d106dc059746157239d951551093fec049a7b73a.tar.gz |
MDEV-5504 Server crashes in String::length on SELECT with MONTHNAME, GROUP BY, ROLLUP
The crash happened because Item_func_monthname was derived from
Item_func_month, so Item_func_monthname::is_null() did not work fine.
Backporting a change from 5.5: Item_func_monthname is now derived from
Item_str_func.
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index b618ec038f2..b5d43786248 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -883,16 +883,13 @@ String* Item_func_monthname::val_str(String* str) { DBUG_ASSERT(fixed == 1); const char *month_name; - uint month= (uint) val_int(); uint err; + MYSQL_TIME ltime; - if (null_value || !month) - { - null_value=1; - return (String*) 0; - } - null_value=0; - month_name= locale->month_names->type_names[month-1]; + if ((null_value= (get_arg0_date(<ime, 0) || !ltime.month))) + return (String *) 0; + + month_name= locale->month_names->type_names[ltime.month - 1]; str->copy(month_name, (uint) strlen(month_name), &my_charset_utf8_bin, collation.collation, &err); return str; |