summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2006-08-29 18:58:50 +0400
committerunknown <evgen@moonbone.local>2006-08-29 18:58:50 +0400
commitf57382196baec5f1e92a49ed82415833c34ef59a (patch)
tree9d51093e989e3337f3ebf66b989e6da4245afb95 /sql/item_cmpfunc.cc
parentef535ac807d1dfd184f0ed6bdedc1d88fec92c2b (diff)
parentc17b36d9842703985a9f242515c811c660d6d074 (diff)
downloadmariadb-git-f57382196baec5f1e92a49ed82415833c34ef59a.tar.gz
Merge moonbone.local:/work/tmp_merge-5.0-mysql
into moonbone.local:/work/tmp_merge-5.1-opt-mysql BUILD/check-cpu: Auto merged include/config-netware.h: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/group_by.result: Auto merged mysql-test/r/join_outer.result: Auto merged mysql-test/r/ndb_condition_pushdown.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/select.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/type_datetime.result: Auto merged mysql-test/r/user_var.result: Auto merged mysql-test/r/view.result: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/range.test: Auto merged mysql-test/t/select.test: Auto merged mysql-test/t/type_datetime.test: Auto merged mysql-test/t/view.test: Auto merged sql/ha_innodb.cc: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_subselect.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/opt_range.h: Auto merged sql/set_var.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_update.cc: Auto merged storage/innobase/btr/btr0btr.c: Auto merged storage/innobase/buf/buf0buf.c: Auto merged storage/innobase/dict/dict0dict.c: Auto merged storage/innobase/fil/fil0fil.c: Auto merged storage/innobase/fsp/fsp0fsp.c: Auto merged storage/innobase/include/buf0buf.ic: Auto merged storage/innobase/log/log0log.c: Auto merged storage/innobase/log/log0recv.c: Auto merged storage/innobase/os/os0file.c: Auto merged storage/innobase/row/row0sel.c: Auto merged storage/innobase/srv/srv0start.c: Auto merged storage/innobase/ut/ut0dbg.c: Auto merged tests/mysql_client_test.c: Auto merged client/mysqltest.c: Manual merge mysql-test/r/innodb_mysql.result: Manual merge mysql-test/t/innodb_mysql.test: Manual merge mysql-test/t/join_outer.test: Manual merge sql/item_cmpfunc.cc: Manual merge sql/mysql_priv.h: Manual merge sql/opt_range.cc: Manual merge sql/sql_base.cc: Manual merge storage/innobase/include/btr0cur.ic: Manual merge storage/innobase/row/row0mysql.c: Manual merge
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 d3272fae4ed..87979bc8c25 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);