Commit d6125b27 authored by Sergey Glukhov's avatar Sergey Glukhov

Bug#11765216 58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION

Valgrind warning happens due to uninitialized cached_format_type field
which is used later in Item_func_str_to_date::val_str method.
The fix is to init cached_format_type field.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.cc:
  init cached_format_type field
parent 4ed8cb4a
......@@ -1381,4 +1381,10 @@ DROP TABLE t1;
SELECT STR_TO_DATE(SPACE(2),'1');
STR_TO_DATE(SPACE(2),'1')
0000-00-00
#
# Bug#11765216 58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
#
SET GLOBAL SQL_MODE='';
DO STR_TO_DATE((''), FROM_DAYS(@@GLOBAL.SQL_MODE));
SET GLOBAL SQL_MODE=DEFAULT;
End of 5.1 tests
......@@ -887,4 +887,12 @@ DROP TABLE t1;
SELECT STR_TO_DATE(SPACE(2),'1');
--echo #
--echo # Bug#11765216 58154: UNINITIALIZED VARIABLE FORMAT IN STR_TO_DATE FUNCTION
--echo #
SET GLOBAL SQL_MODE='';
DO STR_TO_DATE((''), FROM_DAYS(@@GLOBAL.SQL_MODE));
SET GLOBAL SQL_MODE=DEFAULT;
--echo End of 5.1 tests
......@@ -3293,6 +3293,7 @@ void Item_func_str_to_date::fix_length_and_dec()
{
maybe_null= 1;
decimals=0;
cached_format_type= DATE_TIME;
cached_field_type= MYSQL_TYPE_DATETIME;
max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
cached_timestamp_type= MYSQL_TIMESTAMP_NONE;
......
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