diff options
author | unknown <evgen@moonbone.local> | 2006-06-20 01:56:33 +0400 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2006-06-20 01:56:33 +0400 |
commit | 495c6b13d183d18dd6f0650d7ae9097a33607719 (patch) | |
tree | e579b34c452e1bd180ffa728df40622580e5363c /sql | |
parent | 5375bcad698da2c1ebbe33aff5d86ebccc896f4b (diff) | |
parent | 028fa1e454459e0732b00fc4adc1c0fb7fe6632f (diff) | |
download | mariadb-git-495c6b13d183d18dd6f0650d7ae9097a33607719.tar.gz |
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-4.1
into moonbone.local:/work/tmp_merge-4.1-opt-mysql
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_cmpfunc.cc | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 126037a24d8..5055b5f4197 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -78,9 +78,6 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems) NOTES Aggregation rules: - If all items are constants the type will be aggregated from all items. - If there are some non-constant items then only types of non-constant - items will be used for aggregation. If there are DATE/TIME fields/functions in the list and no string fields/functions in the list then: The INT_RESULT type will be used for aggregation instead of original @@ -167,34 +164,25 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) } } } - /* Reset to 0 on first occurence of non-const item. 1 otherwise */ - bool is_const= items[0]->const_item(); /* If the first item is a date/time function then its result should be compared as int */ if (field) - { - /* Suppose we are comparing dates and some non-constant items are present. */ + /* Suppose we are comparing dates */ type[0]= INT_RESULT; - is_const= 0; - } else type[0]= items[0]->result_type(); for (i= 0; i < nitems ; i++) { - if (!items[i]->const_item()) - { - Item_result result= field && items[i]->result_as_longlong() ? - INT_RESULT : items[i]->result_type(); - type[0]= is_const ? result : item_cmp_type(type[0], result); - is_const= 0; - } - else if (is_const) - type[0]= item_cmp_type(type[0], items[i]->result_type()); - else if (field) - convert_constant_item(thd, field, &items[i]); + Item_result result= items[i]->result_type(); + if (field && + ((!items[i]->const_item() && items[i]->result_as_longlong()) || + (items[i]->const_item() && convert_constant_item(thd, field, + &items[i])))) + result= INT_RESULT; + type[0]= item_cmp_type(type[0], result); } if (res == Item::FUNC_ITEM && field) |