Commit e5f238a0 authored by Sergey Petrunya's avatar Sergey Petrunya

Fix buildbot valgrind failure

- Item_in_subselect::init_left_expr_cache() should not try to 
  guess whether the left expression is accessed "over the grouping operation"
  (i.e. the subselect is evaluated after the grouping while the left_expr is
   an Item_ref that wraps an expression from before the grouping). Instead, 
  let new_Cached_item not to try accessing item->real_item() when creating 
  left expr cache.
parent 0d734037
......@@ -3414,7 +3414,7 @@ void mark_select_range_as_dependent(THD *thd,
Item_ident *resolved_item);
extern Cached_item *new_Cached_item(THD *thd, Item *item,
bool use_result_field);
bool pass_through_ref);
extern Item_result item_cmp_type(Item_result a,Item_result b);
extern void resolve_const_item(THD *thd, Item **ref, Item *cmp_item);
extern int stored_field_cmp_to_item(THD *thd, Field *field, Item *item);
......@@ -27,14 +27,13 @@
Create right type of Cached_item for an item.
*/
Cached_item *new_Cached_item(THD *thd, Item *item, bool use_result_field)
Cached_item *new_Cached_item(THD *thd, Item *item, bool pass_through_ref)
{
if (item->real_item()->type() == Item::FIELD_ITEM &&
if (pass_through_ref && item->real_item()->type() == Item::FIELD_ITEM &&
!(((Item_field *) (item->real_item()))->field->flags & BLOB_FLAG))
{
Item_field *real_item= (Item_field *) item->real_item();
Field *cached_field= use_result_field ? real_item->result_field :
real_item->field;
Field *cached_field= real_item->field;
return new Cached_item_field(cached_field);
}
switch (item->result_type()) {
......
......@@ -2192,8 +2192,6 @@ bool Item_in_subselect::setup_engine()
bool Item_in_subselect::init_left_expr_cache()
{
JOIN *outer_join;
Next_select_func end_select;
bool use_result_field= FALSE;
outer_join= unit->outer_select()->join;
/*
......@@ -2202,18 +2200,6 @@ bool Item_in_subselect::init_left_expr_cache()
*/
if (!outer_join || !outer_join->tables || !outer_join->tables_list)
return TRUE;
/*
If we use end_[send | write]_group to handle complete rows of the outer
query, make the cache of the left IN operand use Item_field::result_field
instead of Item_field::field. We need this because normally
Cached_item_field uses Item::field to fetch field data, while
copy_ref_key() that copies the left IN operand into a lookup key uses
Item::result_field. In the case end_[send | write]_group result_field is
one row behind field.
*/
end_select= outer_join->join_tab[outer_join->tables-1].next_select;
if (end_select == end_send_group || end_select == end_write_group)
use_result_field= TRUE;
if (!(left_expr_cache= new List<Cached_item>))
return TRUE;
......@@ -2222,7 +2208,7 @@ bool Item_in_subselect::init_left_expr_cache()
{
Cached_item *cur_item_cache= new_Cached_item(thd,
left_expr->element_index(i),
use_result_field);
FALSE);
if (!cur_item_cache || left_expr_cache->push_front(cur_item_cache))
return TRUE;
}
......
......@@ -16778,7 +16778,7 @@ alloc_group_fields(JOIN *join,ORDER *group)
{
for (; group ; group=group->next)
{
Cached_item *tmp=new_Cached_item(join->thd, *group->item, FALSE);
Cached_item *tmp=new_Cached_item(join->thd, *group->item, TRUE);
if (!tmp || join->group_fields.push_front(tmp))
return TRUE;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment