From 1382df5aff42233669ed5b0b76dfd459f8d87c05 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Dec 2004 13:39:01 +0300 Subject: 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. --- mysql-test/r/cast.result | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'mysql-test/r') diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index ccf75f68e88..636e2603f9b 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -178,3 +178,12 @@ aaa aa aab aa aac aa DROP TABLE t1; +select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour); +date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour) +2004-12-30 00:00:00 +select timediff(cast('2004-12-30 12:00:00' as time), '12:00:00'); +timediff(cast('2004-12-30 12:00:00' as time), '12:00:00') +00:00:00 +select timediff(cast('1 12:00:00' as time), '12:00:00'); +timediff(cast('1 12:00:00' as time), '12:00:00') +24:00:00 -- cgit v1.2.1