- Renaming variables so that they don't shadow others (After this patch one can compile with -Wshadow and get much fewer warnings)

- Changed ER(ER_...) to ER_THD(thd, ER_...) when thd was known or if there was many calls to current_thd in the same function.
- Changed ER(ER_..) to ER_THD_OR_DEFAULT(current_thd, ER...) in some places where current_thd is not necessary defined.
- Removing calls to current_thd when we have access to thd

Part of this is optimization (not calling current_thd when not needed),
but part is bug fixing for error condition when current_thd is not defined
(For example on startup and end of mysqld)

Notable renames done as otherwise a lot of functions would have to be changed:
- In JOIN structure renamed:
   examined_rows -> join_examined_rows
   record_count -> join_record_count
- In Field, renamed new_field() to make_new_field()

Other things:
- Added DBUG_ASSERT(thd == tmp_thd) in Item_singlerow_subselect() just to be safe.
- Removed old 'tab' prefix in JOIN_TAB::save_explain_data() and use members directly
- Added 'thd' as argument to a few functions to avoid calling current_thd.
This commit is contained in:
Monty 2015-07-06 20:24:14 +03:00
commit 7332af49e4
107 changed files with 1562 additions and 1290 deletions

View file

@ -76,7 +76,7 @@ bool Item_sum::init_sum_func_check(THD *thd)
}
if (!(thd->lex->allow_sum_func & curr_sel->name_visibility_map))
{
my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
my_message(ER_INVALID_GROUP_FUNC_USE, ER_THD(thd, ER_INVALID_GROUP_FUNC_USE),
MYF(0));
return TRUE;
}
@ -200,7 +200,8 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
invalid= aggr_level <= max_sum_func_level;
if (invalid)
{
my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),
my_message(ER_INVALID_GROUP_FUNC_USE,
ER_THD(thd, ER_INVALID_GROUP_FUNC_USE),
MYF(0));
return TRUE;
}
@ -281,7 +282,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
!sel->group_list.elements)
{
my_message(ER_MIX_OF_GROUP_FUNC_AND_FIELDS,
ER(ER_MIX_OF_GROUP_FUNC_AND_FIELDS), MYF(0));
ER_THD(thd, ER_MIX_OF_GROUP_FUNC_AND_FIELDS), MYF(0));
return TRUE;
}
}
@ -3112,6 +3113,7 @@ int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)),
CHARSET_INFO *cs= item->collation.collation;
const char *ptr= result->ptr();
uint add_length;
THD *thd= current_thd;
/*
It's ok to use item->result.length() as the fourth argument
as this is never used to limit the length of the data.
@ -3124,8 +3126,9 @@ int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)),
&well_formed_error);
result->length(old_length + add_length);
item->warning_for_row= TRUE;
push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
ER_CUT_VALUE_GROUP_CONCAT, ER(ER_CUT_VALUE_GROUP_CONCAT),
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_CUT_VALUE_GROUP_CONCAT,
ER_THD(thd, ER_CUT_VALUE_GROUP_CONCAT),
item->row_count);
return 1;
@ -3297,7 +3300,7 @@ void Item_func_group_concat::cleanup()
}
Field *Item_func_group_concat::make_string_field(TABLE *table)
Field *Item_func_group_concat::make_string_field(TABLE *table_arg)
{
Field *field;
DBUG_ASSERT(collation.collation);
@ -3306,10 +3309,11 @@ Field *Item_func_group_concat::make_string_field(TABLE *table)
maybe_null, name, collation.collation, TRUE);
else
field= new Field_varstring(max_length,
maybe_null, name, table->s, collation.collation);
maybe_null, name, table_arg->s,
collation.collation);
if (field)
field->init(table);
field->init(table_arg);
return field;
}