Commit 166d19e9 authored by unknown's avatar unknown
Browse files

Deployment of centralized Item change registry, step 2: Item_ref

doesn't need to have it's own recovery mechanism.


sql/item.cc:
  Deployment of centralized Item change registry, step 2: Item_ref 
  doesn't need to have it's own recovery mechanism, so it was simplified.
sql/item.h:
  Deployment of centralized Item change registry, step 2: Item_ref 
  doesn't need to have it's own recovery mechanism, so it was simplified.
sql/item_cmpfunc.cc:
  - Item::split_sum_func now requires THD
  - use THD::register_item_tree_change
sql/item_cmpfunc.h:
  - Item::split_sum_func now requires THD
sql/item_func.cc:
  - Item::split_sum_func now requires THD
  - use THD::register_item_tree_change
sql/item_func.h:
  - Item::split_sum_func now requires THD
sql/item_row.cc:
  - Item::split_sum_func now requires THD
  - use THD::register_item_tree_change
sql/item_row.h:
  - Item::split_sum_func now requires THD
sql/item_strfunc.cc:
  - Item::split_sum_func now requires THD
  - use THD::register_item_tree_change to register changes in the item
    tree
sql/item_strfunc.h:
  - Item::split_sum_func now requires THD
sql/item_subselect.cc:
  - use updated Item_ref constructor
sql/sql_base.cc:
  - Item::split_sum_func now requires THD
sql/sql_select.cc:
  - Item::split_sum_func now requires THD
sql/sql_yacc.yy:
  - use updated Item_ref constructor
parent c428135e
Loading
Loading
Loading
Loading
+2 −15
Original line number Diff line number Diff line
@@ -1334,7 +1334,6 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)

	Item_ref *rf;
	*ref= rf= new Item_ref(last->ref_pointer_array + counter,
			       0,
			       (char *)table_name,
			       (char *)field_name);
        thd->register_item_tree_change(ref, this, &thd->mem_root);
@@ -1357,10 +1356,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
	{
	  Item_ref *rf;
          thd->register_item_tree_change(ref, *ref, &thd->mem_root);
	  *ref= rf= new Item_ref(ref, 0,
				 (where->db[0]?where->db:0), 
				 (char *)where->alias,
				 (char *)field_name);
          *ref= rf= new Item_ref((where->db[0] ? where->db : 0),
                                 (char*) where->alias, (char*) field_name);
	  if (!rf)
	    return 1;
	  /*
@@ -2061,16 +2058,6 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
}


void Item_ref::cleanup()
{
  DBUG_ENTER("Item_ref::cleanup");
  Item_ident::cleanup();
  if (hook_ptr)
    *hook_ptr= orig_item;
  DBUG_VOID_RETURN;
}


void Item_ref::print(String *str)
{
  if (ref && *ref)
+10 −17
Original line number Diff line number Diff line
@@ -237,7 +237,8 @@ class Item {
  virtual void print(String *str_arg) { str_arg->append(full_name()); }
  void print_item_w_name(String *);
  virtual void update_used_tables() {}
  virtual void split_sum_func(Item **ref_pointer_array, List<Item> &fields) {}
  virtual void split_sum_func(THD *thd, Item **ref_pointer_array,
                              List<Item> &fields) {}
  virtual bool get_date(TIME *ltime,uint fuzzydate);
  virtual bool get_time(TIME *ltime);
  virtual bool get_date_result(TIME *ltime,uint fuzzydate)
@@ -781,20 +782,13 @@ class Item_ref :public Item_ident
public:
  Field *result_field;			 /* Save result here */
  Item **ref;
  Item **hook_ptr;                       /* These two to restore  */
  Item *orig_item;                       /* things in 'cleanup()' */
  Item_ref(Item **hook, Item *original,const char *db_par,
	   const char *table_name_par, const char *field_name_par)
    :Item_ident(db_par,table_name_par,field_name_par),ref(0), hook_ptr(hook),
    orig_item(original) {}
  Item_ref(Item **item, Item **hook, 
	   const char *table_name_par, const char *field_name_par)
    :Item_ident(NullS,table_name_par,field_name_par),
    ref(item), hook_ptr(hook), orig_item(hook ? *hook:0) {}
  // Constructor need to process subselect with temporary tables (see Item)
  Item_ref(THD *thd, Item_ref *item, Item **hook)
    :Item_ident(thd, item), ref(item->ref), 
    hook_ptr(hook), orig_item(hook ? *hook : 0) {}
  Item_ref(const char *db_par, const char *table_name_par,
           const char *field_name_par)
    :Item_ident(db_par, table_name_par, field_name_par), ref(0) {}
  Item_ref(Item **item, const char *table_name_par, const char *field_name_par)
    :Item_ident(NullS, table_name_par, field_name_par), ref(item) {}
  /* Constructor need to process subselect with temporary tables (see Item) */
  Item_ref(THD *thd, Item_ref *item) :Item_ident(thd, item), ref(item->ref) {}
  enum Type type() const		{ return REF_ITEM; }
  bool eq(const Item *item, bool binary_cmp) const
  { return ref && (*ref)->eq(item, binary_cmp); }
@@ -845,7 +839,6 @@ class Item_ref :public Item_ident
  }
  Item *real_item() { return *ref; }
  void print(String *str);
  void cleanup();
};

class Item_in_subselect;
@@ -856,7 +849,7 @@ class Item_ref_null_helper: public Item_ref
public:
  Item_ref_null_helper(Item_in_subselect* master, Item **item,
		       const char *table_name_par, const char *field_name_par):
    Item_ref(item, NULL, table_name_par, field_name_par), owner(master) {}
    Item_ref(item, table_name_par, field_name_par), owner(master) {}
  double val();
  longlong val_int();
  String* val_str(String* s);
+6 −3
Original line number Diff line number Diff line
@@ -2018,7 +2018,8 @@ bool Item_cond::walk(Item_processor processor, byte *arg)
  return Item_func::walk(processor, arg);
}

void Item_cond::split_sum_func(Item **ref_pointer_array, List<Item> &fields)
void Item_cond::split_sum_func(THD *thd, Item **ref_pointer_array,
                               List<Item> &fields)
{
  List_iterator<Item> li(list);
  Item *item;
@@ -2027,13 +2028,15 @@ void Item_cond::split_sum_func(Item **ref_pointer_array, List<Item> &fields)
  while ((item=li++))
  {
    if (item->with_sum_func && item->type() != SUM_FUNC_ITEM)
      item->split_sum_func(ref_pointer_array, fields);
      item->split_sum_func(thd, ref_pointer_array, fields);
    else if (item->used_tables() || item->type() == SUM_FUNC_ITEM)
    {
      Item **ref= li.ref();
      uint el= fields.elements;
      fields.push_front(item);
      ref_pointer_array[el]= item;
      li.replace(new Item_ref(ref_pointer_array + el, li.ref(), 0, item->name));
      thd->register_item_tree_change(ref, *ref, &thd->mem_root);
      li.replace(new Item_ref(ref_pointer_array + el, 0, item->name));
    }
    item->update_used_tables();
    used_tables_cache|=item->used_tables();
+1 −1
Original line number Diff line number Diff line
@@ -931,7 +931,7 @@ class Item_cond :public Item_bool_func
  table_map used_tables() const;
  void update_used_tables();
  void print(String *str);
  void split_sum_func(Item **ref_pointer_array, List<Item> &fields);
  void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
  friend int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds);
  void top_level_item() { abort_on_null=1; }
  void copy_andor_arguments(THD *thd, Item_cond *item);
+5 −3
Original line number Diff line number Diff line
@@ -257,20 +257,22 @@ bool Item_func::walk (Item_processor processor, byte *argument)
  return (this->*processor)(argument);
}

void Item_func::split_sum_func(Item **ref_pointer_array, List<Item> &fields)
void Item_func::split_sum_func(THD *thd, Item **ref_pointer_array,
                               List<Item> &fields)
{
  Item **arg, **arg_end;
  for (arg= args, arg_end= args+arg_count; arg != arg_end ; arg++)
  {
    Item *item=* arg;
    if (item->with_sum_func && item->type() != SUM_FUNC_ITEM)
      item->split_sum_func(ref_pointer_array, fields);
      item->split_sum_func(thd, ref_pointer_array, fields);
    else if (item->used_tables() || item->type() == SUM_FUNC_ITEM)
    {
      uint el= fields.elements;
      fields.push_front(item);
      ref_pointer_array[el]= item;
      *arg= new Item_ref(ref_pointer_array + el, arg, 0, item->name);
      thd->register_item_tree_change(arg, *arg, &thd->mem_root);
      *arg= new Item_ref(ref_pointer_array + el, 0, item->name);
    }
  }
}
Loading