summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@gleb.loc>2007-07-13 20:49:21 +0500
committerunknown <gshchepa/uchum@gleb.loc>2007-07-13 20:49:21 +0500
commit85603b2e0b6b51c57de7019f451461e676c458de (patch)
treeb5f4008b2556eb9c71715a74bc85049c4e4600f5 /sql/item_cmpfunc.cc
parentbf30f9e1ddbe8bc093cc7675c5f50d7216600b29 (diff)
parent2a0498c0f9a67676aedef2699fe5a14150ce5f4d (diff)
downloadmariadb-git-85603b2e0b6b51c57de7019f451461e676c458de.tar.gz
Merge gleb.loc:/home/uchum/work/bk/5.0
into gleb.loc:/home/uchum/work/bk/5.0-opt
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc36
1 files changed, 28 insertions, 8 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index ed0c09f0b32..555384b2bfc 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);
}
@@ -1716,6 +1728,7 @@ void Item_func_between::fix_length_and_dec()
THD *thd= current_thd;
int i;
bool datetime_found= FALSE;
+ int time_items_found= 0;
compare_as_dates= TRUE;
/*
@@ -1735,17 +1748,19 @@ void Item_func_between::fix_length_and_dec()
At least one of items should be a DATE/DATETIME item and other items
should return the STRING result.
*/
- for (i= 0; i < 3; i++)
+ if (cmp_type == STRING_RESULT)
{
- if (args[i]->is_datetime())
+ for (i= 0; i < 3; i++)
{
- datetime_found= TRUE;
- continue;
+ if (args[i]->is_datetime())
+ {
+ datetime_found= TRUE;
+ continue;
+ }
+ if (args[i]->field_type() == MYSQL_TYPE_TIME &&
+ args[i]->result_as_longlong())
+ time_items_found++;
}
- if (args[i]->result_type() == STRING_RESULT)
- continue;
- compare_as_dates= FALSE;
- break;
}
if (!datetime_found)
compare_as_dates= FALSE;
@@ -1755,6 +1770,11 @@ void Item_func_between::fix_length_and_dec()
ge_cmp.set_datetime_cmp_func(args, args + 1);
le_cmp.set_datetime_cmp_func(args, args + 2);
}
+ else if (time_items_found == 3)
+ {
+ /* Compare TIME items as integers. */
+ cmp_type= INT_RESULT;
+ }
else if (args[0]->real_item()->type() == FIELD_ITEM &&
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE)