Skip to content

Commit

Permalink
Cleanup: renaming methods make_field(Send_field*) to make_send_field(..)
Browse files Browse the repository at this point in the history
Renaming methods:
- Field::make_field(Send_field*) to make_send_field(..)
- Item::make_field(THD *,Send_field *) to make_send_field(..)
- Item::init_make_field(Send_field *, enum_field_type) to init_make_send_field(..)

These names looked similar to other functions that are used
for a very different purpose (creating Field instances):
- Public function "Field * make_field(..)"
- Method "Field *Column_defitinion::make_field(..)"

The rename makes it's easier to search the code using "grep".
  • Loading branch information
abarkov committed Apr 5, 2018
1 parent d8da97b commit a1a966f
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 59 deletions.
2 changes: 1 addition & 1 deletion libmysqld/lib_sql.cc
Expand Up @@ -1034,7 +1034,7 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
while ((item= it++))
{
Send_field server_field;
item->make_field(thd, &server_field);
item->make_send_field(thd, &server_field);

/* Keep things compatible for old clients */
if (server_field.type == MYSQL_TYPE_VARCHAR)
Expand Down
18 changes: 9 additions & 9 deletions sql/field.cc
Expand Up @@ -1941,7 +1941,7 @@ void Field_num::add_zerofill_and_unsigned(String &res) const
}


void Field::make_field(Send_field *field)
void Field::make_send_field(Send_field *field)
{
if (orig_table && orig_table->s->db.str && *orig_table->s->db.str)
{
Expand Down Expand Up @@ -2173,9 +2173,9 @@ bool Field_str::can_be_substituted_to_equal_item(const Context &ctx,
}


void Field_num::make_field(Send_field *field)
void Field_num::make_send_field(Send_field *field)
{
Field::make_field(field);
Field::make_send_field(field);
field->decimals= dec;
}

Expand Down Expand Up @@ -5478,9 +5478,9 @@ int Field_timestamp_hires::cmp(const uchar *a_ptr, const uchar *b_ptr)
}


void Field_timestamp_with_dec::make_field(Send_field *field)
void Field_timestamp_with_dec::make_send_field(Send_field *field)
{
Field::make_field(field);
Field::make_send_field(field);
field->decimals= dec;
}

Expand Down Expand Up @@ -6185,9 +6185,9 @@ void Field_time_hires::sort_string(uchar *to,uint length __attribute__((unused))
to[0]^= 128;
}

void Field_time_with_dec::make_field(Send_field *field)
void Field_time_with_dec::make_send_field(Send_field *field)
{
Field::make_field(field);
Field::make_send_field(field);
field->decimals= dec;
}

Expand Down Expand Up @@ -6837,9 +6837,9 @@ int Field_datetime_hires::cmp(const uchar *a_ptr, const uchar *b_ptr)
return a < b ? -1 : a > b ? 1 : 0;
}

void Field_datetime_with_dec::make_field(Send_field *field)
void Field_datetime_with_dec::make_send_field(Send_field *field)
{
Field::make_field(field);
Field::make_send_field(field);
field->decimals= dec;
}

Expand Down
10 changes: 5 additions & 5 deletions sql/field.h
Expand Up @@ -1219,7 +1219,7 @@ class Field: public Value_source
}

void make_sort_key(uchar *buff, uint length);
virtual void make_field(Send_field *);
virtual void make_send_field(Send_field *);
virtual void sort_string(uchar *buff,uint length)=0;
virtual bool optimize_range(uint idx, uint part) const;
virtual void free() {}
Expand Down Expand Up @@ -1659,7 +1659,7 @@ class Field_num :public Field {
}
void add_zerofill_and_unsigned(String &res) const;
friend class Create_field;
void make_field(Send_field *);
void make_send_field(Send_field *);
uint decimals() const { return (uint) dec; }
uint size_of() const { return sizeof(*this); }
bool eq_def(const Field *field) const;
Expand Down Expand Up @@ -2571,7 +2571,7 @@ class Field_timestamp_with_dec :public Field_timestamp {
const uchar *unpack(uchar* to, const uchar *from, const uchar *from_end,
uint param_data)
{ return Field::unpack(to, from, from_end, param_data); }
void make_field(Send_field *field);
void make_send_field(Send_field *field);
void sort_string(uchar *to, uint length)
{
DBUG_ASSERT(length == pack_length());
Expand Down Expand Up @@ -2855,7 +2855,7 @@ class Field_time_with_dec :public Field_time {
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
longlong val_int(void);
double val_real(void);
void make_field(Send_field *);
void make_send_field(Send_field *);
};


Expand Down Expand Up @@ -3006,7 +3006,7 @@ class Field_datetime_with_dec :public Field_datetime {
}
uint decimals() const { return dec; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
void make_field(Send_field *field);
void make_send_field(Send_field *field);
bool send_binary(Protocol *protocol);
uchar *pack(uchar *to, const uchar *from, uint max_length)
{ return Field::pack(to, from, max_length); }
Expand Down
30 changes: 15 additions & 15 deletions sql/item.cc
Expand Up @@ -1776,11 +1776,11 @@ bool Item_sp_variable::is_null()
return this_item()->is_null();
}

void Item_sp_variable::make_field(THD *thd, Send_field *field)
void Item_sp_variable::make_send_field(THD *thd, Send_field *field)
{
Item *it= this_item();

it->make_field(thd, field);
it->make_send_field(thd, field);
if (name.str)
field->col_name= name;
else
Expand Down Expand Up @@ -3057,7 +3057,7 @@ Item* Item_ref::build_clone(THD *thd)
}


void Item_ident_for_show::make_field(THD *thd, Send_field *tmp_field)
void Item_ident_for_show::make_send_field(THD *thd, Send_field *tmp_field)
{
tmp_field->table_name= tmp_field->org_table_name= table_name;
tmp_field->db_name= db_name;
Expand Down Expand Up @@ -5033,9 +5033,9 @@ Item_param::get_out_param_info() const
@param field container for meta-data to be filled
*/

void Item_param::make_field(THD *thd, Send_field *field)
void Item_param::make_send_field(THD *thd, Send_field *field)
{
Item::make_field(thd, field);
Item::make_send_field(thd, field);

if (!m_out_param_info)
return;
Expand Down Expand Up @@ -6613,8 +6613,8 @@ Item *Item_field::replace_equal_field(THD *thd, uchar *arg)
}


void Item::init_make_field(Send_field *tmp_field,
enum enum_field_types field_type_arg)
void Item::init_make_send_field(Send_field *tmp_field,
enum enum_field_types field_type_arg)
{
tmp_field->db_name= "";
tmp_field->org_table_name= "";
Expand All @@ -6631,15 +6631,15 @@ void Item::init_make_field(Send_field *tmp_field,
tmp_field->flags |= UNSIGNED_FLAG;
}

void Item::make_field(THD *thd, Send_field *tmp_field)
void Item::make_send_field(THD *thd, Send_field *tmp_field)
{
init_make_field(tmp_field, field_type());
init_make_send_field(tmp_field, field_type());
}


void Item_empty_string::make_field(THD *thd, Send_field *tmp_field)
void Item_empty_string::make_send_field(THD *thd, Send_field *tmp_field)
{
init_make_field(tmp_field, string_type_handler()->field_type());
init_make_send_field(tmp_field, string_type_handler()->field_type());
}


Expand Down Expand Up @@ -6774,9 +6774,9 @@ bool Item::eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs)


/* ARGSUSED */
void Item_field::make_field(THD *thd, Send_field *tmp_field)
void Item_field::make_send_field(THD *thd, Send_field *tmp_field)
{
field->make_field(tmp_field);
field->make_send_field(tmp_field);
DBUG_ASSERT(tmp_field->table_name != 0);
if (name.str)
{
Expand Down Expand Up @@ -8510,9 +8510,9 @@ void Item_ref::save_org_in_field(Field *field, fast_field_copier optimizer_data)
}


void Item_ref::make_field(THD *thd, Send_field *field)
void Item_ref::make_send_field(THD *thd, Send_field *field)
{
(*ref)->make_field(thd, field);
(*ref)->make_send_field(thd, field);
/* Non-zero in case of a view */
if (name.str)
field->col_name= name;
Expand Down
27 changes: 14 additions & 13 deletions sql/item.h
Expand Up @@ -780,9 +780,9 @@ class Item: public Value_source,
void set_name(THD *thd, const char *str, size_t length, CHARSET_INFO *cs);
void set_name_no_truncate(THD *thd, const char *str, uint length,
CHARSET_INFO *cs);
void init_make_field(Send_field *tmp_field,enum enum_field_types type);
void init_make_send_field(Send_field *tmp_field,enum enum_field_types type);
virtual void cleanup();
virtual void make_field(THD *thd, Send_field *field);
virtual void make_send_field(THD *thd, Send_field *field);
virtual bool fix_fields(THD *, Item **);
/*
Fix after some tables has been pulled out. Basically re-calculate all
Expand Down Expand Up @@ -2399,7 +2399,7 @@ class Item_sp_variable :public Item
bool is_null();

public:
void make_field(THD *thd, Send_field *field);
void make_send_field(THD *thd, Send_field *field);

inline bool const_item() const;

Expand Down Expand Up @@ -2833,7 +2833,7 @@ class Item_ident_for_show :public Item
{
return field->get_date(ltime, fuzzydate);
}
void make_field(THD *thd, Send_field *tmp_field);
void make_send_field(THD *thd, Send_field *tmp_field);
const Type_handler *type_handler() const
{
const Type_handler *handler= field->type_handler();
Expand Down Expand Up @@ -2919,7 +2919,7 @@ class Item_field :public Item_ident,
void reset_field(Field *f);
bool fix_fields(THD *, Item **);
void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
void make_field(THD *thd, Send_field *tmp_field);
void make_send_field(THD *thd, Send_field *tmp_field);
int save_in_field(Field *field,bool no_conversions);
void save_org_in_field(Field *field, fast_field_copier optimizer_data);
fast_field_copier setup_fast_field_copier(Field *field);
Expand Down Expand Up @@ -3580,7 +3580,7 @@ class Item_param :public Item_basic_value,

Item_param *get_item_param() { return this; }

virtual void make_field(THD *thd, Send_field *field);
virtual void make_send_field(THD *thd, Send_field *field);

private:
Send_field *m_out_param_info;
Expand Down Expand Up @@ -4130,7 +4130,7 @@ class Item_empty_string :public Item_partition_func_safe_string
name.length= strlen(name.str);
max_length= length * collation.collation->mbmaxlen;
}
void make_field(THD *thd, Send_field *field);
void make_send_field(THD *thd, Send_field *field);
};


Expand Down Expand Up @@ -4732,7 +4732,7 @@ class Item_ref :public Item_ident
bool val_bool_result();
bool is_null_result();
bool send(Protocol *prot, st_value *buffer);
void make_field(THD *thd, Send_field *field);
void make_send_field(THD *thd, Send_field *field);
bool fix_fields(THD *, Item **);
void fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge);
int save_in_field(Field *field, bool no_conversions);
Expand Down Expand Up @@ -5047,8 +5047,8 @@ class Item_cache_wrapper :public Item_result_field,

virtual void print(String *str, enum_query_type query_type);
virtual const char *full_name() const { return orig_item->full_name(); }
virtual void make_field(THD *thd, Send_field *field)
{ orig_item->make_field(thd, field); }
virtual void make_send_field(THD *thd, Send_field *field)
{ orig_item->make_send_field(thd, field); }
bool eq(const Item *item, bool binary_cmp) const
{
Item *it= ((Item *) item)->real_item();
Expand Down Expand Up @@ -5490,7 +5490,8 @@ class Item_copy :public Item,
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }

void make_field(THD *thd, Send_field *field) { item->make_field(thd, field); }
void make_send_field(THD *thd, Send_field *field)
{ item->make_send_field(thd, field); }
table_map used_tables() const { return (table_map) 1L; }
bool const_item() const { return 0; }
bool is_null() { return null_value; }
Expand Down Expand Up @@ -6324,9 +6325,9 @@ class Item_cache_row: public Item_cache
bool setup(THD *thd, Item *item);
void store(Item *item);
void illegal_method_call(const char *);
void make_field(THD *thd, Send_field *)
void make_send_field(THD *thd, Send_field *)
{
illegal_method_call((const char*)"make_field");
illegal_method_call((const char*)"make_send_field");
};
double val_real()
{
Expand Down
12 changes: 6 additions & 6 deletions sql/item_func.cc
Expand Up @@ -5128,17 +5128,17 @@ bool Item_func_set_user_var::send(Protocol *protocol, st_value *buffer)
return Item::send(protocol, buffer);
}

void Item_func_set_user_var::make_field(THD *thd, Send_field *tmp_field)
void Item_func_set_user_var::make_send_field(THD *thd, Send_field *tmp_field)
{
if (result_field)
{
result_field->make_field(tmp_field);
result_field->make_send_field(tmp_field);
DBUG_ASSERT(tmp_field->table_name != 0);
if (Item::name.str)
tmp_field->col_name= Item::name; // Use user supplied name
}
else
Item::make_field(thd, tmp_field);
Item::make_send_field(thd, tmp_field);
}


Expand Down Expand Up @@ -6380,11 +6380,11 @@ Item_func_sp::execute()


void
Item_func_sp::make_field(THD *thd, Send_field *tmp_field)
Item_func_sp::make_send_field(THD *thd, Send_field *tmp_field)
{
DBUG_ENTER("Item_func_sp::make_field");
DBUG_ENTER("Item_func_sp::make_send_field");
DBUG_ASSERT(sp_result_field);
sp_result_field->make_field(tmp_field);
sp_result_field->make_send_field(tmp_field);
if (name.str)
{
DBUG_ASSERT(name.length == strlen(name.str));
Expand Down
4 changes: 2 additions & 2 deletions sql/item_func.h
Expand Up @@ -2414,7 +2414,7 @@ class Item_func_set_user_var :public Item_func_user_var
bool update_hash(void *ptr, size_t length, enum Item_result type,
CHARSET_INFO *cs, bool unsigned_arg);
bool send(Protocol *protocol, st_value *buffer);
void make_field(THD *thd, Send_field *tmp_field);
void make_send_field(THD *thd, Send_field *tmp_field);
bool check(bool use_result_field);
void save_item_result(Item *item);
bool update();
Expand Down Expand Up @@ -2840,7 +2840,7 @@ class Item_func_sp :public Item_func,
sp_result_field :
tmp_table_field_from_field_type(table);
}
void make_field(THD *thd, Send_field *tmp_field);
void make_send_field(THD *thd, Send_field *tmp_field);

longlong val_int()
{
Expand Down
4 changes: 2 additions & 2 deletions sql/item_row.h
Expand Up @@ -58,9 +58,9 @@ class Item_row: public Item,
const Type_handler *type_handler() const { return &type_handler_row; }
void illegal_method_call(const char *);
bool is_null() { return null_value; }
void make_field(THD *thd, Send_field *)
void make_send_field(THD *thd, Send_field *)
{
illegal_method_call((const char*)"make_field");
illegal_method_call((const char*)"make_send_field");
};
double val_real()
{
Expand Down
4 changes: 2 additions & 2 deletions sql/procedure.h
Expand Up @@ -49,9 +49,9 @@ class Item_proc :public Item
virtual void set(longlong nr)=0;
const Type_handler *type_handler() const=0;
void set(const char *str) { set(str,(uint) strlen(str), default_charset()); }
void make_field(THD *thd, Send_field *tmp_field)
void make_send_field(THD *thd, Send_field *tmp_field)
{
init_make_field(tmp_field,field_type());
init_make_send_field(tmp_field,field_type());
}
unsigned int size_of() { return sizeof(*this);}
bool check_vcol_func_processor(void *arg)
Expand Down
2 changes: 1 addition & 1 deletion sql/protocol.cc
Expand Up @@ -821,7 +821,7 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
char *pos;
CHARSET_INFO *cs= system_charset_info;
Send_field field;
item->make_field(thd, &field);
item->make_send_field(thd, &field);

/* limit number of decimals for float and double */
if (field.type == MYSQL_TYPE_FLOAT || field.type == MYSQL_TYPE_DOUBLE)
Expand Down
2 changes: 1 addition & 1 deletion sql/sp_head.cc
Expand Up @@ -2332,7 +2332,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
}

Send_field *out_param_info= new (thd->mem_root) Send_field();
nctx->get_parameter(i)->make_field(thd, out_param_info);
nctx->get_parameter(i)->make_send_field(thd, out_param_info);
out_param_info->db_name= m_db.str;
out_param_info->table_name= m_name.str;
out_param_info->org_table_name= m_name.str;
Expand Down

0 comments on commit a1a966f

Please sign in to comment.