Commit 3b7f0445 authored by Sergey Glukhov's avatar Sergey Glukhov

Bug#11766126 59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING

Valgrind warning happens because null values check happens too late
in Item_func_month::val_str(after result string calculation).The fix
is to check null value before result string calculation.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.h:
  check null value before result string calculation.
parent 4e26a41f
......@@ -1393,4 +1393,10 @@ SET GLOBAL SQL_MODE=DEFAULT;
SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1)
NULL
#
# Bug#11766126 59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
#
SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025))
NULL
End of 5.1 tests
......@@ -901,4 +901,10 @@ SET GLOBAL SQL_MODE=DEFAULT;
SELECT FORMAT(YEAR(STR_TO_DATE('',GET_FORMAT(TIME,''))),1);
--echo #
--echo # Bug#11766126 59166: ANOTHER DATETIME VALGRIND UNINITIALIZED WARNING
--echo #
SELECT CAST((MONTH(FROM_UNIXTIME(@@GLOBAL.SQL_MODE))) AS BINARY(1025));
--echo End of 5.1 tests
......@@ -106,8 +106,11 @@ public:
{ DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); }
String *val_str(String *str)
{
str->set(val_int(), &my_charset_bin);
return null_value ? 0 : str;
longlong nr= val_int();
if (null_value)
return 0;
str->set(nr, &my_charset_bin);
return str;
}
const char *func_name() const { return "month"; }
enum Item_result result_type () const { return INT_RESULT; }
......
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