summaryrefslogtreecommitdiff
path: root/mysql-test/t/cast.test
diff options
context:
space:
mode:
authorunknown <dlenev@brandersnatch.localdomain>2004-12-30 13:39:01 +0300
committerunknown <dlenev@brandersnatch.localdomain>2004-12-30 13:39:01 +0300
commit1382df5aff42233669ed5b0b76dfd459f8d87c05 (patch)
treef51018c159b575ad4f333440949cc9c869de21ea /mysql-test/t/cast.test
parent49501611aa534efcd18d3ee3bf94ec1ba13aa6f2 (diff)
downloadmariadb-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 'mysql-test/t/cast.test')
-rw-r--r--mysql-test/t/cast.test10
1 files changed, 10 insertions, 0 deletions
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index e5681dedbac..23bba7d5aff 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -108,3 +108,13 @@ SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a;
SELECT a, CAST(a AS UNSIGNED) FROM t1 ORDER BY CAST(a AS CHAR) ;
SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a;
DROP TABLE t1;
+
+#
+# Test for bug #6914 "Problems using time()/date() output in expressions".
+# When we are casting datetime value to DATE/TIME we should throw away
+# time/date parts (correspondingly).
+#
+select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour);
+select timediff(cast('2004-12-30 12:00:00' as time), '12:00:00');
+# Still we should not throw away "days" part of time value
+select timediff(cast('1 12:00:00' as time), '12:00:00');