Commit 22a7b4de authored by Alexander Barkov's avatar Alexander Barkov

Removing duplicate code/declarations:

Removing "Field *result_field" from Item_field and Item_ref,
and deriving Item_ident and Item_ref from Item_result_field
instead.
parent 8125db1d
......@@ -739,7 +739,7 @@ Item_ident::Item_ident(TABLE_LIST *view_arg, const char *field_name_arg)
*/
Item_ident::Item_ident(THD *thd, Item_ident *item)
:Item(thd, item),
:Item_result_field(thd, item),
orig_db_name(item->orig_db_name),
orig_table_name(item->orig_table_name),
orig_field_name(item->orig_field_name),
......@@ -758,7 +758,7 @@ void Item_ident::cleanup()
{
DBUG_ENTER("Item_ident::cleanup");
bool was_fixed= fixed;
Item::cleanup();
Item_result_field::cleanup();
db_name= orig_db_name;
table_name= orig_table_name;
field_name= orig_field_name;
......@@ -2189,7 +2189,7 @@ Item_field::Item_field(Name_resolution_context *context_arg,
const char *db_arg,const char *table_name_arg,
const char *field_name_arg)
:Item_ident(context_arg, db_arg,table_name_arg,field_name_arg),
field(0), result_field(0), item_equal(0), no_const_subst(0),
field(0), item_equal(0), no_const_subst(0),
have_privileges(0), any_privileges(0)
{
SELECT_LEX *select= current_thd->lex->current_select;
......@@ -2206,7 +2206,6 @@ Item_field::Item_field(Name_resolution_context *context_arg,
Item_field::Item_field(THD *thd, Item_field *item)
:Item_ident(thd, item),
field(item->field),
result_field(item->result_field),
item_equal(item->item_equal),
no_const_subst(item->no_const_subst),
have_privileges(item->have_privileges),
......@@ -5172,7 +5171,7 @@ void Item_field::cleanup()
it will be linked correctly next time by name of field and table alias.
I.e. we can drop 'field'.
*/
field= result_field= 0;
field= 0;
item_equal= NULL;
null_value= FALSE;
DBUG_VOID_RETURN;
......@@ -6611,7 +6610,7 @@ Item_ref::Item_ref(Name_resolution_context *context_arg,
const char *field_name_arg,
bool alias_name_used_arg)
:Item_ident(context_arg, NullS, table_name_arg, field_name_arg),
result_field(0), ref(item), reference_trough_name(0)
ref(item), reference_trough_name(0)
{
alias_name_used= alias_name_used_arg;
/*
......@@ -6655,7 +6654,7 @@ public:
Item_ref::Item_ref(TABLE_LIST *view_arg, Item **item,
const char *field_name_arg, bool alias_name_used_arg)
:Item_ident(view_arg, field_name_arg),
result_field(NULL), ref(item), reference_trough_name(0)
ref(item), reference_trough_name(0)
{
alias_name_used= alias_name_used_arg;
/*
......@@ -6999,7 +6998,6 @@ void Item_ref::cleanup()
{
DBUG_ENTER("Item_ref::cleanup");
Item_ident::cleanup();
result_field= 0;
if (reference_trough_name)
{
/* We have to reset the reference as it may been freed */
......
......@@ -2069,7 +2069,33 @@ public:
#define NO_CACHED_FIELD_INDEX ((uint)(-1))
class st_select_lex;
class Item_ident :public Item
class Item_result_field :public Item /* Item with result field */
{
public:
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() {} /* Required with gcc 2.95 */
Field *get_tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) { return result_field; }
table_map used_tables() const { return true; }
void set_result_field(Field *field) { result_field= field; }
bool is_result_field() { return true; }
void save_in_result_field(bool no_conversions)
{
save_in_field(result_field, no_conversions);
}
void cleanup();
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
};
class Item_ident :public Item_result_field
{
protected:
/*
......@@ -2165,7 +2191,7 @@ class Item_field :public Item_ident
protected:
void set_field(Field *field);
public:
Field *field,*result_field;
Field *field;
Item_equal *item_equal;
bool no_const_subst;
/*
......@@ -2234,8 +2260,6 @@ public:
return MONOTONIC_STRICT_INCREASING;
}
longlong val_int_endpoint(bool left_endp, bool *incl_endp);
Field *get_tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) { return result_field; }
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate);
bool get_date_result(MYSQL_TIME *ltime,ulonglong fuzzydate);
bool is_null() { return field->is_null(); }
......@@ -2261,6 +2285,9 @@ public:
{
update_table_bitmaps();
}
bool is_result_field() { return false; }
void set_result_field(Field *field) {}
void save_in_result_field(bool no_conversions) { }
Item *get_tmp_table_item(THD *thd);
bool collect_item_field_processor(uchar * arg);
bool add_field_to_set_processor(uchar * arg);
......@@ -2270,7 +2297,6 @@ public:
bool register_field_in_bitmap(uchar *arg);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool vcol_in_partition_func_processor(uchar *bool_arg);
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
bool enumerate_field_refs_processor(uchar *arg);
bool update_table_bitmaps_processor(uchar *arg);
void cleanup();
......@@ -3241,30 +3267,6 @@ public:
class Item_result_field :public Item /* Item with result field */
{
public:
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() {} /* Required with gcc 2.95 */
Field *get_tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg) { return result_field; }
table_map used_tables() const { return 1; }
void set_result_field(Field *field) { result_field= field; }
bool is_result_field() { return 1; }
void save_in_result_field(bool no_conversions)
{
save_in_field(result_field, no_conversions);
}
void cleanup();
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
};
/**
Array of items, e.g. function or aggerate function arguments.
*/
......@@ -3376,14 +3378,13 @@ protected:
void set_properties();
public:
enum Ref_Type { REF, DIRECT_REF, VIEW_REF, OUTER_REF, AGGREGATE_REF };
Field *result_field; /* Save result here */
Item **ref;
bool reference_trough_name;
Item_ref(Name_resolution_context *context_arg,
const char *db_arg, const char *table_name_arg,
const char *field_name_arg)
:Item_ident(context_arg, db_arg, table_name_arg, field_name_arg),
result_field(0), ref(0), reference_trough_name(1) {}
ref(0), reference_trough_name(1) {}
/*
This constructor is used in two scenarios:
A) *item = NULL
......@@ -3406,7 +3407,7 @@ public:
/* Constructor need to process subselect with temporary tables (see Item) */
Item_ref(THD *thd, Item_ref *item)
:Item_ident(thd, item), result_field(item->result_field), ref(item->ref) {}
:Item_ident(thd, item), ref(item->ref) {}
enum Type type() const { return REF_ITEM; }
enum Type real_type() const { return ref ? (*ref)->type() :
REF_ITEM; }
......@@ -3442,6 +3443,7 @@ public:
enum_field_types field_type() const { return (*ref)->field_type(); }
Field *get_tmp_table_field()
{ return result_field ? result_field : (*ref)->get_tmp_table_field(); }
Field *tmp_table_field(TABLE *t_arg) { return 0; }
Item *get_tmp_table_item(THD *thd);
table_map used_tables() const;
void update_used_tables();
......@@ -3453,8 +3455,6 @@ public:
{
return depended_from ? 0 : (*ref)->not_null_tables();
}
void set_result_field(Field *field) { result_field= field; }
bool is_result_field() { return 1; }
void save_in_result_field(bool no_conversions)
{
(*ref)->save_in_field(result_field, no_conversions);
......
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