Commit fe5d5495 authored by Sergey Glukhov's avatar Sergey Glukhov

Bug#53942 valgrind warnings with timestamp() function and incomplete datetime values

Field_time::get_date method does not initialize MYSQL_TIME::time_type field.
The fix is to init this field.
parent 6498472b
...@@ -138,3 +138,13 @@ CAST(c AS TIME) ...@@ -138,3 +138,13 @@ CAST(c AS TIME)
00:00:00 00:00:00
DROP TABLE t1; DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
#
# Bug#53942 valgrind warnings with timestamp() function and incomplete datetime values
#
CREATE TABLE t1(f1 TIME);
INSERT INTO t1 VALUES ('23:38:57');
SELECT TIMESTAMP(f1,'1') FROM t1;
TIMESTAMP(f1,'1')
NULL
DROP TABLE t1;
End of 5.1 tests
...@@ -88,5 +88,15 @@ INSERT INTO t1 VALUES ('0:00:00'); ...@@ -88,5 +88,15 @@ INSERT INTO t1 VALUES ('0:00:00');
SELECT CAST(c AS TIME) FROM t1; SELECT CAST(c AS TIME) FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo End of 5.0 tests --echo End of 5.0 tests
--echo #
--echo # Bug#53942 valgrind warnings with timestamp() function and incomplete datetime values
--echo #
CREATE TABLE t1(f1 TIME);
INSERT INTO t1 VALUES ('23:38:57');
SELECT TIMESTAMP(f1,'1') FROM t1;
DROP TABLE t1;
--echo End of 5.1 tests
...@@ -5312,7 +5312,6 @@ String *Field_time::val_str(String *val_buffer, ...@@ -5312,7 +5312,6 @@ String *Field_time::val_str(String *val_buffer,
bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate) bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{ {
long tmp;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
if (!(fuzzydate & TIME_FUZZY_DATE)) if (!(fuzzydate & TIME_FUZZY_DATE))
{ {
...@@ -5322,19 +5321,7 @@ bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate) ...@@ -5322,19 +5321,7 @@ bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate)
thd->row_count); thd->row_count);
return 1; return 1;
} }
tmp=(long) sint3korr(ptr); return Field_time::get_time(ltime);
ltime->neg=0;
if (tmp < 0)
{
ltime->neg= 1;
tmp=-tmp;
}
ltime->hour=tmp/10000;
tmp-=ltime->hour*10000;
ltime->minute= tmp/100;
ltime->second= tmp % 100;
ltime->year= ltime->month= ltime->day= ltime->second_part= 0;
return 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