mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
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.
This commit is contained in:
parent
455646e785
commit
778a605af3
3 changed files with 17 additions and 2 deletions
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue