diff options
author | unknown <dlenev@brandersnatch.localdomain> | 2004-12-30 13:39:01 +0300 |
---|---|---|
committer | unknown <dlenev@brandersnatch.localdomain> | 2004-12-30 13:39:01 +0300 |
commit | 1382df5aff42233669ed5b0b76dfd459f8d87c05 (patch) | |
tree | f51018c159b575ad4f333440949cc9c869de21ea /sql | |
parent | 49501611aa534efcd18d3ee3bf94ec1ba13aa6f2 (diff) | |
download | mariadb-git-1382df5aff42233669ed5b0b76dfd459f8d87c05.tar.gz |
Fix for bug #6914 "Problems using time()/date() output in expressions".
When we cast datetime value to DATE (TIME) type we should throw away its
time (date) part. This was not done properly if CAST() function was used
in datetime expressions.
mysql-test/r/cast.result:
Added test for bug #6914 "Problems using time()/date() output in
expressions".
mysql-test/t/cast.test:
Added test for bug #6914 "Problems using time()/date() output in
expressions".
sql/item_timefunc.cc:
Item_time_typecast::get_time()/Item_date_typecast::get_date():
When we cast datetime value to DATE we should throw away its time part.
When we cast such value to TIME type we should throw away its date part.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_timefunc.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 84a9e01ed2a..054a9966e73 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2183,6 +2183,12 @@ String *Item_datetime_typecast::val_str(String *str) bool Item_time_typecast::get_time(TIME *ltime) { bool res= get_arg0_time(ltime); + /* + For MYSQL_TIMESTAMP_TIME value we can have non-zero day part, + which we should not lose. + */ + if (ltime->time_type == MYSQL_TIMESTAMP_DATETIME) + ltime->year= ltime->month= ltime->day= 0; ltime->time_type= MYSQL_TIMESTAMP_TIME; return res; } @@ -2206,6 +2212,7 @@ String *Item_time_typecast::val_str(String *str) bool Item_date_typecast::get_date(TIME *ltime, uint fuzzy_date) { bool res= get_arg0_date(ltime,1); + ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0; ltime->time_type= MYSQL_TIMESTAMP_DATE; return res; } |