Commit 9768dc84 authored by unknown's avatar unknown

Pack of changes about 'cleanup()'-s

Some errorneous code trimmed


sql/item.cc:
  initialization of the Item_type_holder::orig_item added
sql/item.h:
  No use to call cleanup() in ~Item
  this only calls Item::cleanup()
  
  We should use item->delete_self() instead of 'delete item' now
  
  Code added to restore Item_type_holder::item_type value
sql/item_row.h:
  this cleanup is wrong
sql/item_sum.cc:
  initialization added
sql/item_sum.h:
  Item_xxx& -> Item_xxx*
sql/sql_parse.cc:
  delete item -> item->delete_self()
parent b44c819b
......@@ -2024,7 +2024,8 @@ void Item_cache_row::bring_value()
Item_type_holder::Item_type_holder(THD *thd, Item *item)
:Item(thd, item), item_type(item->result_type())
:Item(thd, item), item_type(item->result_type()),
orig_type(item_type)
{
DBUG_ASSERT(item->fixed);
......
......@@ -125,7 +125,7 @@ class Item {
optimisation changes in prepared statements
*/
Item(THD *thd, Item *item);
virtual ~Item() { name=0; cleanup(); } /*lint -e1509 */
virtual ~Item() { name=0; } /*lint -e1509 */
void set_name(const char *str,uint length, CHARSET_INFO *cs);
void init_make_field(Send_field *tmp_field,enum enum_field_types type);
virtual void cleanup() { fixed=0; }
......@@ -227,6 +227,11 @@ class Item {
/* Used in sql_select.cc:eliminate_not_funcs() */
virtual Item *neg_transformer() { return NULL; }
void delete_self()
{
cleanup();
delete this;
}
};
......@@ -1003,6 +1008,7 @@ class Item_type_holder: public Item
{
protected:
Item_result item_type;
Item_result orig_type;
Field *field_example;
public:
Item_type_holder(THD*, Item*);
......@@ -1014,6 +1020,11 @@ class Item_type_holder: public Item
String *val_str(String*);
bool join_types(THD *thd, Item *);
Field *example() { return field_example; }
void cleanup()
{
Item::cleanup();
item_type= orig_type;
}
};
......
......@@ -34,16 +34,6 @@ class Item_row: public Item
with_null(0)
{}
void cleanup()
{
if (array_holder && items)
{
sql_element_free(items);
items= 0;
array_holder= 0;
}
}
enum Type type() const { return ROW_ITEM; };
void illegal_method_call(const char *);
bool is_null() { return null_value; }
......
......@@ -1097,6 +1097,7 @@ void Item_sum_count_distinct::cleanup()
if (use_tree)
delete_tree(tree);
table= 0;
use_tree= 0;
}
}
......
......@@ -610,7 +610,7 @@ class Item_sum_udf_float :public Item_sum_num
public:
Item_sum_udf_float(udf_func *udf_arg) :Item_sum_num() {}
Item_sum_udf_float(udf_func *udf_arg, List<Item> &list) :Item_sum_num() {}
Item_sum_udf_float(THD *thd, Item_sum_udf_float &item)
Item_sum_udf_float(THD *thd, Item_sum_udf_float *item)
:Item_sum_num(thd, item) {}
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
double val() { return 0.0; }
......@@ -625,7 +625,7 @@ class Item_sum_udf_int :public Item_sum_num
public:
Item_sum_udf_int(udf_func *udf_arg) :Item_sum_num() {}
Item_sum_udf_int(udf_func *udf_arg, List<Item> &list) :Item_sum_num() {}
Item_sum_udf_int(THD *thd, Item_sum_udf_int &item)
Item_sum_udf_int(THD *thd, Item_sum_udf_int *item)
:Item_sum_num(thd, item) {}
enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; }
longlong val_int() { return 0; }
......@@ -641,7 +641,7 @@ class Item_sum_udf_str :public Item_sum_num
public:
Item_sum_udf_str(udf_func *udf_arg) :Item_sum_num() {}
Item_sum_udf_str(udf_func *udf_arg, List<Item> &list) :Item_sum_num() {}
Item_sum_udf_str(THD *thd, Item_sum_udf_str &item)
Item_sum_udf_str(THD *thd, Item_sum_udf_str *item)
:Item_sum_num(thd, item) {}
String *val_str(String *) { null_value=1; return 0; }
double val() { null_value=1; return 0.0; }
......
......@@ -1109,7 +1109,7 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg)
void free_items(Item *item)
{
for (; item ; item=item->next)
delete item;
item->delete_self();
}
/* This works because items are allocated with sql_alloc() */
......
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