diff options
author | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2010-05-31 13:25:11 +0400 |
---|---|---|
committer | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2010-05-31 13:25:11 +0400 |
commit | 89b83c05e0946e0fdd7cf9392a5e5b7e7a78957e (patch) | |
tree | fe89d7122a6e41e82ab872980dc52799becb5ed3 | |
parent | 9731b3852b0be5820fc795cf4f27d0f260ebe761 (diff) | |
download | mariadb-git-89b83c05e0946e0fdd7cf9392a5e5b7e7a78957e.tar.gz |
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.
mysql-test/r/type_time.result:
test case
mysql-test/t/type_time.test:
test case
sql/field.cc:
--use Field_time::get_time in Field_time::get_date
--removed duplicated code in Field_time::get_date method
-rw-r--r-- | mysql-test/r/type_time.result | 10 | ||||
-rw-r--r-- | mysql-test/t/type_time.test | 12 | ||||
-rw-r--r-- | sql/field.cc | 15 |
3 files changed, 22 insertions, 15 deletions
diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index e4b90196c2d..86712bebfa1 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -138,3 +138,13 @@ CAST(c AS TIME) 00:00:00 DROP TABLE t1; 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 diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test index 5bb521601e5..34331b72688 100644 --- a/mysql-test/t/type_time.test +++ b/mysql-test/t/type_time.test @@ -88,5 +88,15 @@ INSERT INTO t1 VALUES ('0:00:00'); SELECT CAST(c AS TIME) FROM t1; DROP TABLE t1; - --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 diff --git a/sql/field.cc b/sql/field.cc index b203a42a918..7360a013ffb 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5312,7 +5312,6 @@ String *Field_time::val_str(String *val_buffer, bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate) { - long tmp; THD *thd= table ? table->in_use : current_thd; if (!(fuzzydate & TIME_FUZZY_DATE)) { @@ -5322,19 +5321,7 @@ bool Field_time::get_date(MYSQL_TIME *ltime, uint fuzzydate) thd->row_count); return 1; } - tmp=(long) sint3korr(ptr); - 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; + return Field_time::get_time(ltime); } |