#At file:///home/kgeorge/mysql/work/fix-5.1-bugteam/ based on revid:joro@stripped
2894 Georgi Kodinov 2009-05-20
Addendum to bug #44399: add the string type to the mix only of
it will actually be used.
The result of this procedure is used to determine if there will be
typecasting needed and if there will be this may prevent index usage.
@ sql/item_cmpfunc.cc
Bug #44399: add the string type to the comparison mix only if
needed.
modified:
sql/item_cmpfunc.cc
=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc 2009-05-12 13:59:17 +0000
+++ b/sql/item_cmpfunc.cc 2009-05-20 08:20:42 +0000
@@ -207,16 +207,46 @@ static uint collect_cmp_types(Item **ite
Item_result left_result= items[0]->result_type();
DBUG_ASSERT(nitems > 1);
found_types= 0;
+ bool has_cached_items= FALSE;
+
for (i= 1; i < nitems ; i++)
{
+ Item *item= items[i]->real_item();
if ((left_result == ROW_RESULT ||
items[i]->result_type() == ROW_RESULT) &&
cmp_row_type(items[0], items[i]))
return 0;
found_types|= 1<< (uint)item_cmp_type(left_result,
items[i]->result_type());
+
+ /*
+ We will cache the item into a string *only* if a
+
+ 1. We're not in a string function and the item is :
+ - an expression
+ - a subselect
+ - a condition
+ - already cached
+ or
+ 2. This is a BLOB field that is not referenced through an aggregate
+
+ Keep in sync with setup_copy_fields.
+ */
+ if (!has_cached_items &&
+ (((item->type() == Item::FUNC_ITEM ||
+ item->type() == Item::SUBSELECT_ITEM ||
+ item->type() == Item::CACHE_ITEM ||
+ item->type() == Item::COND_ITEM) &&
+ !item->with_sum_func)
+ ||
+ (item->type() == Item::FIELD_ITEM &&
+ !(item != items[i] &&
+ ((Item_ref *)items[i])->ref_type() == Item_ref::AGGREGATE_REF) &&
+ ((Item_field *)item)->field->flags & BLOB_FLAG)))
+ has_cached_items= TRUE;
}
- if (with_sum_func || current_thd->lex->current_select->group_list.elements)
+ if (has_cached_items &&
+ (with_sum_func || current_thd->lex->current_select->group_list.elements))
{
/*
See TODO commentary in the setup_copy_fields function:
Attachment: [text/bzr-bundle] bzr/joro@sun.com-20090520082042-37937y1u3r1zl9nk.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (joro:2894) Bug#44399 | Georgi Kodinov | 20 May |