summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc118
1 files changed, 65 insertions, 53 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 3b1f8b77e82..a6a1d6a5cb8 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -278,10 +278,11 @@ my_decimal *Item::val_decimal_from_string(my_decimal *decimal_value)
res->ptr(), res->length(), res->charset(),
decimal_value) & E_DEC_BAD_NUM)
{
+ THD *thd= current_thd;
ErrConvString err(res);
- push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE,
- ER(ER_TRUNCATED_WRONG_VALUE), "DECIMAL",
+ ER_THD(thd, ER_TRUNCATED_WRONG_VALUE), "DECIMAL",
err.ptr());
}
return decimal_value;
@@ -488,7 +489,7 @@ uint Item::decimal_precision() const
}
-uint Item::temporal_precision(enum_field_types type)
+uint Item::temporal_precision(enum_field_types type_arg)
{
if (const_item() && result_type() == STRING_RESULT &&
!is_temporal_type(field_type()))
@@ -498,7 +499,7 @@ uint Item::temporal_precision(enum_field_types type)
MYSQL_TIME_STATUS status;
DBUG_ASSERT(fixed);
if ((tmp= val_str(&buf)) &&
- !(type == MYSQL_TYPE_TIME ?
+ !(type_arg == MYSQL_TYPE_TIME ?
str_to_time(tmp->charset(), tmp->ptr(), tmp->length(),
&ltime, TIME_TIME_ONLY, &status) :
str_to_datetime(tmp->charset(), tmp->ptr(), tmp->length(),
@@ -962,16 +963,19 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
if (str != str_start && !is_autogenerated_name)
{
char buff[SAFE_NAME_LEN];
+ THD *thd= current_thd;
+
strmake(buff, str_start,
MY_MIN(sizeof(buff)-1, length + (int) (str-str_start)));
if (length == 0)
- push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
- ER_NAME_BECOMES_EMPTY, ER(ER_NAME_BECOMES_EMPTY),
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_NAME_BECOMES_EMPTY,
+ ER_THD(thd, ER_NAME_BECOMES_EMPTY),
buff);
else
- push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
- ER_REMOVED_SPACES, ER(ER_REMOVED_SPACES),
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_REMOVED_SPACES, ER_THD(thd, ER_REMOVED_SPACES),
buff);
}
if (!my_charset_same(cs, system_charset_info))
@@ -2596,11 +2600,11 @@ bool Item_field::is_null_result()
bool Item_field::eq(const Item *item, bool binary_cmp) const
{
- Item *real_item= ((Item *) item)->real_item();
- if (real_item->type() != FIELD_ITEM)
+ Item *real_item2= ((Item *) item)->real_item();
+ if (real_item2->type() != FIELD_ITEM)
return 0;
- Item_field *item_field= (Item_field*) real_item;
+ Item_field *item_field= (Item_field*) real_item2;
if (item_field->field && field)
return item_field->field == field;
/*
@@ -2964,14 +2968,15 @@ double_from_string_with_check(CHARSET_INFO *cs, const char *cptr,
if (error || (end != end_of_num &&
!check_if_only_end_space(cs, end_of_num, end)))
{
+ THD *thd= current_thd;
ErrConvString err(cptr, end - cptr, cs);
/*
We can use err.ptr() here as ErrConvString is guranteed to put an
end \0 here.
*/
- push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE,
- ER(ER_TRUNCATED_WRONG_VALUE), "DOUBLE",
+ ER_THD(thd, ER_TRUNCATED_WRONG_VALUE), "DOUBLE",
err.ptr());
}
return tmp;
@@ -3005,11 +3010,12 @@ longlong_from_string_with_check(CHARSET_INFO *cs, const char *cptr,
(err > 0 ||
(end != end_of_num && !check_if_only_end_space(cs, end_of_num, end))))
{
- ErrConvString err(cptr, end - cptr, cs);
- push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
+ THD *thd= current_thd;
+ ErrConvString err_str(cptr, end - cptr, cs);
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE,
- ER(ER_TRUNCATED_WRONG_VALUE), "INTEGER",
- err.ptr());
+ ER_THD(thd, ER_TRUNCATED_WRONG_VALUE), "INTEGER",
+ err_str.ptr());
}
return tmp;
}
@@ -4280,11 +4286,12 @@ static bool mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current,
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
- ER_WARN_FIELD_RESOLVED, ER(ER_WARN_FIELD_RESOLVED),
- db_name, (db_name[0] ? "." : ""),
- table_name, (table_name [0] ? "." : ""),
- resolved_item->field_name,
- current->select_number, last->select_number);
+ ER_WARN_FIELD_RESOLVED,
+ ER_THD(thd,ER_WARN_FIELD_RESOLVED),
+ db_name, (db_name[0] ? "." : ""),
+ table_name, (table_name [0] ? "." : ""),
+ resolved_item->field_name,
+ current->select_number, last->select_number);
}
return FALSE;
}
@@ -4527,9 +4534,10 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select)
!((*group_by_ref)->eq(*select_ref, 0)))
{
ambiguous_fields= TRUE;
- push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_NON_UNIQ_ERROR,
- ER(ER_NON_UNIQ_ERROR), ref->full_name(),
- current_thd->where);
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_NON_UNIQ_ERROR,
+ ER_THD(thd,ER_NON_UNIQ_ERROR), ref->full_name(),
+ thd->where);
}
}
@@ -5023,7 +5031,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
{
/* The column to which we link isn't valid. */
my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name,
- current_thd->where);
+ thd->where);
return(1);
}
@@ -5040,8 +5048,8 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
Item_ref *rf= new Item_ref(context, db_name,table_name,field_name);
if (!rf)
return 1;
- bool ret= rf->fix_fields(thd, (Item **) &rf) || rf->check_cols(1);
- if (ret)
+ bool err= rf->fix_fields(thd, (Item **) &rf) || rf->check_cols(1);
+ if (err)
return TRUE;
SELECT_LEX *select= thd->lex->current_select;
@@ -5437,12 +5445,12 @@ Item *Item_field::replace_equal_field(uchar *arg)
REPLACE_EQUAL_FIELD_ARG* param= (REPLACE_EQUAL_FIELD_ARG*)arg;
if (item_equal && item_equal == param->item_equal)
{
- Item *const_item= item_equal->get_const();
- if (const_item)
+ Item *const_item2= item_equal->get_const();
+ if (const_item2)
{
- if (!has_compatible_context(const_item))
+ if (!has_compatible_context(const_item2))
return this;
- return const_item;
+ return const_item2;
}
Item_field *subst=
(Item_field *)(item_equal->get_first(param->context_tab, this));
@@ -5554,8 +5562,10 @@ String *Item::check_well_formed_result(String *str, bool send_error)
{
str->length(wlen);
}
- push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_INVALID_CHARACTER_STRING,
- ER(ER_INVALID_CHARACTER_STRING), cs->csname, hexbuf);
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_INVALID_CHARACTER_STRING,
+ ER_THD(thd, ER_INVALID_CHARACTER_STRING), cs->csname,
+ hexbuf);
}
return str;
}
@@ -5576,7 +5586,7 @@ String_copier_for_item::copy_with_warn(CHARSET_INFO *dstcs, String *dst,
ErrConvString err(pos, src_length - (pos - src), &my_charset_bin);
push_warning_printf(m_thd, Sql_condition::WARN_LEVEL_WARN,
ER_INVALID_CHARACTER_STRING,
- ER(ER_INVALID_CHARACTER_STRING),
+ ER_THD(m_thd, ER_INVALID_CHARACTER_STRING),
srccs == &my_charset_bin ?
dstcs->csname : srccs->csname,
err.ptr());
@@ -5591,7 +5601,7 @@ String_copier_for_item::copy_with_warn(CHARSET_INFO *dstcs, String *dst,
octet2hex(buf, pos, mblen);
push_warning_printf(m_thd, Sql_condition::WARN_LEVEL_WARN,
ER_CANNOT_CONVERT_CHARACTER,
- ER(ER_CANNOT_CONVERT_CHARACTER),
+ ER_THD(m_thd, ER_CANNOT_CONVERT_CHARACTER),
srccs->csname, buf, dstcs->csname);
return m_thd->is_strict_mode();
}
@@ -6806,7 +6816,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
{
/* The current reference cannot be resolved in this query. */
my_error(ER_BAD_FIELD_ERROR,MYF(0),
- this->full_name(), current_thd->where);
+ this->full_name(), thd->where);
goto error;
}
@@ -6954,7 +6964,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
{
/* The item was not a table field and not a reference */
my_error(ER_BAD_FIELD_ERROR, MYF(0),
- this->full_name(), current_thd->where);
+ this->full_name(), thd->where);
goto error;
}
/* Should be checked in resolve_ref_in_select_and_group(). */
@@ -7934,12 +7944,13 @@ bool Item_outer_ref::fix_fields(THD *thd, Item **reference)
}
-void Item_outer_ref::fix_after_pullout(st_select_lex *new_parent, Item **ref)
+void Item_outer_ref::fix_after_pullout(st_select_lex *new_parent,
+ Item **ref_arg)
{
if (get_depended_from() == new_parent)
{
- *ref= outer_ref;
- (*ref)->fix_after_pullout(new_parent, ref);
+ *ref_arg= outer_ref;
+ (*ref_arg)->fix_after_pullout(new_parent, ref_arg);
}
}
@@ -7973,12 +7984,12 @@ bool Item_outer_ref::check_inner_refs_processor(uchar *arg)
{
List_iterator_fast<Item_outer_ref> *it=
((List_iterator_fast<Item_outer_ref> *) arg);
- Item_outer_ref *ref;
- while ((ref= (*it)++))
+ Item_outer_ref *tmp_ref;
+ while ((tmp_ref= (*it)++))
{
- if (ref == this)
+ if (tmp_ref == this)
{
- ref->found_in_group_by= 1;
+ tmp_ref->found_in_group_by= 1;
break;
}
}
@@ -8218,38 +8229,39 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions)
{
if (!arg)
{
+ THD *thd= field_arg->table->in_use;
+
if (field_arg->flags & NO_DEFAULT_VALUE_FLAG &&
field_arg->real_type() != MYSQL_TYPE_ENUM)
{
if (field_arg->reset())
{
my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
- ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
+ ER_THD(thd, ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
return -1;
}
if (context->error_processor == &view_error_processor)
{
TABLE_LIST *view= field_arg->table->pos_in_table_list->top_table();
- push_warning_printf(field_arg->table->in_use,
+ push_warning_printf(thd,
Sql_condition::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_VIEW_FIELD,
- ER(ER_NO_DEFAULT_FOR_VIEW_FIELD),
+ ER_THD(thd, ER_NO_DEFAULT_FOR_VIEW_FIELD),
view->view_db.str,
view->view_name.str);
}
else
{
- push_warning_printf(field_arg->table->in_use,
+ push_warning_printf(thd,
Sql_condition::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_FIELD,
- ER(ER_NO_DEFAULT_FOR_FIELD),
+ ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD),
field_arg->field_name);
}
return 1;
}
field_arg->set_default();
- THD *thd= field_arg->table->in_use;
return
!field_arg->is_null_in_record(field_arg->table->s->default_values) &&
field_arg->validate_value_in_record_with_warn(thd,
@@ -8998,10 +9010,10 @@ int Item_cache_temporal::save_in_field(Field *field, bool no_conversions)
}
-void Item_cache_temporal::store_packed(longlong val_arg, Item *example)
+void Item_cache_temporal::store_packed(longlong val_arg, Item *example_arg)
{
/* An explicit values is given, save it. */
- store(example);
+ store(example_arg);
value_cached= true;
value= val_arg;
null_value= false;