Commit 3ca1852c authored by unknown's avatar unknown

Fix for bug #18501: Server crashes with monthname().


mysql-test/r/func_time.result:
  Fix for bug #18501: Server crashes with monthname().
    - test case
mysql-test/t/func_time.test:
  Fix for bug #18501: Server crashes with monthname().
    - test case
sql/item_timefunc.cc:
  Fix for bug #18501: Server crashes with monthname().
    - check null_value as well.
parent 4189bfa4
...@@ -626,3 +626,7 @@ last_day('2005-01-00') ...@@ -626,3 +626,7 @@ last_day('2005-01-00')
NULL NULL
Warnings: Warnings:
Warning 1292 Truncated incorrect datetime value: '2005-01-00' Warning 1292 Truncated incorrect datetime value: '2005-01-00'
select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
monthname(str_to_date(null, '%m')) monthname(str_to_date(null, '%m')) monthname(str_to_date(1, '%m')) monthname(str_to_date(0, '%m'))
NULL NULL January NULL
...@@ -315,4 +315,11 @@ select last_day('2005-00-00'); ...@@ -315,4 +315,11 @@ select last_day('2005-00-00');
select last_day('2005-00-01'); select last_day('2005-00-01');
select last_day('2005-01-00'); select last_day('2005-01-00');
#
# Bug #18501: monthname and NULLs
#
select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
# End of 4.1 tests # End of 4.1 tests
...@@ -905,9 +905,9 @@ String* Item_func_monthname::val_str(String* str) ...@@ -905,9 +905,9 @@ String* Item_func_monthname::val_str(String* str)
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
const char *month_name; const char *month_name;
uint month=(uint) Item_func_month::val_int(); uint month= (uint) val_int();
if (!month) // This is also true for NULL if (null_value || !month)
{ {
null_value=1; null_value=1;
return (String*) 0; return (String*) 0;
......
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