Commit acecc4dd authored by unknown's avatar unknown
Browse files

A small simplification: perform two actions at once, register a

change, and perform it (the new Item changes registry).


sql/item.cc:
  A small simplification: perform two actions at once, register a
  change, and perform it.
sql/item_cmpfunc.cc:
  register_item_tree_change -> change_item_tree
sql/item_func.cc:
  register_item_tree_change -> change_item_tree
sql/item_row.cc:
  register_item_tree_change -> change_item_tree
sql/item_strfunc.cc:
  register_item_tree_change -> change_item_tree
sql/sql_class.h:
  register_item_tree_change -> change_item_tree
sql/sql_select.cc:
  register_item_tree_change -> change_item_tree
parent fe0a0347
Loading
Loading
Loading
Loading
+10 −15
Original line number Diff line number Diff line
@@ -1332,13 +1332,11 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
	  return -1;
	}

	Item_ref *rf;
	*ref= rf= new Item_ref(last->ref_pointer_array + counter,
			       (char *)table_name,
			       (char *)field_name);
        thd->register_item_tree_change(ref, this, &thd->mem_root);
	Item_ref *rf= new Item_ref(last->ref_pointer_array + counter,
                                   (char *)table_name, (char *)field_name);
	if (!rf)
	  return 1;
        thd->change_item_tree(ref, rf);
	/*
	  rf is Item_ref => never substitute other items (in this case)
	  during fix_fields() => we can use rf after fix_fields()
@@ -1355,11 +1353,11 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
	if (last->having_fix_field)
	{
	  Item_ref *rf;
          thd->register_item_tree_change(ref, *ref, &thd->mem_root);
          *ref= rf= new Item_ref((where->db[0] ? where->db : 0),
          rf= new Item_ref((where->db[0] ? where->db : 0),
                           (char*) where->alias, (char*) field_name);
	  if (!rf)
	    return 1;
          thd->change_item_tree(ref, rf);
	  /*
	    rf is Item_ref => never substitute other items (in this case)
	    during fix_fields() => we can use rf after fix_fields()
@@ -1992,10 +1990,10 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
      else if (tmp != not_found_field)
      {
	ref= 0; // To prevent "delete *ref;" on ~Item_ref() of this item
	Item_field* fld;
	if (!((*reference)= fld= new Item_field(tmp)))
	Item_field* fld= new Item_field(tmp);
	if (!fld)
	  return 1;
	thd->register_item_tree_change(reference, this, &thd->mem_root);
	thd->change_item_tree(reference, fld);
	mark_as_dependent(thd, last, thd->lex->current_select, fld);
	return 0;
      }
@@ -2250,10 +2248,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item)
               new Item_real(name, result, decimals, length));
  }
  if (new_item)
  {
    thd->register_item_tree_change(ref, item, &thd->mem_root);
    *ref= new_item;
  }
    thd->change_item_tree(ref, new_item);
}

/*
+3 −6
Original line number Diff line number Diff line
@@ -153,10 +153,7 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
    {
      Item *tmp=new Item_int_with_ref(field->val_int(), *item);
      if (tmp)
      {
        thd->register_item_tree_change(item, *item, &thd->mem_root);
	*item=tmp;
      }
        thd->change_item_tree(item, tmp);
      return 1;					// Item was replaced
    }
  }
@@ -2033,10 +2030,10 @@ void Item_cond::split_sum_func(THD *thd, Item **ref_pointer_array,
    {
      Item **ref= li.ref();
      uint el= fields.elements;
      Item *new_item= new Item_ref(ref_pointer_array + el, 0, item->name);
      fields.push_front(item);
      ref_pointer_array[el]= item;
      thd->register_item_tree_change(ref, *ref, &thd->mem_root);
      li.replace(new Item_ref(ref_pointer_array + el, 0, item->name));
      thd->change_item_tree(ref, new_item);
    }
    item->update_used_tables();
    used_tables_cache|=item->used_tables();
+2 −2
Original line number Diff line number Diff line
@@ -269,10 +269,10 @@ void Item_func::split_sum_func(THD *thd, Item **ref_pointer_array,
    else if (item->used_tables() || item->type() == SUM_FUNC_ITEM)
    {
      uint el= fields.elements;
      Item *new_item= new Item_ref(ref_pointer_array + el, 0, item->name);
      fields.push_front(item);
      ref_pointer_array[el]= item;
      thd->register_item_tree_change(arg, *arg, &thd->mem_root);
      *arg= new Item_ref(ref_pointer_array + el, 0, item->name);
      thd->change_item_tree(arg, new_item);
    }
  }
}
+2 −2
Original line number Diff line number Diff line
@@ -95,10 +95,10 @@ void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array,
    else if ((*arg)->used_tables() || (*arg)->type() == SUM_FUNC_ITEM)
    {
      uint el= fields.elements;
      Item *new_item= new Item_ref(ref_pointer_array + el, 0, (*arg)->name);
      fields.push_front(*arg);
      ref_pointer_array[el]= *arg;
      thd->register_item_tree_change(arg, *arg, &thd->mem_root);
      *arg= new Item_ref(ref_pointer_array + el, 0, (*arg)->name);
      thd->change_item_tree(arg, new_item);
    }
  }
}
+4 −4
Original line number Diff line number Diff line
@@ -643,10 +643,10 @@ void Item_func_concat_ws::split_sum_func(THD *thd, Item **ref_pointer_array,
  else if (separator->used_tables() || separator->type() == SUM_FUNC_ITEM)
  {
    uint el= fields.elements;
    Item *new_item= new Item_ref(ref_pointer_array + el, 0, separator->name);
    fields.push_front(separator);
    ref_pointer_array[el]= separator;
    thd->register_item_tree_change(&separator, separator, &thd->mem_root);
    separator= new Item_ref(ref_pointer_array + el, 0, separator->name);
    thd->change_item_tree(&separator, new_item);
  }
  Item_str_func::split_sum_func(thd, ref_pointer_array, fields);
}
@@ -1779,10 +1779,10 @@ void Item_func_make_set::split_sum_func(THD *thd, Item **ref_pointer_array,
  else if (item->used_tables() || item->type() == SUM_FUNC_ITEM)
  {
    uint el= fields.elements;
    Item *new_item= new Item_ref(ref_pointer_array + el, 0, item->name);
    fields.push_front(item);
    ref_pointer_array[el]= item;
    thd->register_item_tree_change(&item, item, &thd->mem_root);
    item= new Item_ref(ref_pointer_array + el, 0, item->name);
    thd->change_item_tree(&item, new_item);
  }
  Item_str_func::split_sum_func(thd, ref_pointer_array, fields);
}
Loading