Commit 25a2c073 authored by unknown's avatar unknown

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

Item & changed with Item* in Item_xxx constructors
tables_list.first -> get_table_list()


sql/item.cc:
  Item& -> Item*
sql/item.h:
  Item& -> Item*
sql/item_cmpfunc.cc:
  Item& -> Item*
sql/item_cmpfunc.h:
  Item& -> Item*
sql/item_func.cc:
  Item& -> Item*
sql/item_func.h:
  Item& -> Item*
sql/item_sum.cc:
  Item& -> Item*
sql/item_sum.h:
  Item& -> Item*
sql/item_uniq.h:
  Item& -> Item*
sql/sql_prepare.cc:
  Code cleanup
sql/sql_select.cc:
  Item& -> Item*
parent ddd422cc
......@@ -71,18 +71,18 @@ Item::Item():
Used for duplicating lists in processing queries with temporary
tables
*/
Item::Item(THD *thd, Item &item):
str_value(item.str_value),
name(item.name),
max_length(item.max_length),
marker(item.marker),
decimals(item.decimals),
maybe_null(item.maybe_null),
null_value(item.null_value),
unsigned_flag(item.unsigned_flag),
with_sum_func(item.with_sum_func),
fixed(item.fixed),
collation(item.collation)
Item::Item(THD *thd, Item *item):
str_value(item->str_value),
name(item->name),
max_length(item->max_length),
marker(item->marker),
decimals(item->decimals),
maybe_null(item->maybe_null),
null_value(item->null_value),
unsigned_flag(item->unsigned_flag),
with_sum_func(item->with_sum_func),
fixed(item->fixed),
collation(item->collation)
{
next= thd->free_list; // Put in free list
thd->free_list= this;
......@@ -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)
Item_ident::Item_ident(THD *thd, Item_ident &item):
Item_ident::Item_ident(THD *thd, Item_ident *item):
Item(thd, item),
db_name(item.db_name),
table_name(item.table_name),
field_name(item.field_name),
depended_from(item.depended_from)
db_name(item->db_name),
table_name(item->table_name),
field_name(item->field_name),
depended_from(item->depended_from)
{}
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)
}
// 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),
field(item.field),
result_field(item.result_field)
field(item->field),
result_field(item->result_field)
{
collation.set(DERIVATION_IMPLICIT);
}
......@@ -455,7 +455,7 @@ table_map Item_field::used_tables() const
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)
new_item->field= new_item->result_field;
return new_item;
......@@ -937,7 +937,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if (last->having_fix_field)
{
Item_ref *rf;
*ref= rf= new Item_ref(ref, this,
*ref= rf= new Item_ref(ref, *ref,
(where->db[0]?where->db:0),
(char *)where->alias,
(char *)field_name);
......@@ -967,8 +967,7 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
void Item_field::cleanup()
{
Item_ident::cleanup();
field= 0;
result_field= 0;
field= result_field= 0;
}
void Item::init_make_field(Send_field *tmp_field,
......@@ -2028,7 +2027,7 @@ 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())
{
DBUG_ASSERT(item->fixed);
......
......@@ -124,7 +124,7 @@ class Item {
top AND/OR ctructure of WHERE clause to protect it of
optimisation changes in prepared statements
*/
Item(THD *thd, Item &item);
Item(THD *thd, Item *item);
virtual ~Item() { name=0; cleanup(); } /*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);
......@@ -240,7 +240,7 @@ class Item_ident :public Item
st_select_lex *depended_from;
Item_ident(const char *db_name_par,const char *table_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;
bool remove_dependence_processor(byte * arg);
......@@ -259,7 +259,7 @@ class Item_field :public Item_ident
:Item_ident(db_par,table_name_par,field_name_par),field(0),result_field(0)
{ collation.set(DERIVATION_IMPLICIT); }
// 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);
enum Type type() const { return FIELD_ITEM; }
bool eq(const Item *item, bool binary_cmp) const;
......@@ -581,8 +581,8 @@ class Item_result_field :public Item /* Item with result field */
Field *result_field; /* Save result here */
Item_result_field() :result_field(0) {}
// Constructor used for Item_sum/Item_cond_and/or (see Item comment)
Item_result_field(THD *thd, Item_result_field &item):
Item(thd, item), result_field(item.result_field)
Item_result_field(THD *thd, Item_result_field *item):
Item(thd, item), result_field(item->result_field)
{}
~Item_result_field() {} /* Required with gcc 2.95 */
Field *get_tmp_table_field() { return result_field; }
......@@ -614,8 +614,8 @@ class Item_ref :public Item_ident
: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),
Item_ref(THD *thd, Item_ref *item, Item **hook)
:Item_ident(thd, item), ref(item->ref),
hook_ptr(hook), orig_item(hook ? *hook : 0) {}
enum Type type() const { return REF_ITEM; }
bool eq(const Item *item, bool binary_cmp) const
......
......@@ -1651,10 +1651,10 @@ longlong Item_func_bit_and::val_int()
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),
abort_on_null(item.abort_on_null),
and_tables_cache(item.and_tables_cache)
abort_on_null(item->abort_on_null),
and_tables_cache(item->and_tables_cache)
{
/*
here should be following text:
......
......@@ -82,7 +82,7 @@ class Item_bool_func :public Item_int_func
Item_bool_func() :Item_int_func() {}
Item_bool_func(Item *a) :Item_int_func(a) {}
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; }
};
......@@ -889,7 +889,7 @@ class Item_cond :public Item_bool_func
list.push_back(i1);
list.push_back(i2);
}
Item_cond(THD *thd, Item_cond &item);
Item_cond(THD *thd, Item_cond *item);
Item_cond(List<Item> &nlist)
:Item_bool_func(), list(nlist), abort_on_null(0) {}
bool add(Item *item) { return list.push_back(item); }
......@@ -914,7 +914,7 @@ class Item_cond_and :public Item_cond
public:
Item_cond_and() :Item_cond() {}
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) {}
enum Functype functype() const { return COND_AND_FUNC; }
longlong val_int();
......@@ -922,7 +922,7 @@ class Item_cond_and :public Item_cond
Item* copy_andor_structure(THD *thd)
{
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);
return item;
}
......@@ -934,7 +934,7 @@ class Item_cond_or :public Item_cond
public:
Item_cond_or() :Item_cond() {}
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) {}
enum Functype functype() const { return COND_OR_FUNC; }
longlong val_int();
......@@ -943,7 +943,7 @@ class Item_cond_or :public Item_cond
Item* copy_andor_structure(THD *thd)
{
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);
return item;
}
......
......@@ -130,13 +130,13 @@ Item_func::Item_func(List<Item> &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),
allowed_arg_cols(item.allowed_arg_cols),
arg_count(item.arg_count),
used_tables_cache(item.used_tables_cache),
not_null_tables_cache(item.not_null_tables_cache),
const_item_cache(item.const_item_cache)
allowed_arg_cols(item->allowed_arg_cols),
arg_count(item->arg_count),
used_tables_cache(item->used_tables_cache),
not_null_tables_cache(item->not_null_tables_cache),
const_item_cache(item->const_item_cache)
{
if (arg_count)
{
......@@ -147,7 +147,7 @@ Item_func::Item_func(THD *thd, Item_func &item)
if (!(args=(Item**) thd->alloc(sizeof(Item*)*arg_count)))
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 @@ class Item_func :public Item_result_field
}
Item_func(List<Item> &list);
// 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);
table_map used_tables() const;
table_map not_null_tables() const;
......@@ -199,7 +199,7 @@ class Item_int_func :public Item_func
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(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(); }
String *val_str(String*str);
enum Item_result result_type () const { return INT_RESULT; }
......
......@@ -42,17 +42,17 @@ Item_sum::Item_sum(List<Item> &list)
}
// Constructor used in processing select with temporary tebles
Item_sum::Item_sum(THD *thd, Item_sum &item):
Item_result_field(thd, item), quick_group(item.quick_group)
Item_sum::Item_sum(THD *thd, Item_sum *item):
Item_result_field(thd, item), quick_group(item->quick_group)
{
arg_count= item.arg_count;
arg_count= item->arg_count;
if (arg_count <= 2)
args=tmp_args;
else
if (!(args=(Item**) sql_alloc(sizeof(Item*)*arg_count)))
return;
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()
......@@ -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)
{
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()
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()
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()
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)
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)
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()
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()
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()
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()
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()
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()
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()
......@@ -1404,7 +1404,7 @@ String *Item_sum_udf_float::val_str(String *str)
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()
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()
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);
}
......
This diff is collapsed.
......@@ -38,7 +38,7 @@ class Item_sum_unique_users :public Item_sum_num
public:
Item_sum_unique_users(Item *name_arg,int start,int end,Item *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) {}
double val() { return 0.0; }
enum Sumfunctype sum_func () const {return UNIQUE_USERS_FUNC;}
......@@ -53,7 +53,7 @@ class Item_sum_unique_users :public Item_sum_num
}
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); }
};
......@@ -756,9 +756,8 @@ static bool mysql_test_select_fields(Prepared_statement *stmt,
JOIN *join= new JOIN(thd, fields, select_options, result);
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,
(TABLE_LIST*)select_lex->table_list.first,
(TABLE_LIST*)select_lex->get_table_list(),
wild_num, conds, og_num, order, group, having, proc,
select_lex, unit))
DBUG_RETURN(1);
......@@ -1106,6 +1105,7 @@ void mysql_stmt_free(THD *thd, char *packet)
if (!(stmt= find_prepared_statement(thd, stmt_id, "close")))
DBUG_VOID_RETURN;
free_items(stmt->free_list);
/* Statement map deletes statement on erase */
thd->stmt_map.erase(stmt);
DBUG_VOID_RETURN;
......
......@@ -8282,7 +8282,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
if (pos->type() == 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;
pos= item;
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