summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-07-11 23:18:02 +0400
committerunknown <evgen@moonbone.local>2007-07-11 23:18:02 +0400
commit25e28d4d28e7052d31079a9c8b6f65e4e94041ca (patch)
tree2cb4df496d59d5569bd8f4865939fbefdf3068da /mysql-test
parent3295d449c42464f40940e9e7d369fef5935f4c40 (diff)
downloadmariadb-git-25e28d4d28e7052d31079a9c8b6f65e4e94041ca.tar.gz
Bug#29555: Comparing time values as strings may lead to a wrong result.
Time values were compared as strings. This led to a wrong comparison result when comparing values one of which is under 100 hours and another is over 100 hours. Now when the Arg_comparator::set_cmp_func function sees that both items to compare are of the TIME type it sets the comparator to the Arg_comparator::compare_e_int or the Arg_comparator::compare_int_unsigned functions. sql/item_cmpfunc.cc: Bug#29555: Comparing time values as strings may lead to a wrong result. Now when the Arg_comparator::set_cmp_func function sees that both items to compare are of the TIME type it sets the comparator to the Arg_comparator::compare_e_int or the Arg_comparator::compare_int_unsigned functions. mysql-test/r/type_time.result: Added a test case for the bug#29555: Comparing time values as strings may lead to a wrong result. mysql-test/t/type_time.test: Added a test case for the bug#29555: Comparing time values as strings may lead to a wrong result.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/type_time.result18
-rw-r--r--mysql-test/t/type_time.test10
2 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result
index 442435b0459..6124f6e39f1 100644
--- a/mysql-test/r/type_time.result
+++ b/mysql-test/r/type_time.result
@@ -85,3 +85,21 @@ sec_to_time(time_to_sec(t))
13:00:00
09:00:00
drop table t1;
+select cast('100:55:50' as time) < cast('24:00:00' as time);
+cast('100:55:50' as time) < cast('24:00:00' as time)
+0
+select cast('100:55:50' as time) < cast('024:00:00' as time);
+cast('100:55:50' as time) < cast('024:00:00' as time)
+0
+select cast('300:55:50' as time) < cast('240:00:00' as time);
+cast('300:55:50' as time) < cast('240:00:00' as time)
+0
+select cast('100:55:50' as time) > cast('24:00:00' as time);
+cast('100:55:50' as time) > cast('24:00:00' as time)
+1
+select cast('100:55:50' as time) > cast('024:00:00' as time);
+cast('100:55:50' as time) > cast('024:00:00' as time)
+1
+select cast('300:55:50' as time) > cast('240:00:00' as time);
+cast('300:55:50' as time) > cast('240:00:00' as time)
+1
diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test
index cb7e4f85ad1..d294e53a12f 100644
--- a/mysql-test/t/type_time.test
+++ b/mysql-test/t/type_time.test
@@ -40,3 +40,13 @@ drop table t1;
# ##########################################################
# End of 4.1 tests
+
+#
+# Bug#29555: Comparing time values as strings may lead to a wrong result.
+#
+select cast('100:55:50' as time) < cast('24:00:00' as time);
+select cast('100:55:50' as time) < cast('024:00:00' as time);
+select cast('300:55:50' as time) < cast('240:00:00' as time);
+select cast('100:55:50' as time) > cast('24:00:00' as time);
+select cast('100:55:50' as time) > cast('024:00:00' as time);
+select cast('300:55:50' as time) > cast('240:00:00' as time);