summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorevgen@moonbone.local <>2006-09-01 14:08:38 +0400
committerevgen@moonbone.local <>2006-09-01 14:08:38 +0400
commite1c245bff39ea9c67cf16ba4fea6fe1d2f0c38dc (patch)
treea39c7842d908256f7192d59cbff602e87e10ec85 /sql/item_cmpfunc.cc
parent636d9023058093d4964ceb3c50efd8e4b816b073 (diff)
parent94028c618f7f7df2736851b6f4faa131708016d9 (diff)
downloadmariadb-git-e1c245bff39ea9c67cf16ba4fea6fe1d2f0c38dc.tar.gz
Merge moonbone.local:/home/evgen/bk-trees/mysql-5.1-opt
into moonbone.local:/work/tmp_merge-5.1-mysql
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc54
1 files changed, 33 insertions, 21 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 4d793af4f93..fd0b348ac85 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -125,31 +125,39 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
uchar null_byte;
Field *field= NULL;
- /* Search for date/time fields/functions */
- for (i= 0; i < nitems; i++)
+ /*
+ Do not convert items while creating a or showing a view in order
+ to store/display the original query in these cases.
+ */
+ if (thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
+ thd->lex->sql_command != SQLCOM_SHOW_CREATE)
{
- if (!items[i]->result_as_longlong())
+ /* Search for date/time fields/functions */
+ for (i= 0; i < nitems; i++)
{
- /* Do not convert anything if a string field/function is present */
- if (!items[i]->const_item() && items[i]->result_type() == STRING_RESULT)
+ if (!items[i]->result_as_longlong())
+ {
+ /* Do not convert anything if a string field/function is present */
+ if (!items[i]->const_item() && items[i]->result_type() == STRING_RESULT)
+ {
+ i= nitems;
+ break;
+ }
+ continue;
+ }
+ if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM &&
+ items[i]->result_type() != INT_RESULT)
{
- i= nitems;
+ field= ((Item_field *)items[i]->real_item())->field;
+ break;
+ }
+ else if (res == Item::FUNC_ITEM)
+ {
+ field= items[i]->tmp_table_field_from_field_type(0,0);
+ if (field)
+ field->move_field(buff, &null_byte, 0);
break;
}
- continue;
- }
- if ((res= items[i]->real_item()->type()) == Item::FIELD_ITEM &&
- items[i]->result_type() != INT_RESULT)
- {
- field= ((Item_field *)items[i]->real_item())->field;
- break;
- }
- else if (res == Item::FUNC_ITEM)
- {
- field= items[i]->tmp_table_field_from_field_type(0, 0);
- if (field)
- field->move_field(buff, &null_byte, 0);
- break;
}
}
if (field)
@@ -412,7 +420,8 @@ void Item_bool_func2::fix_length_and_dec()
agg_arg_charsets(coll, args, 2, MY_COLL_CMP_CONV, 1))
return;
-
+ args[0]->cmp_context= args[1]->cmp_context=
+ item_cmp_type(args[0]->result_type(), args[1]->result_type());
// Make a special case of compare with fields to get nicer DATE comparisons
if (functype() == LIKE_FUNC) // Disable conversion in case of LIKE function.
@@ -433,6 +442,7 @@ void Item_bool_func2::fix_length_and_dec()
{
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
INT_RESULT); // Works for all types.
+ args[0]->cmp_context= args[1]->cmp_context= INT_RESULT;
return;
}
}
@@ -447,6 +457,7 @@ void Item_bool_func2::fix_length_and_dec()
{
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
INT_RESULT); // Works for all types.
+ args[0]->cmp_context= args[1]->cmp_context= INT_RESULT;
return;
}
}
@@ -1224,6 +1235,7 @@ void Item_func_between::fix_length_and_dec()
if (!args[0] || !args[1] || !args[2])
return;
agg_cmp_type(thd, &cmp_type, args, 3);
+ args[0]->cmp_context= args[1]->cmp_context= args[2]->cmp_context= cmp_type;
if (cmp_type == STRING_RESULT)
agg_arg_charsets(cmp_collation, args, 3, MY_COLL_CMP_CONV, 1);