summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
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 /sql/item_cmpfunc.cc
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 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index ed0c09f0b32..70df1b4d09c 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -706,6 +706,18 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
func= &Arg_comparator::compare_datetime;
return 0;
}
+ else if (type == STRING_RESULT && (*a)->field_type() == MYSQL_TYPE_TIME &&
+ (*b)->field_type() == MYSQL_TYPE_TIME)
+ {
+ /* Compare TIME values as integers. */
+ thd= current_thd;
+ owner= owner_arg;
+ func= ((test(owner && owner->functype() == Item_func::EQUAL_FUNC)) ?
+ &Arg_comparator::compare_e_int :
+ &Arg_comparator::compare_int_unsigned);
+ return 0;
+ }
+
return set_compare_func(owner_arg, type);
}