Commit 1f8eb403 authored by hf@deer.(none)'s avatar hf@deer.(none)

Code cleanup (working on PS & cleanup() code)

Item & changed with Item* in Item_xxx constructors
tables_list.first -> get_table_list()
parent f97cc835
...@@ -71,18 +71,18 @@ Item::Item(): ...@@ -71,18 +71,18 @@ Item::Item():
Used for duplicating lists in processing queries with temporary Used for duplicating lists in processing queries with temporary
tables tables
*/ */
Item::Item(THD *thd, Item &item): Item::Item(THD *thd, Item *item):
str_value(item.str_value), str_value(item->str_value),
name(item.name), name(item->name),
max_length(item.max_length), max_length(item->max_length),
marker(item.marker), marker(item->marker),
decimals(item.decimals), decimals(item->decimals),
maybe_null(item.maybe_null), maybe_null(item->maybe_null),
null_value(item.null_value), null_value(item->null_value),
unsigned_flag(item.unsigned_flag), unsigned_flag(item->unsigned_flag),
with_sum_func(item.with_sum_func), with_sum_func(item->with_sum_func),
fixed(item.fixed), fixed(item->fixed),
collation(item.collation) collation(item->collation)
{ {
next= thd->free_list; // Put in free list next= thd->free_list; // Put in free list
thd->free_list= this; thd->free_list= this;
...@@ -110,12 +110,12 @@ Item_ident::Item_ident(const char *db_name_par,const char *table_name_par, ...@@ -110,12 +110,12 @@ Item_ident::Item_ident(const char *db_name_par,const char *table_name_par,
} }
// Constructor used by Item_field & Item_ref (see Item comment) // Constructor used by Item_field & Item_ref (see Item comment)
Item_ident::Item_ident(THD *thd, Item_ident &item): Item_ident::Item_ident(THD *thd, Item_ident *item):
Item(thd, item), Item(thd, item),
db_name(item.db_name), db_name(item->db_name),
table_name(item.table_name), table_name(item->table_name),
field_name(item.field_name), field_name(item->field_name),
depended_from(item.depended_from) depended_from(item->depended_from)
{} {}
bool Item_ident::remove_dependence_processor(byte * arg) bool Item_ident::remove_dependence_processor(byte * arg)
...@@ -296,10 +296,10 @@ Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name) ...@@ -296,10 +296,10 @@ Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name)
} }
// Constructor need to process subselect with temporary tables (see Item) // Constructor need to process subselect with temporary tables (see Item)
Item_field::Item_field(THD *thd, Item_field &item) Item_field::Item_field(THD *thd, Item_field *item)
:Item_ident(thd, item), :Item_ident(thd, item),
field(item.field), field(item->field),
result_field(item.result_field) result_field(item->result_field)
{ {
collation.set(DERIVATION_IMPLICIT); collation.set(DERIVATION_IMPLICIT);
} }
...@@ -455,7 +455,7 @@ table_map Item_field::used_tables() const ...@@ -455,7 +455,7 @@ table_map Item_field::used_tables() const
Item *Item_field::get_tmp_table_item(THD *thd) Item *Item_field::get_tmp_table_item(THD *thd)
{ {
Item_field *new_item= new Item_field(thd, *this); Item_field *new_item= new Item_field(thd, this);
if (new_item) if (new_item)
new_item->field= new_item->result_field; new_item->field= new_item->result_field;
return new_item; return new_item;
...@@ -937,7 +937,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -937,7 +937,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if (last->having_fix_field) if (last->having_fix_field)
{ {
Item_ref *rf; Item_ref *rf;
*ref= rf= new Item_ref(ref, this, *ref= rf= new Item_ref(ref, *ref,
(where->db[0]?where->db:0), (where->db[0]?where->db:0),
(char *)where->alias, (char *)where->alias,
(char *)field_name); (char *)field_name);
...@@ -967,8 +967,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -967,8 +967,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
void Item_field::cleanup() void Item_field::cleanup()
{ {
Item_ident::cleanup(); Item_ident::cleanup();
field= 0; field= result_field= 0;
result_field= 0;
} }
void Item::init_make_field(Send_field *tmp_field, void Item::init_make_field(Send_field *tmp_field,
...@@ -2028,7 +2027,7 @@ void Item_cache_row::bring_value() ...@@ -2028,7 +2027,7 @@ void Item_cache_row::bring_value()
Item_type_holder::Item_type_holder(THD *thd, Item *item) 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())
{ {
DBUG_ASSERT(item->fixed); DBUG_ASSERT(item->fixed);
......
...@@ -124,7 +124,7 @@ public: ...@@ -124,7 +124,7 @@ public:
top AND/OR ctructure of WHERE clause to protect it of top AND/OR ctructure of WHERE clause to protect it of
optimisation changes in prepared statements optimisation changes in prepared statements
*/ */
Item(THD *thd, Item &item); Item(THD *thd, Item *item);
virtual ~Item() { name=0; cleanup(); } /*lint -e1509 */ virtual ~Item() { name=0; cleanup(); } /*lint -e1509 */
void set_name(const char *str,uint length, CHARSET_INFO *cs); void set_name(const char *str,uint length, CHARSET_INFO *cs);
void init_make_field(Send_field *tmp_field,enum enum_field_types type); void init_make_field(Send_field *tmp_field,enum enum_field_types type);
...@@ -240,7 +240,7 @@ public: ...@@ -240,7 +240,7 @@ public:
st_select_lex *depended_from; st_select_lex *depended_from;
Item_ident(const char *db_name_par,const char *table_name_par, Item_ident(const char *db_name_par,const char *table_name_par,
const char *field_name_par); const char *field_name_par);
Item_ident::Item_ident(THD *thd, Item_ident &item); Item_ident::Item_ident(THD *thd, Item_ident *item);
const char *full_name() const; const char *full_name() const;
bool remove_dependence_processor(byte * arg); bool remove_dependence_processor(byte * arg);
...@@ -259,7 +259,7 @@ public: ...@@ -259,7 +259,7 @@ public:
:Item_ident(db_par,table_name_par,field_name_par),field(0),result_field(0) :Item_ident(db_par,table_name_par,field_name_par),field(0),result_field(0)
{ collation.set(DERIVATION_IMPLICIT); } { collation.set(DERIVATION_IMPLICIT); }
// Constructor need to process subselect with temporary tables (see Item) // Constructor need to process subselect with temporary tables (see Item)
Item_field(THD *thd, Item_field &item); Item_field(THD *thd, Item_field *item);
Item_field(Field *field); Item_field(Field *field);
enum Type type() const { return FIELD_ITEM; } enum Type type() const { return FIELD_ITEM; }
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
...@@ -581,8 +581,8 @@ public: ...@@ -581,8 +581,8 @@ public:
Field *result_field; /* Save result here */ Field *result_field; /* Save result here */
Item_result_field() :result_field(0) {} Item_result_field() :result_field(0) {}
// Constructor used for Item_sum/Item_cond_and/or (see Item comment) // Constructor used for Item_sum/Item_cond_and/or (see Item comment)
Item_result_field(THD *thd, Item_result_field &item): Item_result_field(THD *thd, Item_result_field *item):
Item(thd, item), result_field(item.result_field) Item(thd, item), result_field(item->result_field)
{} {}
~Item_result_field() {} /* Required with gcc 2.95 */ ~Item_result_field() {} /* Required with gcc 2.95 */
Field *get_tmp_table_field() { return result_field; } Field *get_tmp_table_field() { return result_field; }
...@@ -614,8 +614,8 @@ public: ...@@ -614,8 +614,8 @@ public:
:Item_ident(NullS,table_name_par,field_name_par), :Item_ident(NullS,table_name_par,field_name_par),
ref(item), hook_ptr(hook), orig_item(hook ? *hook:0) {} ref(item), hook_ptr(hook), orig_item(hook ? *hook:0) {}
// Constructor need to process subselect with temporary tables (see Item) // Constructor need to process subselect with temporary tables (see Item)
Item_ref(THD *thd, Item_ref &item, Item **hook) Item_ref(THD *thd, Item_ref *item, Item **hook)
:Item_ident(thd, item), ref(item.ref), :Item_ident(thd, item), ref(item->ref),
hook_ptr(hook), orig_item(hook ? *hook : 0) {} hook_ptr(hook), orig_item(hook ? *hook : 0) {}
enum Type type() const { return REF_ITEM; } enum Type type() const { return REF_ITEM; }
bool eq(const Item *item, bool binary_cmp) const bool eq(const Item *item, bool binary_cmp) const
......
...@@ -1651,10 +1651,10 @@ longlong Item_func_bit_and::val_int() ...@@ -1651,10 +1651,10 @@ longlong Item_func_bit_and::val_int()
return (longlong) (arg1 & arg2); return (longlong) (arg1 & arg2);
} }
Item_cond::Item_cond(THD *thd, Item_cond &item) Item_cond::Item_cond(THD *thd, Item_cond *item)
:Item_bool_func(thd, item), :Item_bool_func(thd, item),
abort_on_null(item.abort_on_null), abort_on_null(item->abort_on_null),
and_tables_cache(item.and_tables_cache) and_tables_cache(item->and_tables_cache)
{ {
/* /*
here should be following text: here should be following text:
......
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
Item_bool_func() :Item_int_func() {} Item_bool_func() :Item_int_func() {}
Item_bool_func(Item *a) :Item_int_func(a) {} Item_bool_func(Item *a) :Item_int_func(a) {}
Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {} Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {}
Item_bool_func(THD *thd, Item_bool_func &item) :Item_int_func(thd, item) {} Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {}
void fix_length_and_dec() { decimals=0; max_length=1; } void fix_length_and_dec() { decimals=0; max_length=1; }
}; };
...@@ -889,7 +889,7 @@ public: ...@@ -889,7 +889,7 @@ public:
list.push_back(i1); list.push_back(i1);
list.push_back(i2); list.push_back(i2);
} }
Item_cond(THD *thd, Item_cond &item); Item_cond(THD *thd, Item_cond *item);
Item_cond(List<Item> &nlist) Item_cond(List<Item> &nlist)
:Item_bool_func(), list(nlist), abort_on_null(0) {} :Item_bool_func(), list(nlist), abort_on_null(0) {}
bool add(Item *item) { return list.push_back(item); } bool add(Item *item) { return list.push_back(item); }
...@@ -914,7 +914,7 @@ class Item_cond_and :public Item_cond ...@@ -914,7 +914,7 @@ class Item_cond_and :public Item_cond
public: public:
Item_cond_and() :Item_cond() {} Item_cond_and() :Item_cond() {}
Item_cond_and(Item *i1,Item *i2) :Item_cond(i1,i2) {} Item_cond_and(Item *i1,Item *i2) :Item_cond(i1,i2) {}
Item_cond_and(THD *thd, Item_cond_and &item) :Item_cond(thd, item) {} Item_cond_and(THD *thd, Item_cond_and *item) :Item_cond(thd, item) {}
Item_cond_and(List<Item> &list): Item_cond(list) {} Item_cond_and(List<Item> &list): Item_cond(list) {}
enum Functype functype() const { return COND_AND_FUNC; } enum Functype functype() const { return COND_AND_FUNC; }
longlong val_int(); longlong val_int();
...@@ -922,7 +922,7 @@ public: ...@@ -922,7 +922,7 @@ public:
Item* copy_andor_structure(THD *thd) Item* copy_andor_structure(THD *thd)
{ {
Item_cond_and *item; Item_cond_and *item;
if((item= new Item_cond_and(thd, *this))) if((item= new Item_cond_and(thd, this)))
item->copy_andor_arguments(thd, this); item->copy_andor_arguments(thd, this);
return item; return item;
} }
...@@ -934,7 +934,7 @@ class Item_cond_or :public Item_cond ...@@ -934,7 +934,7 @@ class Item_cond_or :public Item_cond
public: public:
Item_cond_or() :Item_cond() {} Item_cond_or() :Item_cond() {}
Item_cond_or(Item *i1,Item *i2) :Item_cond(i1,i2) {} Item_cond_or(Item *i1,Item *i2) :Item_cond(i1,i2) {}
Item_cond_or(THD *thd, Item_cond_or &item) :Item_cond(thd, item) {} Item_cond_or(THD *thd, Item_cond_or *item) :Item_cond(thd, item) {}
Item_cond_or(List<Item> &list): Item_cond(list) {} Item_cond_or(List<Item> &list): Item_cond(list) {}
enum Functype functype() const { return COND_OR_FUNC; } enum Functype functype() const { return COND_OR_FUNC; }
longlong val_int(); longlong val_int();
...@@ -943,7 +943,7 @@ public: ...@@ -943,7 +943,7 @@ public:
Item* copy_andor_structure(THD *thd) Item* copy_andor_structure(THD *thd)
{ {
Item_cond_or *item; Item_cond_or *item;
if((item= new Item_cond_or(thd, *this))) if((item= new Item_cond_or(thd, this)))
item->copy_andor_arguments(thd, this); item->copy_andor_arguments(thd, this);
return item; return item;
} }
......
...@@ -130,13 +130,13 @@ Item_func::Item_func(List<Item> &list) ...@@ -130,13 +130,13 @@ Item_func::Item_func(List<Item> &list)
set_arguments(list); set_arguments(list);
} }
Item_func::Item_func(THD *thd, Item_func &item) Item_func::Item_func(THD *thd, Item_func *item)
:Item_result_field(thd, item), :Item_result_field(thd, item),
allowed_arg_cols(item.allowed_arg_cols), allowed_arg_cols(item->allowed_arg_cols),
arg_count(item.arg_count), arg_count(item->arg_count),
used_tables_cache(item.used_tables_cache), used_tables_cache(item->used_tables_cache),
not_null_tables_cache(item.not_null_tables_cache), not_null_tables_cache(item->not_null_tables_cache),
const_item_cache(item.const_item_cache) const_item_cache(item->const_item_cache)
{ {
if (arg_count) if (arg_count)
{ {
...@@ -147,7 +147,7 @@ Item_func::Item_func(THD *thd, Item_func &item) ...@@ -147,7 +147,7 @@ Item_func::Item_func(THD *thd, Item_func &item)
if (!(args=(Item**) thd->alloc(sizeof(Item*)*arg_count))) if (!(args=(Item**) thd->alloc(sizeof(Item*)*arg_count)))
return; return;
} }
memcpy((char*) args, (char*) item.args, sizeof(Item*)*arg_count); memcpy((char*) args, (char*) item->args, sizeof(Item*)*arg_count);
} }
} }
......
...@@ -106,7 +106,7 @@ public: ...@@ -106,7 +106,7 @@ public:
} }
Item_func(List<Item> &list); Item_func(List<Item> &list);
// Constructor used for Item_cond_and/or (see Item comment) // Constructor used for Item_cond_and/or (see Item comment)
Item_func(THD *thd, Item_func &item); Item_func(THD *thd, Item_func *item);
bool fix_fields(THD *,struct st_table_list *, Item **ref); bool fix_fields(THD *,struct st_table_list *, Item **ref);
table_map used_tables() const; table_map used_tables() const;
table_map not_null_tables() const; table_map not_null_tables() const;
...@@ -199,7 +199,7 @@ public: ...@@ -199,7 +199,7 @@ public:
Item_int_func(Item *a,Item *b) :Item_func(a,b) { max_length=21; } Item_int_func(Item *a,Item *b) :Item_func(a,b) { max_length=21; }
Item_int_func(Item *a,Item *b,Item *c) :Item_func(a,b,c) { max_length=21; } Item_int_func(Item *a,Item *b,Item *c) :Item_func(a,b,c) { max_length=21; }
Item_int_func(List<Item> &list) :Item_func(list) { max_length=21; } Item_int_func(List<Item> &list) :Item_func(list) { max_length=21; }
Item_int_func(THD *thd, Item_int_func &item) :Item_func(thd, item) {} Item_int_func(THD *thd, Item_int_func *item) :Item_func(thd, item) {}
double val() { return (double) val_int(); } double val() { return (double) val_int(); }
String *val_str(String*str); String *val_str(String*str);
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
......
...@@ -42,17 +42,17 @@ Item_sum::Item_sum(List<Item> &list) ...@@ -42,17 +42,17 @@ Item_sum::Item_sum(List<Item> &list)
} }
// Constructor used in processing select with temporary tebles // Constructor used in processing select with temporary tebles
Item_sum::Item_sum(THD *thd, Item_sum &item): Item_sum::Item_sum(THD *thd, Item_sum *item):
Item_result_field(thd, item), quick_group(item.quick_group) Item_result_field(thd, item), quick_group(item->quick_group)
{ {
arg_count= item.arg_count; arg_count= item->arg_count;
if (arg_count <= 2) if (arg_count <= 2)
args=tmp_args; args=tmp_args;
else else
if (!(args=(Item**) sql_alloc(sizeof(Item*)*arg_count))) if (!(args=(Item**) sql_alloc(sizeof(Item*)*arg_count)))
return; return;
for (uint i= 0; i < arg_count; i++) for (uint i= 0; i < arg_count; i++)
args[i]= item.args[i]; args[i]= item->args[i];
} }
void Item_sum::mark_as_sum_func() void Item_sum::mark_as_sum_func()
...@@ -240,7 +240,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -240,7 +240,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
Item *Item_sum_sum::copy_or_same(THD* thd) Item *Item_sum_sum::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_sum(thd, *this); return new (&thd->mem_root) Item_sum_sum(thd, this);
} }
...@@ -267,7 +267,7 @@ double Item_sum_sum::val() ...@@ -267,7 +267,7 @@ double Item_sum_sum::val()
Item *Item_sum_count::copy_or_same(THD* thd) Item *Item_sum_count::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_count(thd, *this); return new (&thd->mem_root) Item_sum_count(thd, this);
} }
...@@ -301,7 +301,7 @@ longlong Item_sum_count::val_int() ...@@ -301,7 +301,7 @@ longlong Item_sum_count::val_int()
Item *Item_sum_avg::copy_or_same(THD* thd) Item *Item_sum_avg::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_avg(thd, *this); return new (&thd->mem_root) Item_sum_avg(thd, this);
} }
...@@ -346,7 +346,7 @@ double Item_sum_std::val() ...@@ -346,7 +346,7 @@ double Item_sum_std::val()
Item *Item_sum_std::copy_or_same(THD* thd) Item *Item_sum_std::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_std(thd, *this); return new (&thd->mem_root) Item_sum_std(thd, this);
} }
...@@ -356,7 +356,7 @@ Item *Item_sum_std::copy_or_same(THD* thd) ...@@ -356,7 +356,7 @@ Item *Item_sum_std::copy_or_same(THD* thd)
Item *Item_sum_variance::copy_or_same(THD* thd) Item *Item_sum_variance::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_variance(thd, *this); return new (&thd->mem_root) Item_sum_variance(thd, this);
} }
...@@ -497,7 +497,7 @@ Item_sum_hybrid::val_str(String *str) ...@@ -497,7 +497,7 @@ Item_sum_hybrid::val_str(String *str)
Item *Item_sum_min::copy_or_same(THD* thd) Item *Item_sum_min::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_min(thd, *this); return new (&thd->mem_root) Item_sum_min(thd, this);
} }
...@@ -550,7 +550,7 @@ bool Item_sum_min::add() ...@@ -550,7 +550,7 @@ bool Item_sum_min::add()
Item *Item_sum_max::copy_or_same(THD* thd) Item *Item_sum_max::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_max(thd, *this); return new (&thd->mem_root) Item_sum_max(thd, this);
} }
...@@ -616,7 +616,7 @@ void Item_sum_bit::clear() ...@@ -616,7 +616,7 @@ void Item_sum_bit::clear()
Item *Item_sum_or::copy_or_same(THD* thd) Item *Item_sum_or::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_or(thd, *this); return new (&thd->mem_root) Item_sum_or(thd, this);
} }
...@@ -630,7 +630,7 @@ bool Item_sum_or::add() ...@@ -630,7 +630,7 @@ bool Item_sum_or::add()
Item *Item_sum_xor::copy_or_same(THD* thd) Item *Item_sum_xor::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_xor(thd, *this); return new (&thd->mem_root) Item_sum_xor(thd, this);
} }
...@@ -644,7 +644,7 @@ bool Item_sum_xor::add() ...@@ -644,7 +644,7 @@ bool Item_sum_xor::add()
Item *Item_sum_and::copy_or_same(THD* thd) Item *Item_sum_and::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_and(thd, *this); return new (&thd->mem_root) Item_sum_and(thd, this);
} }
...@@ -1281,7 +1281,7 @@ int Item_sum_count_distinct::tree_to_myisam() ...@@ -1281,7 +1281,7 @@ int Item_sum_count_distinct::tree_to_myisam()
Item *Item_sum_count_distinct::copy_or_same(THD* thd) Item *Item_sum_count_distinct::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_count_distinct(thd, *this); return new (&thd->mem_root) Item_sum_count_distinct(thd, this);
} }
...@@ -1381,7 +1381,7 @@ bool Item_udf_sum::add() ...@@ -1381,7 +1381,7 @@ bool Item_udf_sum::add()
Item *Item_sum_udf_float::copy_or_same(THD* thd) Item *Item_sum_udf_float::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_udf_float(thd, *this); return new (&thd->mem_root) Item_sum_udf_float(thd, this);
} }
double Item_sum_udf_float::val() double Item_sum_udf_float::val()
...@@ -1404,7 +1404,7 @@ String *Item_sum_udf_float::val_str(String *str) ...@@ -1404,7 +1404,7 @@ String *Item_sum_udf_float::val_str(String *str)
Item *Item_sum_udf_int::copy_or_same(THD* thd) Item *Item_sum_udf_int::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_udf_int(thd, *this); return new (&thd->mem_root) Item_sum_udf_int(thd, this);
} }
...@@ -1440,7 +1440,7 @@ void Item_sum_udf_str::fix_length_and_dec() ...@@ -1440,7 +1440,7 @@ void Item_sum_udf_str::fix_length_and_dec()
Item *Item_sum_udf_str::copy_or_same(THD* thd) Item *Item_sum_udf_str::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_sum_udf_str(thd, *this); return new (&thd->mem_root) Item_sum_udf_str(thd, this);
} }
...@@ -1701,7 +1701,7 @@ Item_func_group_concat::~Item_func_group_concat() ...@@ -1701,7 +1701,7 @@ Item_func_group_concat::~Item_func_group_concat()
Item *Item_func_group_concat::copy_or_same(THD* thd) Item *Item_func_group_concat::copy_or_same(THD* thd)
{ {
return new (&thd->mem_root) Item_func_group_concat(thd, *this); return new (&thd->mem_root) Item_func_group_concat(thd, this);
} }
......
...@@ -57,7 +57,7 @@ public: ...@@ -57,7 +57,7 @@ public:
} }
Item_sum(List<Item> &list); Item_sum(List<Item> &list);
//Copy constructor, need to perform subselects with temporary tables //Copy constructor, need to perform subselects with temporary tables
Item_sum(THD *thd, Item_sum &item); Item_sum(THD *thd, Item_sum *item);
void cleanup() void cleanup()
{ {
Item_result_field::cleanup(); Item_result_field::cleanup();
...@@ -110,7 +110,7 @@ public: ...@@ -110,7 +110,7 @@ public:
Item_sum_num(Item *item_par) :Item_sum(item_par) {} Item_sum_num(Item *item_par) :Item_sum(item_par) {}
Item_sum_num(Item *a, Item* b) :Item_sum(a,b) {} Item_sum_num(Item *a, Item* b) :Item_sum(a,b) {}
Item_sum_num(List<Item> &list) :Item_sum(list) {} Item_sum_num(List<Item> &list) :Item_sum(list) {}
Item_sum_num(THD *thd, Item_sum_num &item) :Item_sum(thd, item) {} Item_sum_num(THD *thd, Item_sum_num *item) :Item_sum(thd, item) {}
bool fix_fields(THD *, TABLE_LIST *, Item **); bool fix_fields(THD *, TABLE_LIST *, Item **);
longlong val_int() { return (longlong) val(); } /* Real as default */ longlong val_int() { return (longlong) val(); } /* Real as default */
String *val_str(String*str); String *val_str(String*str);
...@@ -123,7 +123,7 @@ class Item_sum_int :public Item_sum_num ...@@ -123,7 +123,7 @@ class Item_sum_int :public Item_sum_num
public: public:
Item_sum_int(Item *item_par) :Item_sum_num(item_par) {} Item_sum_int(Item *item_par) :Item_sum_num(item_par) {}
Item_sum_int(List<Item> &list) :Item_sum_num(list) {} Item_sum_int(List<Item> &list) :Item_sum_num(list) {}
Item_sum_int(THD *thd, Item_sum_int &item) :Item_sum_num(thd, item) {} Item_sum_int(THD *thd, Item_sum_int *item) :Item_sum_num(thd, item) {}
double val() { return (double) val_int(); } double val() { return (double) val_int(); }
String *val_str(String*str); String *val_str(String*str);
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
...@@ -139,8 +139,8 @@ class Item_sum_sum :public Item_sum_num ...@@ -139,8 +139,8 @@ class Item_sum_sum :public Item_sum_num
public: public:
Item_sum_sum(Item *item_par) :Item_sum_num(item_par),sum(0.0) {} Item_sum_sum(Item *item_par) :Item_sum_num(item_par),sum(0.0) {}
Item_sum_sum(THD *thd, Item_sum_sum &item) Item_sum_sum(THD *thd, Item_sum_sum *item)
:Item_sum_num(thd, item), sum(item.sum) {} :Item_sum_num(thd, item), sum(item->sum) {}
enum Sumfunctype sum_func () const {return SUM_FUNC;} enum Sumfunctype sum_func () const {return SUM_FUNC;}
void clear(); void clear();
bool add(); bool add();
...@@ -162,9 +162,9 @@ class Item_sum_count :public Item_sum_int ...@@ -162,9 +162,9 @@ class Item_sum_count :public Item_sum_int
Item_sum_count(Item *item_par) Item_sum_count(Item *item_par)
:Item_sum_int(item_par),count(0),used_table_cache(~(table_map) 0) :Item_sum_int(item_par),count(0),used_table_cache(~(table_map) 0)
{} {}
Item_sum_count(THD *thd, Item_sum_count &item) Item_sum_count(THD *thd, Item_sum_count *item)
:Item_sum_int(thd, item), count(item.count), :Item_sum_int(thd, item), count(item->count),
used_table_cache(item.used_table_cache) used_table_cache(item->used_table_cache)
{} {}
table_map used_tables() const { return used_table_cache; } table_map used_tables() const { return used_table_cache; }
bool const_item() const { return !used_table_cache; } bool const_item() const { return !used_table_cache; }
...@@ -230,14 +230,14 @@ class Item_sum_count_distinct :public Item_sum_int ...@@ -230,14 +230,14 @@ class Item_sum_count_distinct :public Item_sum_int
tmp_table_param(0), tree(&tree_base), original(0), use_tree(0), tmp_table_param(0), tree(&tree_base), original(0), use_tree(0),
always_null(0) always_null(0)
{ quick_group= 0; } { quick_group= 0; }
Item_sum_count_distinct(THD *thd, Item_sum_count_distinct &item) Item_sum_count_distinct(THD *thd, Item_sum_count_distinct *item)
:Item_sum_int(thd, item), table(item.table), :Item_sum_int(thd, item), table(item->table),
used_table_cache(item.used_table_cache), used_table_cache(item->used_table_cache),
field_lengths(item.field_lengths), tmp_table_param(item.tmp_table_param), field_lengths(item->field_lengths), tmp_table_param(item->tmp_table_param),
tree(item.tree), original(&item), key_length(item.key_length), tree(item->tree), original(item), key_length(item->key_length),
max_elements_in_tree(item.max_elements_in_tree), max_elements_in_tree(item->max_elements_in_tree),
rec_offset(item.rec_offset), use_tree(item.use_tree), rec_offset(item->rec_offset), use_tree(item->use_tree),
always_null(item.always_null) always_null(item->always_null)
{} {}
void cleanup(); void cleanup();
...@@ -285,8 +285,8 @@ class Item_sum_avg :public Item_sum_num ...@@ -285,8 +285,8 @@ class Item_sum_avg :public Item_sum_num
public: public:
Item_sum_avg(Item *item_par) :Item_sum_num(item_par),count(0) {} Item_sum_avg(Item *item_par) :Item_sum_num(item_par),count(0) {}
Item_sum_avg(THD *thd, Item_sum_avg &item) Item_sum_avg(THD *thd, Item_sum_avg *item)
:Item_sum_num(thd, item), sum(item.sum), count(item.count) {} :Item_sum_num(thd, item), sum(item->sum), count(item->count) {}
enum Sumfunctype sum_func () const {return AVG_FUNC;} enum Sumfunctype sum_func () const {return AVG_FUNC;}
void clear(); void clear();
bool add(); bool add();
...@@ -337,9 +337,9 @@ class Item_sum_variance : public Item_sum_num ...@@ -337,9 +337,9 @@ class Item_sum_variance : public Item_sum_num
public: public:
Item_sum_variance(Item *item_par) :Item_sum_num(item_par),count(0) {} Item_sum_variance(Item *item_par) :Item_sum_num(item_par),count(0) {}
Item_sum_variance(THD *thd, Item_sum_variance &item): Item_sum_variance(THD *thd, Item_sum_variance *item):
Item_sum_num(thd, item), sum(item.sum), sum_sqr(item.sum_sqr), Item_sum_num(thd, item), sum(item->sum), sum_sqr(item->sum_sqr),
count(item.count) {} count(item->count) {}
enum Sumfunctype sum_func () const { return VARIANCE_FUNC; } enum Sumfunctype sum_func () const { return VARIANCE_FUNC; }
void clear(); void clear();
bool add(); bool add();
...@@ -370,7 +370,7 @@ class Item_sum_std :public Item_sum_variance ...@@ -370,7 +370,7 @@ class Item_sum_std :public Item_sum_variance
{ {
public: public:
Item_sum_std(Item *item_par) :Item_sum_variance(item_par) {} Item_sum_std(Item *item_par) :Item_sum_variance(item_par) {}
Item_sum_std(THD *thd, Item_sum_std &item) Item_sum_std(THD *thd, Item_sum_std *item)
:Item_sum_variance(thd, item) :Item_sum_variance(thd, item)
{} {}
enum Sumfunctype sum_func () const { return STD_FUNC; } enum Sumfunctype sum_func () const { return STD_FUNC; }
...@@ -401,11 +401,11 @@ class Item_sum_hybrid :public Item_sum ...@@ -401,11 +401,11 @@ class Item_sum_hybrid :public Item_sum
used_table_cache(~(table_map) 0), used_table_cache(~(table_map) 0),
cmp_charset(&my_charset_bin) cmp_charset(&my_charset_bin)
{} {}
Item_sum_hybrid(THD *thd, Item_sum_hybrid &item): Item_sum_hybrid(THD *thd, Item_sum_hybrid *item):
Item_sum(thd, item), value(item.value), tmp_value(item.tmp_value), Item_sum(thd, item), value(item->value), tmp_value(item->tmp_value),
sum(item.sum), sum_int(item.sum_int), hybrid_type(item.hybrid_type), sum(item->sum), sum_int(item->sum_int), hybrid_type(item->hybrid_type),
hybrid_field_type(item.hybrid_field_type),cmp_sign(item.cmp_sign), hybrid_field_type(item->hybrid_field_type),cmp_sign(item->cmp_sign),
used_table_cache(item.used_table_cache), cmp_charset(item.cmp_charset) {} used_table_cache(item->used_table_cache), cmp_charset(item->cmp_charset) {}
bool fix_fields(THD *, TABLE_LIST *, Item **); bool fix_fields(THD *, TABLE_LIST *, Item **);
table_map used_tables() const { return used_table_cache; } table_map used_tables() const { return used_table_cache; }
bool const_item() const { return !used_table_cache; } bool const_item() const { return !used_table_cache; }
...@@ -436,7 +436,7 @@ class Item_sum_min :public Item_sum_hybrid ...@@ -436,7 +436,7 @@ class Item_sum_min :public Item_sum_hybrid
{ {
public: public:
Item_sum_min(Item *item_par) :Item_sum_hybrid(item_par,1) {} Item_sum_min(Item *item_par) :Item_sum_hybrid(item_par,1) {}
Item_sum_min(THD *thd, Item_sum_min &item) :Item_sum_hybrid(thd, item) {} Item_sum_min(THD *thd, Item_sum_min *item) :Item_sum_hybrid(thd, item) {}
enum Sumfunctype sum_func () const {return MIN_FUNC;} enum Sumfunctype sum_func () const {return MIN_FUNC;}
bool add(); bool add();
...@@ -449,7 +449,7 @@ class Item_sum_max :public Item_sum_hybrid ...@@ -449,7 +449,7 @@ class Item_sum_max :public Item_sum_hybrid
{ {
public: public:
Item_sum_max(Item *item_par) :Item_sum_hybrid(item_par,-1) {} Item_sum_max(Item *item_par) :Item_sum_hybrid(item_par,-1) {}
Item_sum_max(THD *thd, Item_sum_max &item) :Item_sum_hybrid(thd, item) {} Item_sum_max(THD *thd, Item_sum_max *item) :Item_sum_hybrid(thd, item) {}
enum Sumfunctype sum_func () const {return MAX_FUNC;} enum Sumfunctype sum_func () const {return MAX_FUNC;}
bool add(); bool add();
...@@ -466,8 +466,8 @@ protected: ...@@ -466,8 +466,8 @@ protected:
public: public:
Item_sum_bit(Item *item_par,ulonglong reset_arg) Item_sum_bit(Item *item_par,ulonglong reset_arg)
:Item_sum_int(item_par),reset_bits(reset_arg),bits(reset_arg) {} :Item_sum_int(item_par),reset_bits(reset_arg),bits(reset_arg) {}
Item_sum_bit(THD *thd, Item_sum_bit &item): Item_sum_bit(THD *thd, Item_sum_bit *item):
Item_sum_int(thd, item), reset_bits(item.reset_bits), bits(item.bits) {} Item_sum_int(thd, item), reset_bits(item->reset_bits), bits(item->bits) {}
enum Sumfunctype sum_func () const {return SUM_BIT_FUNC;} enum Sumfunctype sum_func () const {return SUM_BIT_FUNC;}
void clear(); void clear();
longlong val_int(); longlong val_int();
...@@ -482,7 +482,7 @@ class Item_sum_or :public Item_sum_bit ...@@ -482,7 +482,7 @@ class Item_sum_or :public Item_sum_bit
{ {
public: public:
Item_sum_or(Item *item_par) :Item_sum_bit(item_par,LL(0)) {} Item_sum_or(Item *item_par) :Item_sum_bit(item_par,LL(0)) {}
Item_sum_or(THD *thd, Item_sum_or &item) :Item_sum_bit(thd, item) {} Item_sum_or(THD *thd, Item_sum_or *item) :Item_sum_bit(thd, item) {}
bool add(); bool add();
const char *func_name() const { return "bit_or"; } const char *func_name() const { return "bit_or"; }
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
...@@ -493,7 +493,7 @@ class Item_sum_and :public Item_sum_bit ...@@ -493,7 +493,7 @@ class Item_sum_and :public Item_sum_bit
{ {
public: public:
Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ULONGLONG_MAX) {} Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ULONGLONG_MAX) {}
Item_sum_and(THD *thd, Item_sum_and &item) :Item_sum_bit(thd, item) {} Item_sum_and(THD *thd, Item_sum_and *item) :Item_sum_bit(thd, item) {}
bool add(); bool add();
const char *func_name() const { return "bit_and"; } const char *func_name() const { return "bit_and"; }
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
...@@ -503,7 +503,7 @@ class Item_sum_xor :public Item_sum_bit ...@@ -503,7 +503,7 @@ class Item_sum_xor :public Item_sum_bit
{ {
public: public:
Item_sum_xor(Item *item_par) :Item_sum_bit(item_par,LL(0)) {} Item_sum_xor(Item *item_par) :Item_sum_bit(item_par,LL(0)) {}
Item_sum_xor(THD *thd, Item_sum_xor &item) :Item_sum_bit(thd, item) {} Item_sum_xor(THD *thd, Item_sum_xor *item) :Item_sum_bit(thd, item) {}
bool add(); bool add();
const char *func_name() const { return "bit_xor"; } const char *func_name() const { return "bit_xor"; }
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
...@@ -525,8 +525,8 @@ public: ...@@ -525,8 +525,8 @@ public:
Item_udf_sum( udf_func *udf_arg, List<Item> &list ) Item_udf_sum( udf_func *udf_arg, List<Item> &list )
:Item_sum( list ), udf(udf_arg) :Item_sum( list ), udf(udf_arg)
{ quick_group=0;} { quick_group=0;}
Item_udf_sum(THD *thd, Item_udf_sum &item) Item_udf_sum(THD *thd, Item_udf_sum *item)
:Item_sum(thd, item), udf(item.udf) {} :Item_sum(thd, item), udf(item->udf) {}
const char *func_name() const { return udf.name(); } const char *func_name() const { return udf.name(); }
bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) bool fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{ {
...@@ -549,7 +549,7 @@ class Item_sum_udf_float :public Item_udf_sum ...@@ -549,7 +549,7 @@ class Item_sum_udf_float :public Item_udf_sum
Item_sum_udf_float(udf_func *udf_arg) :Item_udf_sum(udf_arg) {} Item_sum_udf_float(udf_func *udf_arg) :Item_udf_sum(udf_arg) {}
Item_sum_udf_float(udf_func *udf_arg, List<Item> &list) Item_sum_udf_float(udf_func *udf_arg, List<Item> &list)
:Item_udf_sum(udf_arg,list) {} :Item_udf_sum(udf_arg,list) {}
Item_sum_udf_float(THD *thd, Item_sum_udf_float &item) Item_sum_udf_float(THD *thd, Item_sum_udf_float *item)
:Item_udf_sum(thd, item) {} :Item_udf_sum(thd, item) {}
longlong val_int() { return (longlong) Item_sum_udf_float::val(); } longlong val_int() { return (longlong) Item_sum_udf_float::val(); }
double val(); double val();
...@@ -565,7 +565,7 @@ public: ...@@ -565,7 +565,7 @@ public:
Item_sum_udf_int(udf_func *udf_arg) :Item_udf_sum(udf_arg) {} Item_sum_udf_int(udf_func *udf_arg) :Item_udf_sum(udf_arg) {}
Item_sum_udf_int(udf_func *udf_arg, List<Item> &list) Item_sum_udf_int(udf_func *udf_arg, List<Item> &list)
:Item_udf_sum(udf_arg,list) {} :Item_udf_sum(udf_arg,list) {}
Item_sum_udf_int(THD *thd, Item_sum_udf_int &item) Item_sum_udf_int(THD *thd, Item_sum_udf_int *item)
:Item_udf_sum(thd, item) {} :Item_udf_sum(thd, item) {}
longlong val_int(); longlong val_int();
double val() { return (double) Item_sum_udf_int::val_int(); } double val() { return (double) Item_sum_udf_int::val_int(); }
...@@ -582,7 +582,7 @@ public: ...@@ -582,7 +582,7 @@ public:
Item_sum_udf_str(udf_func *udf_arg) :Item_udf_sum(udf_arg) {} Item_sum_udf_str(udf_func *udf_arg) :Item_udf_sum(udf_arg) {}
Item_sum_udf_str(udf_func *udf_arg, List<Item> &list) Item_sum_udf_str(udf_func *udf_arg, List<Item> &list)
:Item_udf_sum(udf_arg,list) {} :Item_udf_sum(udf_arg,list) {}
Item_sum_udf_str(THD *thd, Item_sum_udf_str &item) Item_sum_udf_str(THD *thd, Item_sum_udf_str *item)
:Item_udf_sum(thd, item) {} :Item_udf_sum(thd, item) {}
String *val_str(String *); String *val_str(String *);
double val() double val()
...@@ -704,31 +704,31 @@ class Item_func_group_concat : public Item_sum ...@@ -704,31 +704,31 @@ class Item_func_group_concat : public Item_sum
Item_func_group_concat(bool is_distinct,List<Item> *is_select, Item_func_group_concat(bool is_distinct,List<Item> *is_select,
SQL_LIST *is_order,String *is_separator); SQL_LIST *is_order,String *is_separator);
Item_func_group_concat(THD *thd, Item_func_group_concat &item) Item_func_group_concat(THD *thd, Item_func_group_concat *item)
:Item_sum(thd, item),item_thd(thd), :Item_sum(thd, item),item_thd(thd),
tmp_table_param(item.tmp_table_param), tmp_table_param(item->tmp_table_param),
max_elements_in_tree(item.max_elements_in_tree), max_elements_in_tree(item->max_elements_in_tree),
warning(item.warning), warning(item->warning),
warning_available(item.warning_available), warning_available(item->warning_available),
key_length(item.key_length), key_length(item->key_length),
rec_offset(item.rec_offset), rec_offset(item->rec_offset),
tree_mode(item.tree_mode), tree_mode(item->tree_mode),
distinct(item.distinct), distinct(item->distinct),
warning_for_row(item.warning_for_row), warning_for_row(item->warning_for_row),
separator(item.separator), separator(item->separator),
tree(item.tree), tree(item->tree),
table(item.table), table(item->table),
order(item.order), order(item->order),
tables_list(item.tables_list), tables_list(item->tables_list),
group_concat_max_len(item.group_concat_max_len), group_concat_max_len(item->group_concat_max_len),
show_elements(item.show_elements), show_elements(item->show_elements),
arg_count_order(item.arg_count_order), arg_count_order(item->arg_count_order),
arg_count_field(item.arg_count_field), arg_count_field(item->arg_count_field),
arg_show_fields(item.arg_show_fields), arg_show_fields(item->arg_show_fields),
count_cut_values(item.count_cut_values), count_cut_values(item->count_cut_values),
original(&item) original(item)
{ {
quick_group= item.quick_group; quick_group= item->quick_group;
}; };
~Item_func_group_concat(); ~Item_func_group_concat();
void cleanup(); void cleanup();
......
...@@ -38,7 +38,7 @@ class Item_sum_unique_users :public Item_sum_num ...@@ -38,7 +38,7 @@ class Item_sum_unique_users :public Item_sum_num
public: public:
Item_sum_unique_users(Item *name_arg,int start,int end,Item *item_arg) Item_sum_unique_users(Item *name_arg,int start,int end,Item *item_arg)
:Item_sum_num(item_arg) {} :Item_sum_num(item_arg) {}
Item_sum_unique_users(THD *thd, Item_sum_unique_users &item) Item_sum_unique_users(THD *thd, Item_sum_unique_users *item)
:Item_sum_num(thd, item) {} :Item_sum_num(thd, item) {}
double val() { return 0.0; } double val() { return 0.0; }
enum Sumfunctype sum_func () const {return UNIQUE_USERS_FUNC;} enum Sumfunctype sum_func () const {return UNIQUE_USERS_FUNC;}
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
} }
Item *copy_or_same(THD* thd) Item *copy_or_same(THD* thd)
{ {
return new Item_sum_unique_users(thd, *this); return new Item_sum_unique_users(thd, this);
} }
void print(String *str) { str->append("0.0", 3); } void print(String *str) { str->append("0.0", 3); }
}; };
...@@ -756,9 +756,8 @@ static bool mysql_test_select_fields(Prepared_statement *stmt, ...@@ -756,9 +756,8 @@ static bool mysql_test_select_fields(Prepared_statement *stmt,
JOIN *join= new JOIN(thd, fields, select_options, result); JOIN *join= new JOIN(thd, fields, select_options, result);
thd->used_tables= 0; // Updated by setup_fields thd->used_tables= 0; // Updated by setup_fields
// if (join->prepare(&select_lex->ref_pointer_array, tables,
if (join->prepare(&select_lex->ref_pointer_array, if (join->prepare(&select_lex->ref_pointer_array,
(TABLE_LIST*)select_lex->table_list.first, (TABLE_LIST*)select_lex->get_table_list(),
wild_num, conds, og_num, order, group, having, proc, wild_num, conds, og_num, order, group, having, proc,
select_lex, unit)) select_lex, unit))
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -1106,6 +1105,7 @@ void mysql_stmt_free(THD *thd, char *packet) ...@@ -1106,6 +1105,7 @@ void mysql_stmt_free(THD *thd, char *packet)
if (!(stmt= find_prepared_statement(thd, stmt_id, "close"))) if (!(stmt= find_prepared_statement(thd, stmt_id, "close")))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
free_items(stmt->free_list);
/* Statement map deletes statement on erase */ /* Statement map deletes statement on erase */
thd->stmt_map.erase(stmt); thd->stmt_map.erase(stmt);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
...@@ -8282,7 +8282,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, ...@@ -8282,7 +8282,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
if (pos->type() == Item::FIELD_ITEM) if (pos->type() == Item::FIELD_ITEM)
{ {
Item_field *item; Item_field *item;
if (!(item= new Item_field(thd, *((Item_field*) pos)))) if (!(item= new Item_field(thd, ((Item_field*) pos))))
goto err; goto err;
pos= item; pos= item;
if (item->field->flags & BLOB_FLAG) if (item->field->flags & BLOB_FLAG)
......
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