3826 Alexander Barkov 2012-03-30 [merge]
BUG#12537203 post-fix
Introducing a new class NameString, to avoid "name" and "name_length"
desynchronization in the future.
modified:
sql/field.cc
sql/item.cc
sql/item.h
sql/item_cmpfunc.cc
sql/item_create.cc
sql/item_func.cc
sql/item_func.h
sql/item_geofunc.cc
sql/item_subselect.cc
sql/item_sum.cc
sql/item_timefunc.h
sql/log_event.cc
sql/partition_info.cc
sql/procedure.cc
sql/procedure.h
sql/sql_acl.cc
sql/sql_analyse.cc
sql/sql_base.cc
sql/sql_class.cc
sql/sql_executor.cc
sql/sql_lex.cc
sql/sql_load.cc
sql/sql_optimizer.cc
sql/sql_parse.cc
sql/sql_profile.cc
sql/sql_resolver.cc
sql/sql_show.cc
sql/sql_tmp_table.cc
sql/sql_update.cc
sql/sql_view.cc
sql/sql_yacc.yy
sql/table.cc
3825 Rohit Kalhans 2012-03-30 [merge]
upmerge from mysql-5.5 branch to mysql-trunk branch
modified:
mysql-test/r/explain.result
mysql-test/r/get_diagnostics.result
mysql-test/r/innodb_explain_json_non_select_all.result
mysql-test/r/innodb_explain_json_non_select_none.result
mysql-test/r/innodb_explain_non_select_all.result
mysql-test/r/innodb_explain_non_select_none.result
mysql-test/r/myisam_explain_json_non_select_all.result
mysql-test/r/myisam_explain_json_non_select_none.result
mysql-test/r/myisam_explain_non_select_all.result
mysql-test/r/myisam_explain_non_select_none.result
mysql-test/r/partition_error.result
mysql-test/r/partition_exchange.result
mysql-test/r/read_only_innodb.result
mysql-test/r/sp-destruct.result
mysql-test/r/type_time.result
mysql-test/r/variables.result
mysql-test/suite/binlog/r/binlog_rewrite.result
mysql-test/suite/binlog/r/binlog_unsafe.result
mysql-test/suite/binlog/t/binlog_unsafe.test
mysql-test/suite/rpl/r/rpl_alter_repository.result
mysql-test/suite/rpl/r/rpl_known_bugs_detection.result
mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result
mysql-test/suite/rpl/r/rpl_parallel_start_stop.result
mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result
mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result
mysql-test/suite/rpl/t/rpl_alter_repository.test
mysql-test/suite/rpl/t/rpl_parallel_start_stop.test
mysql-test/suite/sys_vars/r/max_binlog_cache_size_basic.result
mysql-test/suite/sys_vars/r/max_binlog_stmt_cache_size_basic.result
sql/share/errmsg-utf8.txt
sql/sql_base.cc
sql/sql_lex.cc
sql/sql_lex.h
=== modified file 'sql/field.cc'
--- a/sql/field.cc 2012-03-20 05:51:52 +0000
+++ b/sql/field.cc 2012-03-30 15:38:01 +0000
@@ -2579,7 +2579,7 @@ Field *Field_new_decimal::create_from_it
/* Corrected value fits. */
len= required_length;
}
- return new Field_new_decimal(len, item->maybe_null, item->name,
+ return new Field_new_decimal(len, item->maybe_null, item->item_name.ptr(),
dec, item->unsigned_flag);
}
=== modified file 'sql/item.cc'
--- a/sql/item.cc 2012-03-28 13:39:57 +0000
+++ b/sql/item.cc 2012-03-30 15:38:01 +0000
@@ -547,8 +547,8 @@ int Item::save_str_value_in_field(Field
Item::Item():
- is_expensive_cache(-1), rsize(0), name(0), orig_name(0), name_length(0),
- marker(0), fixed(0), is_autogenerated_name(TRUE),
+ is_expensive_cache(-1), rsize(0),
+ marker(0), fixed(0),
collation(&my_charset_bin, DERIVATION_COERCIBLE), with_subselect(false)
{
maybe_null=null_value=with_sum_func=unsigned_flag=0;
@@ -585,10 +585,9 @@ Item::Item(THD *thd, Item *item):
is_expensive_cache(-1),
rsize(0),
str_value(item->str_value),
- name(item->name),
+ item_name(item->item_name),
orig_name(item->orig_name),
max_length(item->max_length),
- name_length(item->name_length),
marker(item->marker),
decimals(item->decimals),
maybe_null(item->maybe_null),
@@ -596,7 +595,6 @@ Item::Item(THD *thd, Item *item):
unsigned_flag(item->unsigned_flag),
with_sum_func(item->with_sum_func),
fixed(item->fixed),
- is_autogenerated_name(item->is_autogenerated_name),
collation(item->collation),
cmp_context(item->cmp_context),
with_subselect(item->with_subselect)
@@ -672,11 +670,11 @@ void Item::print_item_w_name(String *str
{
print(str, query_type);
- if (name)
+ if (item_name.ptr())
{
THD *thd= current_thd;
str->append(STRING_WITH_LEN(" AS "));
- append_identifier(thd, str, name, (uint) strlen(name));
+ append_identifier(thd, str, item_name.ptr(), item_name.length());
}
}
@@ -698,9 +696,9 @@ void Item::print_for_order(String *str,
{
if (used_alias)
{
- DBUG_ASSERT(name != NULL);
+ DBUG_ASSERT(item_name.ptr() != NULL);
// In the clause, user has referenced expression using an alias; we use it
- append_identifier(current_thd, str, name, (uint) strlen(name));
+ append_identifier(current_thd, str, item_name.ptr(), item_name.length());
}
else
print(str,query_type);
@@ -712,8 +710,8 @@ void Item::cleanup()
DBUG_ENTER("Item::cleanup");
fixed=0;
marker= 0;
- if (orig_name)
- name= orig_name;
+ if (orig_name.ptr())
+ item_name= orig_name;
DBUG_VOID_RETURN;
}
@@ -744,9 +742,9 @@ void Item::rename(char *new_name)
we can compare pointers to names here, because if name was not changed,
pointer will be same
*/
- if (!orig_name && new_name != name)
- orig_name= name;
- name= new_name;
+ if (!orig_name.ptr() && new_name != item_name.ptr())
+ orig_name= item_name;
+ item_name.set(new_name);
}
@@ -797,7 +795,7 @@ Item_ident::Item_ident(Name_resolution_c
alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
cached_table(0), depended_from(0)
{
- name = (char*) field_name_arg;
+ item_name.set(field_name_arg);
}
@@ -960,13 +958,13 @@ bool Item::check_cols(uint c)
}
-void Item::set_name(const char *str, uint length, const CHARSET_INFO *cs)
+void NameString::copy(const char *str, uint length, const CHARSET_INFO *cs)
{
if (!length)
{
/* Empty string, used by AS or internal function like last_insert_id() */
- name= (char*) str;
- name_length= 0;
+ m_str= (char*) str;
+ m_length= 0;
return;
}
if (cs->ctype)
@@ -976,12 +974,12 @@ void Item::set_name(const char *str, uin
This will probably need a better implementation in the future:
a function in CHARSET_INFO structure.
*/
- while (length && !my_isgraph(cs,*str))
+ while (length && !my_isgraph(cs, *str))
{ // Fix problem with yacc
length--;
str++;
}
- if (orig_len != length && !is_autogenerated_name)
+ if (orig_len != length && !is_autogenerated())
{
if (length == 0)
push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
@@ -996,12 +994,12 @@ void Item::set_name(const char *str, uin
if (!my_charset_same(cs, system_charset_info))
{
size_t res_length;
- name= sql_strmake_with_convert(str, name_length= length, cs,
- MAX_ALIAS_NAME, system_charset_info,
- &res_length);
+ m_str= sql_strmake_with_convert(str, length, cs, MAX_ALIAS_NAME,
+ system_charset_info, &res_length);
+ m_length= res_length;
}
else
- name= sql_strmake(str, (name_length= min<size_t>(length, MAX_ALIAS_NAME)));
+ m_str= sql_strmake(str, (m_length= min<size_t>(length, MAX_ALIAS_NAME)));
}
@@ -1019,8 +1017,7 @@ bool Item::eq(const Item *item, bool bin
for all basic constants we have special checks, and Item_param's
type() can be only among basic constant types.
*/
- return type() == item->type() && name && item->name &&
- !my_strcasecmp(system_charset_info,name,item->name);
+ return type() == item->type() && item_name.eq(&item->item_name);
}
@@ -1849,7 +1846,7 @@ Item::Type Item_name_const::type() const
bool Item_name_const::fix_fields(THD *thd, Item **ref)
{
char buf[128];
- String *item_name;
+ String *tmp;
String s(buf, sizeof(buf), &my_charset_bin);
s.length(0);
@@ -1857,14 +1854,14 @@ bool Item_name_const::fix_fields(THD *th
name_item->fix_fields(thd, &name_item) ||
!value_item->const_item() ||
!name_item->const_item() ||
- !(item_name= name_item->val_str(&s))) // Can't have a NULL name
+ !(tmp= name_item->val_str(&s))) // Can't have a NULL name
{
my_error(ER_RESERVED_SYNTAX, MYF(0), "NAME_CONST");
return TRUE;
}
- if (is_autogenerated_name)
+ if (item_name.is_autogenerated())
{
- set_name(item_name->ptr(), (uint) item_name->length(), system_charset_info);
+ item_name.copy(tmp->ptr(), (uint) tmp->length(), system_charset_info);
}
collation.set(value_item->collation.collation, DERIVATION_IMPLICIT,
value_item->collation.repertoire);
@@ -1964,7 +1961,8 @@ void Item::split_sum_func2(THD *thd, Ref
ref_pointer_array[el]= real_itm;
if (!(item_ref= new Item_aggregate_ref(&thd->lex->current_select->context,
- &ref_pointer_array[el], 0, name)))
+ &ref_pointer_array[el], 0,
+ item_name.ptr())))
return; // fatal_error is set
if (type() == SUM_FUNC_ITEM)
item_ref->depended_from= ((Item_sum *) this)->depended_from();
@@ -2432,7 +2430,7 @@ Item_field::Item_field(THD *thd, Name_re
during execution. Still we need it to point to persistent
memory if this item is to be reused.
*/
- name= (char*) orig_field_name;
+ item_name.set(orig_field_name);
}
set_field(f);
}
@@ -2554,14 +2552,14 @@ void Item_field::reset_field(Field *f)
{
set_field(f);
/* 'name' is pointing at field->field_name of old field */
- name= (char*) f->field_name;
+ item_name.set(f->field_name);
}
const char *Item_ident::full_name() const
{
char *tmp;
if (!table_name || !field_name)
- return field_name ? field_name : name ? name : "tmp_field";
+ return field_name ? field_name : item_name.ptr() ? item_name.ptr() : "tmp_field";
if (db_name && db_name[0])
{
tmp=(char*) sql_alloc((uint) strlen(db_name)+(uint) strlen(table_name)+
@@ -2607,7 +2605,7 @@ void Item_ident::print(String *str, enum
if (!table_name || !field_name || !field_name[0])
{
const char *nm= (field_name && field_name[0]) ?
- field_name : name ? name : "tmp_field";
+ field_name : item_name.ptr() ? item_name.ptr() : "tmp_field";
append_identifier(thd, str, nm, (uint) strlen(nm));
return;
}
@@ -2831,8 +2829,7 @@ bool Item_field::eq(const Item *item, bo
(In cases where we would choose wrong we would have to generate a
ER_NON_UNIQ_ERROR).
*/
- return (!my_strcasecmp(system_charset_info, item_field->name,
- field_name) &&
+ return (item_field->item_name.eq(field_name) &&
(!item_field->table_name || !table_name ||
(!my_strcasecmp(table_alias_charset, item_field->table_name,
table_name) &&
@@ -2951,18 +2948,17 @@ longlong Item_field::val_int_endpoint(bo
}
/**
- Create an item from a string we KNOW points to a valid longlong
- end \\0 terminated number string.
+ Create an item from a string we KNOW points to a valid longlong.
+ str_arg does not necessary has to be a \\0 terminated string.
This is always 'signed'. Unsigned values are created with Item_uint()
*/
-
Item_int::Item_int(const char *str_arg, uint length)
{
char *end_ptr= (char*) str_arg + length;
int error;
value= my_strtoll10(str_arg, &end_ptr, &error);
max_length= (uint) (end_ptr - str_arg);
- name= (char*) str_arg;
+ item_name.copy(str_arg, max_length);
fixed= 1;
}
@@ -3024,7 +3020,7 @@ Item_decimal::Item_decimal(const char *s
const CHARSET_INFO *charset)
{
str2my_decimal(E_DEC_FATAL_ERROR, str_arg, length, charset, &decimal_value);
- name= (char*) str_arg;
+ item_name.set(str_arg);
decimals= (uint8) decimal_value.frac;
fixed= 1;
max_length= my_decimal_precision_to_length_no_truncation(decimal_value.intg +
@@ -3061,7 +3057,7 @@ Item_decimal::Item_decimal(const char *s
uint decimal_par, uint length)
{
my_decimal2decimal(val_arg, &decimal_value);
- name= (char*) str;
+ item_name.set(str);
decimals= (uint8) decimal_par;
max_length= length;
fixed= 1;
@@ -3381,7 +3377,7 @@ Item_param::Item_param(uint pos_in_query
limit_clause_param(FALSE),
m_out_param_info(NULL)
{
- name= (char*) "?";
+ item_name.set("?");
/*
Since we can't say whenever this item can be NULL or cannot be NULL
before mysql_stmt_execute(), so we assuming that it can be NULL until
@@ -3988,16 +3984,16 @@ Item_param::clone_item()
/* see comments in the header file */
switch (state) {
case NULL_VALUE:
- return new Item_null(name);
+ return new Item_null(item_name.ptr());
case INT_VALUE:
return (unsigned_flag ?
- new Item_uint(name, value.integer, max_length) :
- new Item_int(name, value.integer, max_length));
+ new Item_uint(item_name.ptr(), value.integer, max_length) :
+ new Item_int(item_name.ptr(), value.integer, max_length));
case REAL_VALUE:
- return new Item_float(name, value.real, decimals, max_length);
+ return new Item_float(item_name.ptr(), value.real, decimals, max_length);
case STRING_VALUE:
case LONG_DATA_VALUE:
- return new Item_string(name, str_value.c_ptr_quick(), str_value.length(),
+ return new Item_string(item_name.ptr(), str_value.c_ptr_quick(), str_value.length(),
str_value.charset());
case TIME_VALUE:
break;
@@ -4865,7 +4861,7 @@ resolve_ref_in_select_and_group(THD *thd
the strict mode is enabled.
*/
my_error(ER_NON_GROUPING_FIELD_USED, MYF(0),
- ref->name, "HAVING");
+ ref->item_name.ptr(), "HAVING");
return NULL;
}
if (select_ref != not_found_item || group_by_ref)
@@ -4876,7 +4872,7 @@ resolve_ref_in_select_and_group(THD *thd
if (!select->ref_pointer_array[counter])
{
my_error(ER_ILLEGAL_REFERENCE, MYF(0),
- ref->name, "forward reference in item list");
+ ref->item_name.ptr(), "forward reference in item list");
return NULL;
}
DBUG_ASSERT((*select_ref)->fixed);
@@ -5303,7 +5299,7 @@ bool Item_field::fix_fields(THD *thd, It
if (new_field == NULL)
{
/* The column to which we link isn't valid. */
- my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name,
+ my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->item_name.ptr(),
current_thd->where);
return(1);
}
@@ -5725,7 +5721,7 @@ void Item::init_make_field(Send_field *t
tmp_field->org_table_name= empty_name;
tmp_field->org_col_name= empty_name;
tmp_field->table_name= empty_name;
- tmp_field->col_name= name;
+ tmp_field->col_name= item_name.ptr();
tmp_field->charsetnr= collation.collation->number;
tmp_field->flags= (maybe_null ? 0 : NOT_NULL_FLAG) |
(my_binary_compare(charset_for_protocol()) ?
@@ -5871,15 +5867,15 @@ Field *Item::make_string_field(TABLE *ta
Field *field;
DBUG_ASSERT(collation.collation);
if (max_length/collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB)
- field= new Field_blob(max_length, maybe_null, name,
+ field= new Field_blob(max_length, maybe_null, item_name.ptr(),
collation.collation, TRUE);
/* Item_type_holder holds the exact type, do not change it */
else if (max_length > 0 &&
(type() != Item::TYPE_HOLDER || field_type() != MYSQL_TYPE_STRING))
- field= new Field_varstring(max_length, maybe_null, name, table->s,
- collation.collation);
+ field= new Field_varstring(max_length, maybe_null, item_name.ptr(),
+ table->s, collation.collation);
else
- field= new Field_string(max_length, maybe_null, name,
+ field= new Field_string(max_length, maybe_null, item_name.ptr(),
collation.collation);
if (field)
field->init(table);
@@ -5914,58 +5910,58 @@ Field *Item::tmp_table_field_from_field_
break;
case MYSQL_TYPE_TINY:
field= new Field_tiny((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, 0, unsigned_flag);
+ item_name.ptr(), 0, unsigned_flag);
break;
case MYSQL_TYPE_SHORT:
field= new Field_short((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, 0, unsigned_flag);
+ item_name.ptr(), 0, unsigned_flag);
break;
case MYSQL_TYPE_LONG:
field= new Field_long((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, 0, unsigned_flag);
+ item_name.ptr(), 0, unsigned_flag);
break;
#ifdef HAVE_LONG_LONG
case MYSQL_TYPE_LONGLONG:
field= new Field_longlong((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, 0, unsigned_flag);
+ item_name.ptr(), 0, unsigned_flag);
break;
#endif
case MYSQL_TYPE_FLOAT:
field= new Field_float((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, decimals, 0, unsigned_flag);
+ item_name.ptr(), decimals, 0, unsigned_flag);
break;
case MYSQL_TYPE_DOUBLE:
field= new Field_double((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, decimals, 0, unsigned_flag);
+ item_name.ptr(), decimals, 0, unsigned_flag);
break;
case MYSQL_TYPE_NULL:
field= new Field_null((uchar*) 0, max_length, Field::NONE,
- name, &my_charset_bin);
+ item_name.ptr(), &my_charset_bin);
break;
case MYSQL_TYPE_INT24:
field= new Field_medium((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name, 0, unsigned_flag);
+ item_name.ptr(), 0, unsigned_flag);
break;
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_NEWDATE:
- field= new Field_newdate(maybe_null, name);
+ field= new Field_newdate(maybe_null, item_name.ptr());
break;
case MYSQL_TYPE_TIME:
- field= new Field_timef(maybe_null, name, decimals);
+ field= new Field_timef(maybe_null, item_name.ptr(), decimals);
break;
case MYSQL_TYPE_TIMESTAMP:
- field= new Field_timestampf(maybe_null, name, decimals);
+ field= new Field_timestampf(maybe_null, item_name.ptr(), decimals);
break;
case MYSQL_TYPE_DATETIME:
- field= new Field_datetimef(maybe_null, name, decimals);
+ field= new Field_datetimef(maybe_null, item_name.ptr(), decimals);
break;
case MYSQL_TYPE_YEAR:
field= new Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
- name);
+ item_name.ptr());
break;
case MYSQL_TYPE_BIT:
field= new Field_bit_as_char(NULL, max_length, null_ptr, 0,
- Field::NONE, name);
+ Field::NONE, item_name.ptr());
break;
default:
/* This case should never be chosen */
@@ -5974,7 +5970,7 @@ Field *Item::tmp_table_field_from_field_
case MYSQL_TYPE_STRING:
if (fixed_length && max_length < CONVERT_IF_BIGGER_TO_BLOB)
{
- field= new Field_string(max_length, maybe_null, name,
+ field= new Field_string(max_length, maybe_null, item_name.ptr(),
collation.collation);
break;
}
@@ -5989,15 +5985,15 @@ Field *Item::tmp_table_field_from_field_
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
if (this->type() == Item::TYPE_HOLDER)
- field= new Field_blob(max_length, maybe_null, name, collation.collation,
+ field= new Field_blob(max_length, maybe_null, item_name.ptr(), collation.collation,
1);
else
- field= new Field_blob(max_length, maybe_null, name, collation.collation);
+ field= new Field_blob(max_length, maybe_null, item_name.ptr(), collation.collation);
break; // Blob handled outside of case
#ifdef HAVE_SPATIAL
case MYSQL_TYPE_GEOMETRY:
field= new Field_geom(max_length, maybe_null,
- name, table->s, get_geometry_type());
+ item_name.ptr(), table->s, get_geometry_type());
#endif /* HAVE_SPATIAL */
}
if (field)
@@ -6011,8 +6007,8 @@ void Item_field::make_field(Send_field *
{
field->make_field(tmp_field);
DBUG_ASSERT(tmp_field->table_name != 0);
- if (name)
- tmp_field->col_name=name; // Use user supplied name
+ if (item_name.ptr())
+ tmp_field->col_name= item_name.ptr(); // Use user supplied name
if (table_name)
tmp_field->table_name= table_name;
if (db_name)
@@ -6245,8 +6241,8 @@ Item *Item_int_with_ref::clone_item()
parameter markers.
*/
return (ref->unsigned_flag ?
- new Item_uint(ref->name, ref->val_int(), ref->max_length) :
- new Item_int(ref->name, ref->val_int(), ref->max_length));
+ new Item_uint(ref->item_name.ptr(), ref->val_int(), ref->max_length) :
+ new Item_int(ref->item_name.ptr(), ref->val_int(), ref->max_length));
}
@@ -6257,7 +6253,7 @@ Item *Item_time_with_ref::clone_item()
We need to evaluate the constant to make sure it works with
parameter markers.
*/
- return new Item_temporal(MYSQL_TYPE_TIME, ref->name,
+ return new Item_temporal(MYSQL_TYPE_TIME, ref->item_name.ptr(),
ref->val_time_temporal(), ref->max_length);
}
@@ -6269,7 +6265,7 @@ Item *Item_datetime_with_ref::clone_item
We need to evaluate the constant to make sure it works with
parameter markers.
*/
- return new Item_temporal(MYSQL_TYPE_DATETIME, ref->name,
+ return new Item_temporal(MYSQL_TYPE_DATETIME, ref->item_name.ptr(),
ref->val_date_temporal(), ref->max_length);
}
@@ -6339,12 +6335,9 @@ static uint nr_of_decimals(const char *s
- when parsing XPath query from item_xmlfunc.cc
We will signal an error if value is not a true double value (overflow):
eng: Illegal %s '%-.192s' value found during parsing
-
- Note: the string is NOT null terminated when called from item_xmlfunc.cc,
- so this->name will contain some SQL query tail behind the "length" bytes.
- This is Ok for now, as this Item is never seen in SHOW,
- or EXPLAIN, or anywhere else in metadata.
- Item->name should be fixed to use LEX_STRING eventually.
+
+ Note: str_arg does not necessarily have to be a null terminated string,
+ e.g. it is NOT when called from item_xmlfunc.cc or sql_yacc.yy.
*/
Item_float::Item_float(const char *str_arg, uint length)
@@ -6359,7 +6352,8 @@ Item_float::Item_float(const char *str_a
my_snprintf(tmp, sizeof(tmp), "%.*s", length, str_arg);
my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0), "double", tmp);
}
- presentation= name=(char*) str_arg;
+ presentation.copy(str_arg, length);
+ item_name.copy(str_arg, length);
decimals=(uint8) nr_of_decimals(str_arg, str_arg+length);
max_length=length;
fixed= 1;
@@ -6378,9 +6372,9 @@ int Item_float::save_in_field(Field *fie
void Item_float::print(String *str, enum_query_type query_type)
{
- if (presentation)
+ if (presentation.ptr())
{
- str->append(presentation);
+ str->append(presentation.ptr());
return;
}
char buffer[20];
@@ -7166,13 +7160,13 @@ bool Item_ref::fix_fields(THD *thd, Item
*/
if (!((*ref)->type() == REF_ITEM &&
((Item_ref *)(*ref))->ref_type() == OUTER_REF) &&
- (((*ref)->with_sum_func && name &&
+ (((*ref)->with_sum_func && item_name.ptr() &&
!(current_sel->linkage != GLOBAL_OPTIONS_TYPE &&
current_sel->having_fix_field)) ||
!(*ref)->fixed))
{
my_error(ER_ILLEGAL_REFERENCE, MYF(0),
- name, ((*ref)->with_sum_func?
+ item_name.ptr(), ((*ref)->with_sum_func?
"reference to group function":
"forward reference in item list"));
goto error;
@@ -7318,11 +7312,11 @@ void Item_ref::print(String *str, enum_q
if (ref)
{
if ((*ref)->type() != Item::CACHE_ITEM && ref_type() != VIEW_REF &&
- !table_name && name && alias_name_used)
+ !table_name && item_name.ptr() && alias_name_used)
{
THD *thd= current_thd;
- append_identifier(thd, str, (*ref)->real_item()->name,
- strlen((*ref)->real_item()->name));
+ append_identifier(thd, str, (*ref)->real_item()->item_name.ptr(),
+ (*ref)->real_item()->item_name.length());
}
else
(*ref)->print(str, query_type);
@@ -7537,8 +7531,8 @@ void Item_ref::make_field(Send_field *fi
{
(*ref)->make_field(field);
/* Non-zero in case of a view */
- if (name)
- field->col_name= name;
+ if (item_name.ptr())
+ field->col_name= item_name.ptr();
if (table_name)
field->table_name= table_name;
if (db_name)
@@ -7795,7 +7789,7 @@ bool Item_default_value::fix_fields(THD
real_arg= arg->real_item();
if (real_arg->type() != FIELD_ITEM)
{
- my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), arg->name);
+ my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), arg->item_name.ptr());
goto error;
}
@@ -8158,7 +8152,7 @@ void resolve_const_item(THD *thd, Item *
return; // Can't be better
Item_result res_type=item_cmp_type(comp_item->result_type(),
item->result_type());
- char *name=item->name; // Alloced by sql_alloc
+ char *name= item->item_name.ptr(); // Alloced by sql_alloc
switch (res_type) {
case STRING_RESULT:
@@ -9091,7 +9085,7 @@ bool Item_type_holder::join_types(THD *t
DBUG_ENTER("Item_type_holder::join_types");
DBUG_PRINT("info:", ("was type %d len %d, dec %d name %s",
fld_type, max_length, decimals,
- (name ? name : "<NULL>")));
+ (item_name.ptr() ? item_name.ptr() : "<NULL>")));
DBUG_PRINT("info:", ("in type %d len %d, dec %d",
get_real_type(item),
item->max_length, item->decimals));
@@ -9272,7 +9266,7 @@ Field *Item_type_holder::make_field_by_t
case MYSQL_TYPE_ENUM:
DBUG_ASSERT(enum_set_typelib);
field= new Field_enum((uchar *) 0, max_length, null_ptr, 0,
- Field::NONE, name,
+ Field::NONE, item_name.ptr(),
get_enum_pack_length(enum_set_typelib->count),
enum_set_typelib, collation.collation);
if (field)
@@ -9281,7 +9275,7 @@ Field *Item_type_holder::make_field_by_t
case MYSQL_TYPE_SET:
DBUG_ASSERT(enum_set_typelib);
field= new Field_set((uchar *) 0, max_length, null_ptr, 0,
- Field::NONE, name,
+ Field::NONE, item_name.ptr(),
get_set_pack_length(enum_set_typelib->count),
enum_set_typelib, collation.collation);
if (field)
=== modified file 'sql/item.h'
--- a/sql/item.h 2012-03-20 12:26:25 +0000
+++ b/sql/item.h 2012-03-30 15:38:01 +0000
@@ -504,6 +504,87 @@ typedef Item* (Item::*Item_transformer)
typedef void (*Cond_traverser) (const Item *item, void *arg);
+class NameString
+{
+private:
+ char *m_str;
+ uint m_length;
+ bool m_is_autogenerated; /* indicates if name of this Item
+ was autogenerated or set by user */
+public:
+ NameString()
+ {
+ m_str= 0;
+ m_length= 0;
+ m_is_autogenerated= true;
+ }
+ /**
+ Set m_is_autogenerated flag to the given value.
+ */
+ void set_autogenerated(bool is_autogenerated)
+ {
+ m_is_autogenerated= is_autogenerated;
+ }
+ /**
+ Allocate space using sql_strmake() or sql_strmake_with_convert().
+ */
+ void copy(const char *str, uint length, const CHARSET_INFO *cs);
+ /**
+ Variants for copy(), for various argument combinations.
+ */
+ void copy(const char *str, uint length, const CHARSET_INFO *cs,
+ bool is_autogenerated)
+ {
+ m_is_autogenerated= is_autogenerated; // Must be done before set/copy
+ copy(str, length, cs);
+ }
+ void copy(const char *str, uint length)
+ {
+ copy(str, length, system_charset_info);
+ }
+ void copy(const char *str)
+ {
+ copy(str, (uint) (str ? strlen(str) : 0), system_charset_info);
+ }
+ /**
+ Set name to the existing memory. No allocation happens.
+ */
+ void set(const char *str)
+ {
+ m_str= (char *) str;
+ m_length= str ? strlen(str) : 0;
+ }
+ /**
+ Return name buffer.
+ */
+ char *ptr() const { return m_str; }
+ /**
+ Return name length.
+ */
+ uint length() const { return m_length; }
+ /**
+ Return if name was auto-generated.
+ */
+ bool is_autogenerated() const { return m_is_autogenerated; }
+ /**
+ Compare name to another name in NameString.
+ */
+ bool eq(const NameString *name) const
+ {
+ return ptr() && name->ptr() &&
+ my_strcasecmp(system_charset_info, ptr(), name->ptr()) == 0;
+ }
+ /**
+ Compare name to another name in C string.
+ */
+ bool eq(const char *str) const
+ {
+ return ptr() && str &&
+ my_strcasecmp(system_charset_info, ptr(), str) == 0;
+ }
+};
+
+
class Item
{
Item(const Item &); /* Prevent use of these */
@@ -542,9 +623,10 @@ public:
save_in_field
*/
String str_value;
- char * name; /* Name from select */
- /* Original item name (if it was renamed)*/
- char * orig_name;
+
+ NameString item_name; /* Name from select */
+ NameString orig_name; /* Original item name (if it was renamed)*/
+
/**
Intrusive list pointer for free list. If not null, points to the next
Item on some Query_arena's free list. For instance, stored procedures
@@ -554,11 +636,6 @@ public:
*/
Item *next;
uint32 max_length; /* Maximum length, in bytes */
- /*
- TODO: convert name and name_length fields into String to keep them in sync
- (see bug #11829681/60295 etc).
- */
- uint name_length; /* Length of name */
/**
This member has several successive meanings, depending on the phase we're
in:
@@ -583,8 +660,6 @@ public:
my_bool unsigned_flag;
my_bool with_sum_func;
my_bool fixed; /* If item fixed with fix_fields */
- my_bool is_autogenerated_name; /* indicate was name of this Item
- autogenerated or set by user */
DTCollation collation;
Item_result cmp_context; /* Comparison context */
protected:
@@ -608,10 +683,9 @@ public:
virtual ~Item()
{
#ifdef EXTRA_DEBUG
- name=0;
+ item_name.set(0);
#endif
} /*lint -e1509 */
- void set_name(const char *str, uint length, const CHARSET_INFO *cs);
void rename(char *new_name);
void init_make_field(Send_field *tmp_field,enum enum_field_types type);
virtual void cleanup();
@@ -1009,7 +1083,10 @@ public:
virtual Field *get_tmp_table_field() { return 0; }
/* This is also used to create fields in CREATE ... SELECT: */
virtual Field *tmp_table_field(TABLE *t_arg) { return 0; }
- virtual const char *full_name() const { return name ? name : "???"; }
+ virtual const char *full_name() const
+ {
+ return item_name.ptr() ? item_name.ptr() : "???";
+ }
/*
*result* family of methods is analog of *val* family (see above) but
@@ -1533,8 +1610,8 @@ public:
in the statement memory. If the name is auto generated, it must be
done again between subsequent executions of a prepared statement.
*/
- if (orig_name)
- name= orig_name;
+ if (orig_name.ptr())
+ item_name= orig_name;
}
};
@@ -1595,10 +1672,10 @@ inline void Item_sp_variable::make_field
{
Item *it= this_item();
- if (name)
- it->set_name(name, (uint) strlen(name), system_charset_info);
+ if (item_name.ptr())
+ it->item_name.copy(item_name.ptr(), (uint) item_name.length());
else
- it->set_name(m_name.str, (uint) m_name.length, system_charset_info);
+ it->item_name.copy(m_name.str, (uint) m_name.length);
it->make_field(field);
}
@@ -2107,7 +2184,7 @@ public:
{
maybe_null= null_value= TRUE;
max_length= 0;
- name= name_par ? name_par : (char*) "NULL";
+ item_name.copy(name_par ? name_par : (char*) "NULL");
fixed= 1;
collation.set(&my_charset_bin, DERIVATION_IGNORABLE);
}
@@ -2133,7 +2210,7 @@ public:
enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_NULL; }
bool basic_const_item() const { return 1; }
- Item *clone_item() { return new Item_null(name); }
+ Item *clone_item() { return new Item_null(item_name.ptr()); }
bool is_null() { return 1; }
virtual inline void print(String *str, enum_query_type query_type)
@@ -2334,9 +2411,20 @@ public:
Item_int(ulonglong i, uint length= MY_INT64_NUM_DECIMAL_DIGITS)
:value((longlong)i)
{ max_length=length; fixed= 1; unsigned_flag= 1; }
+ Item_int(Item_int *item_arg)
+ {
+ value= item_arg->value;
+ item_name= item_arg->item_name;
+ max_length= item_arg->max_length;
+ fixed= 1;
+ }
Item_int(const char *str_arg,longlong i,uint length) :value(i)
- { max_length=length; name=(char*) str_arg; fixed= 1; }
- Item_int(const char *str_arg, uint length=64);
+ {
+ max_length= length;
+ item_name.set(str_arg);
+ fixed= 1;
+ }
+ Item_int(const char *str_arg, uint length);
enum Type type() const { return INT_ITEM; }
enum Item_result result_type () const { return INT_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
@@ -2354,7 +2442,7 @@ public:
}
int save_in_field(Field *field, bool no_conversions);
bool basic_const_item() const { return 1; }
- Item *clone_item() { return new Item_int(name,value,max_length); }
+ Item *clone_item() { return new Item_int(this); }
virtual void print(String *str, enum_query_type query_type);
Item_num *neg() { value= -value; return this; }
uint decimal_precision() const
@@ -2389,7 +2477,7 @@ public:
{
DBUG_ASSERT(is_temporal_type(field_type_arg));
max_length= length;
- name= (char*) str_arg;
+ item_name.set(str_arg);
fixed= 1;
}
Item *clone_item() { return new Item_temporal(field_type(), value); }
@@ -2422,7 +2510,7 @@ public:
double val_real()
{ DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); }
String *val_str(String*);
- Item *clone_item() { return new Item_uint(name, value, max_length); }
+ Item *clone_item() { return new Item_uint(item_name.ptr(), value, max_length); }
int save_in_field(Field *field, bool no_conversions);
virtual void print(String *str, enum_query_type query_type);
Item_num *neg ();
@@ -2464,7 +2552,7 @@ public:
bool basic_const_item() const { return 1; }
Item *clone_item()
{
- return new Item_decimal(name, &decimal_value, decimals, max_length);
+ return new Item_decimal(item_name.ptr(), &decimal_value, decimals, max_length);
}
virtual void print(String *str, enum_query_type query_type);
Item_num *neg()
@@ -2482,7 +2570,7 @@ public:
class Item_float :public Item_num
{
- char *presentation;
+ NameString presentation;
public:
double value;
// Item_real() :value(0) {}
@@ -2490,12 +2578,13 @@ public:
Item_float(const char *str,double val_arg,uint decimal_par,uint length)
:value(val_arg)
{
- presentation= name=(char*) str;
+ presentation.set(str);
+ item_name.set(str);
decimals=(uint8) decimal_par;
max_length=length;
fixed= 1;
}
- Item_float(double value_par, uint decimal_par) :presentation(0), value(value_par)
+ Item_float(double value_par, uint decimal_par) :value(value_par)
{
decimals= (uint8) decimal_par;
fixed= 1;
@@ -2529,7 +2618,7 @@ public:
}
bool basic_const_item() const { return 1; }
Item *clone_item()
- { return new Item_float(name, value, decimals, max_length); }
+ { return new Item_float(item_name.ptr(), value, decimals, max_length); }
Item_num *neg() { value= -value; return this; }
virtual void print(String *str, enum_query_type query_type);
bool eq(const Item *, bool binary_cmp) const;
@@ -2572,7 +2661,7 @@ public:
divide the max_length with mbmaxlen).
*/
max_length= str_value.numchars()*cs->mbmaxlen;
- set_name(str, length, cs);
+ item_name.copy(str, length, cs);
decimals=NOT_FIXED_DEC;
// it is constant => can be used without fix_fields (and frequently used)
fixed= 1;
@@ -2583,7 +2672,7 @@ public:
{
collation.set(cs, dv);
max_length= 0;
- set_name(NULL, 0, cs);
+ item_name.copy(NULL, 0, cs);
decimals= NOT_FIXED_DEC;
fixed= 1;
}
@@ -2595,7 +2684,7 @@ public:
str_value.set_or_copy_aligned(str, length, cs);
collation.set(cs, dv, repertoire);
max_length= str_value.numchars()*cs->mbmaxlen;
- set_name(name_par, 0, cs);
+ item_name.copy(name_par, 0, cs);
decimals=NOT_FIXED_DEC;
// it is constant => can be used without fix_fields (and frequently used)
fixed= 1;
@@ -2639,7 +2728,7 @@ public:
bool eq(const Item *item, bool binary_cmp) const;
Item *clone_item()
{
- return new Item_string(name, str_value.ptr(),
+ return new Item_string(item_name.ptr(), str_value.ptr(),
str_value.length(), collation.collation);
}
Item *safe_charset_converter(const CHARSET_INFO *tocs);
@@ -2769,7 +2858,10 @@ public:
Item_empty_string(const char *header, uint length,
const CHARSET_INFO *cs= NULL) :
Item_partition_func_safe_string("",0, cs ? cs : &my_charset_utf8_general_ci)
- { name=(char*) header; max_length= length * collation.collation->mbmaxlen; }
+ {
+ item_name.set(header);
+ max_length= length * collation.collation->mbmaxlen;
+ }
void make_field(Send_field *field);
};
@@ -3108,7 +3200,7 @@ public:
Item *get_tmp_table_item(THD *thd)
{
Item *item= Item_ref::get_tmp_table_item(thd);
- item->name= name;
+ item->item_name= item_name;
return item;
}
virtual Ref_Type ref_type() { return VIEW_REF; }
@@ -3403,7 +3495,7 @@ protected:
null_value=maybe_null=item->maybe_null;
decimals=item->decimals;
max_length=item->max_length;
- name=item->name;
+ item_name= item->item_name;
cached_field_type= item->field_type();
cached_result_type= item->result_type();
unsigned_flag= item->unsigned_flag;
=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc 2012-03-21 14:27:34 +0000
+++ b/sql/item_cmpfunc.cc 2012-03-30 15:38:01 +0000
@@ -894,7 +894,7 @@ Arg_comparator::can_compare_as_dates(Ite
str_val= str_arg->val_str(&tmp);
if (str_arg->null_value)
return CMP_DATE_DFLT;
- value= get_date_from_str(thd, str_val, t_type, date_arg->name, &error);
+ value= get_date_from_str(thd, str_val, t_type, date_arg->item_name.ptr(), &error);
if (error)
return CMP_DATE_DFLT;
if (const_value)
@@ -1222,7 +1222,7 @@ get_datetime_value(THD *thd, Item ***ite
enum_field_types f_type= warn_item->field_type();
timestamp_type t_type= f_type ==
MYSQL_TYPE_DATE ? MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME;
- value= (longlong) get_date_from_str(thd, str, t_type, warn_item->name, &error);
+ value= (longlong) get_date_from_str(thd, str, t_type, warn_item->item_name.ptr(), &error);
/*
If str did not contain a valid date according to the current
SQL_MODE, get_date_from_str() has already thrown a warning,
=== modified file 'sql/item_create.cc'
--- a/sql/item_create.cc 2012-03-06 14:29:42 +0000
+++ b/sql/item_create.cc 2012-03-30 15:38:01 +0000
@@ -2638,7 +2638,7 @@ static bool has_named_parameters(List<It
List_iterator<Item> it(*params);
while ((param= it++))
{
- if (! param->is_autogenerated_name)
+ if (! param->item_name.is_autogenerated())
return true;
}
}
@@ -2894,7 +2894,7 @@ Create_func_arg1::create_func(THD *thd,
Item *param_1= item_list->pop();
- if (! param_1->is_autogenerated_name)
+ if (! param_1->item_name.is_autogenerated())
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
return NULL;
@@ -2921,8 +2921,8 @@ Create_func_arg2::create_func(THD *thd,
Item *param_1= item_list->pop();
Item *param_2= item_list->pop();
- if ( (! param_1->is_autogenerated_name)
- || (! param_2->is_autogenerated_name))
+ if ( (! param_1->item_name.is_autogenerated())
+ || (! param_2->item_name.is_autogenerated()))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
return NULL;
@@ -2950,9 +2950,9 @@ Create_func_arg3::create_func(THD *thd,
Item *param_2= item_list->pop();
Item *param_3= item_list->pop();
- if ( (! param_1->is_autogenerated_name)
- || (! param_2->is_autogenerated_name)
- || (! param_3->is_autogenerated_name))
+ if ( (! param_1->item_name.is_autogenerated())
+ || (! param_2->item_name.is_autogenerated())
+ || (! param_3->item_name.is_autogenerated()))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str);
return NULL;
@@ -5755,7 +5755,7 @@ create_func_cast(THD *thd, Item *a, Cast
decoded_size= strtoul(c_len, NULL, 10);
if (errno != 0)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), INT_MAX, a->name,
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), INT_MAX, a->item_name.ptr(),
static_cast<ulong>(DECIMAL_MAX_PRECISION));
return NULL;
}
@@ -5769,7 +5769,7 @@ create_func_cast(THD *thd, Item *a, Cast
decoded_size= strtoul(c_dec, NULL, 10);
if ((errno != 0) || (decoded_size > UINT_MAX))
{
- my_error(ER_TOO_BIG_SCALE, MYF(0), INT_MAX, a->name,
+ my_error(ER_TOO_BIG_SCALE, MYF(0), INT_MAX, a->item_name.ptr(),
static_cast<ulong>(DECIMAL_MAX_SCALE));
return NULL;
}
@@ -5783,13 +5783,13 @@ create_func_cast(THD *thd, Item *a, Cast
}
if (len > DECIMAL_MAX_PRECISION)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), static_cast<int>(len), a->name,
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), static_cast<int>(len), a->item_name.ptr(),
static_cast<ulong>(DECIMAL_MAX_PRECISION));
return 0;
}
if (dec > DECIMAL_MAX_SCALE)
{
- my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->name,
+ my_error(ER_TOO_BIG_SCALE, MYF(0), dec, a->item_name.ptr(),
static_cast<ulong>(DECIMAL_MAX_SCALE));
return 0;
}
=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc 2012-03-15 14:41:06 +0000
+++ b/sql/item_func.cc 2012-03-30 15:38:01 +0000
@@ -506,14 +506,14 @@ Field *Item_func::tmp_table_field(TABLE
switch (result_type()) {
case INT_RESULT:
if (max_char_length() > MY_INT32_NUM_DECIMAL_DIGITS)
- field= new Field_longlong(max_char_length(), maybe_null, name,
+ field= new Field_longlong(max_char_length(), maybe_null, item_name.ptr(),
unsigned_flag);
else
- field= new Field_long(max_char_length(), maybe_null, name,
+ field= new Field_long(max_char_length(), maybe_null, item_name.ptr(),
unsigned_flag);
break;
case REAL_RESULT:
- field= new Field_double(max_char_length(), maybe_null, name, decimals);
+ field= new Field_double(max_char_length(), maybe_null, item_name.ptr(), decimals);
break;
case STRING_RESULT:
return make_string_field(table);
@@ -1274,7 +1274,7 @@ err:
push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE,
ER(ER_WARN_DATA_OUT_OF_RANGE),
- name, 1L);
+ item_name.ptr(), 1L);
return dec;
}
@@ -3584,8 +3584,8 @@ udf_handler::fix_fields(THD *thd, Item_r
f_args.lengths[i]= arguments[i]->max_length;
f_args.maybe_null[i]= (char) arguments[i]->maybe_null;
- f_args.attributes[i]= arguments[i]->name;
- f_args.attribute_lengths[i]= arguments[i]->name_length;
+ f_args.attributes[i]= arguments[i]->item_name.ptr();
+ f_args.attribute_lengths[i]= arguments[i]->item_name.length();
if (arguments[i]->const_item())
{
@@ -5196,8 +5196,8 @@ void Item_func_set_user_var::make_field(
{
result_field->make_field(tmp_field);
DBUG_ASSERT(tmp_field->table_name != 0);
- if (Item::name)
- tmp_field->col_name=Item::name; // Use user supplied name
+ if (Item::item_name.ptr())
+ tmp_field->col_name=Item::item_name.ptr(); // Use user supplied name
}
else
Item::make_field(tmp_field);
@@ -5658,8 +5658,8 @@ Item_func_get_system_var(sys_var *var_ar
:var(var_arg), var_type(var_type_arg), orig_var_type(var_type_arg),
component(*component_arg), cache_present(0)
{
- /* set_name() will allocate the name */
- set_name(name_arg, (uint) name_len_arg, system_charset_info);
+ /* copy() will allocate the name */
+ item_name.copy(name_arg, (uint) name_len_arg);
}
@@ -5764,7 +5764,7 @@ void Item_func_get_system_var::fix_lengt
void Item_func_get_system_var::print(String *str, enum_query_type query_type)
{
- str->append(name, name_length);
+ str->append(item_name.ptr(), item_name.length());
}
@@ -6637,7 +6637,7 @@ Item_func_sp::init_result_field(THD *thd
share->table_cache_key = empty_name;
share->table_name = empty_name;
- if (!(sp_result_field= m_sp->create_result_field(max_length, name,
+ if (!(sp_result_field= m_sp->create_result_field(max_length, item_name.ptr(),
dummy_table)))
{
DBUG_RETURN(TRUE);
@@ -6805,8 +6805,8 @@ Item_func_sp::make_field(Send_field *tmp
DBUG_ENTER("Item_func_sp::make_field");
DBUG_ASSERT(sp_result_field);
sp_result_field->make_field(tmp_field);
- if (name)
- tmp_field->col_name= name;
+ if (item_name.ptr())
+ tmp_field->col_name= item_name.ptr();
DBUG_VOID_RETURN;
}
=== modified file 'sql/item_func.h'
--- a/sql/item_func.h 2012-03-06 14:29:42 +0000
+++ b/sql/item_func.h 2012-03-30 15:38:01 +0000
@@ -1009,8 +1009,7 @@ class Item_func_rollup_const :public Ite
public:
Item_func_rollup_const(Item *a) :Item_func(a)
{
- name= a->name;
- name_length= a->name_length;
+ item_name= a->item_name;
}
double val_real() { return args[0]->val_real(); }
longlong val_int() { return args[0]->val_int(); }
@@ -1737,7 +1736,7 @@ class Item_user_var_as_out_param :public
user_var_entry *entry;
public:
Item_user_var_as_out_param(LEX_STRING a) : name(a)
- { set_name(a.str, 0, system_charset_info); }
+ { item_name.copy(a.str, 0); }
/* We should return something different from FIELD_ITEM here */
enum Type type() const { return STRING_ITEM;}
double val_real();
=== modified file 'sql/item_geofunc.cc'
--- a/sql/item_geofunc.cc 2012-03-14 10:34:57 +0000
+++ b/sql/item_geofunc.cc 2012-03-30 15:38:01 +0000
@@ -36,7 +36,7 @@
Field *Item_geometry_func::tmp_table_field(TABLE *t_arg)
{
Field *result;
- if ((result= new Field_geom(max_length, maybe_null, name, t_arg->s,
+ if ((result= new Field_geom(max_length, maybe_null, item_name.ptr(), t_arg->s,
get_geometry_type())))
result->init(t_arg);
return result;
=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc 2012-03-27 12:58:14 +0000
+++ b/sql/item_subselect.cc 2012-03-30 15:38:01 +0000
@@ -218,8 +218,7 @@ bool Item_subselect::fix_fields(THD *thd
unit->outer_select()->having= substitution; // correct HAVING for PS
(*ref)= substitution;
- substitution->is_autogenerated_name= is_autogenerated_name;
- substitution->name= name;
+ substitution->item_name= item_name;
if (have_to_be_excluded)
engine->exclude();
substitution= 0;
@@ -1473,7 +1472,7 @@ Item_in_subselect::single_value_in_to_ex
*/
select_lex->having= join->having= and_items(join->having, item);
if (join->having == item)
- item->name= (char*)in_having_cond;
+ item->item_name.set(in_having_cond);
select_lex->having->top_level_item();
select_lex->having_fix_field= 1;
/*
@@ -1518,7 +1517,7 @@ Item_in_subselect::single_value_in_to_ex
we can assign select_lex->having here, and pass 0 as last
argument (reference) to fix_fields()
*/
- having->name= (char*)in_having_cond;
+ having->item_name.set(in_having_cond);
select_lex->having= join->having= having;
select_lex->having_fix_field= 1;
/*
@@ -1551,7 +1550,7 @@ Item_in_subselect::single_value_in_to_ex
single_value_transformer but there is no corresponding action in
row_value_transformer?
*/
- item->name= (char *)in_additional_cond;
+ item->item_name.set(in_additional_cond);
/*
AND can't be changed during fix_fields()
@@ -1594,7 +1593,7 @@ Item_in_subselect::single_value_in_to_ex
OUTER_FIELD_IS_NOT_NULL)))
DBUG_RETURN(RES_ERROR);
}
- new_having->name= (char*)in_having_cond;
+ new_having->item_name.set(in_having_cond);
select_lex->having= join->having= new_having;
select_lex->having_fix_field= 1;
@@ -1908,7 +1907,7 @@ Item_in_subselect::row_value_in_to_exist
bool res;
select_lex->having= join->having= and_items(join->having, having_item);
if (having_item == select_lex->having)
- having_item->name= (char*)in_having_cond;
+ having_item->item_name.set(in_having_cond);
select_lex->having->top_level_item();
/*
AND can't be changed during fix_fields()
=== modified file 'sql/item_sum.cc'
--- a/sql/item_sum.cc 2012-03-06 14:29:42 +0000
+++ b/sql/item_sum.cc 2012-03-30 15:38:01 +0000
@@ -502,10 +502,10 @@ Field *Item_sum::create_tmp_field(bool g
Field *field;
switch (result_type()) {
case REAL_RESULT:
- field= new Field_double(max_length, maybe_null, name, decimals, TRUE);
+ field= new Field_double(max_length, maybe_null, item_name.ptr(), decimals, TRUE);
break;
case INT_RESULT:
- field= new Field_longlong(max_length, maybe_null, name, unsigned_flag);
+ field= new Field_longlong(max_length, maybe_null, item_name.ptr(), unsigned_flag);
break;
case STRING_RESULT:
if (max_length/collation.collation->mbmaxlen <= 255 ||
@@ -513,7 +513,7 @@ Field *Item_sum::create_tmp_field(bool g
!convert_blob_length)
return make_string_field(table);
field= new Field_varstring(convert_blob_length, maybe_null,
- name, table->s, collation.collation);
+ item_name.ptr(), table->s, collation.collation);
break;
case DECIMAL_RESULT:
field= Field_new_decimal::create_from_item(this);
@@ -1217,7 +1217,7 @@ Field *Item_sum_hybrid::create_tmp_field
{
field= ((Item_field*) args[0])->field;
- if ((field= create_tmp_field_from_field(current_thd, field, name, table,
+ if ((field= create_tmp_field_from_field(current_thd, field, item_name.ptr(), table,
NULL, convert_blob_length)))
field->flags&= ~NOT_NULL_FLAG;
return field;
@@ -1229,14 +1229,14 @@ Field *Item_sum_hybrid::create_tmp_field
*/
switch (args[0]->field_type()) {
case MYSQL_TYPE_DATE:
- field= new Field_newdate(maybe_null, name);
+ field= new Field_newdate(maybe_null, item_name.ptr());
break;
case MYSQL_TYPE_TIME:
- field= new Field_timef(maybe_null, name, decimals);
+ field= new Field_timef(maybe_null, item_name.ptr(), decimals);
break;
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
- field= new Field_datetimef(maybe_null, name, decimals);
+ field= new Field_datetimef(maybe_null, item_name.ptr(), decimals);
break;
default:
return Item_sum::create_tmp_field(group, table, convert_blob_length);
@@ -1566,12 +1566,12 @@ Field *Item_sum_avg::create_tmp_field(bo
*/
field= new Field_string(((hybrid_type == DECIMAL_RESULT) ?
dec_bin_size : sizeof(double)) + sizeof(longlong),
- 0, name, &my_charset_bin);
+ 0, item_name.ptr(), &my_charset_bin);
}
else if (hybrid_type == DECIMAL_RESULT)
field= Field_new_decimal::create_from_item(this);
else
- field= new Field_double(max_length, maybe_null, name, decimals, TRUE);
+ field= new Field_double(max_length, maybe_null, item_name.ptr(), decimals, TRUE);
if (field)
field->init(table);
return field;
@@ -1782,10 +1782,10 @@ Field *Item_sum_variance::create_tmp_fie
The easiest way is to do this is to store both value in a string
and unpack on access.
*/
- field= new Field_string(sizeof(double)*2 + sizeof(longlong), 0, name, &my_charset_bin);
+ field= new Field_string(sizeof(double)*2 + sizeof(longlong), 0, item_name.ptr(), &my_charset_bin);
}
else
- field= new Field_double(max_length, maybe_null, name, decimals, TRUE);
+ field= new Field_double(max_length, maybe_null, item_name.ptr(), decimals, TRUE);
if (field != NULL)
field->init(table);
@@ -2563,7 +2563,7 @@ void Item_sum_hybrid::min_max_update_dec
Item_avg_field::Item_avg_field(Item_result res_type, Item_sum_avg *item)
{
- name=item->name;
+ item_name= item->item_name;
decimals=item->decimals;
max_length= item->max_length;
unsigned_flag= item->unsigned_flag;
@@ -2669,7 +2669,7 @@ my_decimal *Item_std_field::val_decimal(
Item_variance_field::Item_variance_field(Item_sum_variance *item)
{
- name=item->name;
+ item_name= item->item_name;
decimals=item->decimals;
max_length=item->max_length;
unsigned_flag= item->unsigned_flag;
@@ -3225,10 +3225,10 @@ Field *Item_func_group_concat::make_stri
const uint32 max_characters= max_length / collation.collation->mbminlen;
if (max_characters > CONVERT_IF_BIGGER_TO_BLOB)
field= new Field_blob(max_characters * collation.collation->mbmaxlen,
- maybe_null, name, collation.collation, TRUE);
+ maybe_null, item_name.ptr(), collation.collation, TRUE);
else
field= new Field_varstring(max_characters * collation.collation->mbmaxlen,
- maybe_null, name, table->s, collation.collation);
+ maybe_null, item_name.ptr(), table->s, collation.collation);
if (field)
field->init(table);
=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h 2012-03-06 14:29:42 +0000
+++ b/sql/item_timefunc.h 2012-03-30 15:38:01 +0000
@@ -899,8 +899,8 @@ public:
void cleanup()
{
// See Item_basic_const::cleanup()
- if (orig_name)
- name= orig_name;
+ if (orig_name.ptr())
+ item_name= orig_name;
}
bool eq(const Item *item, bool binary_cmp) const;
};
@@ -956,8 +956,8 @@ public:
void cleanup()
{
// See Item_basic_const::cleanup()
- if (orig_name)
- name= orig_name;
+ if (orig_name.ptr())
+ item_name= orig_name;
}
bool eq(const Item *item, bool binary_cmp) const;
};
@@ -1013,8 +1013,8 @@ public:
void cleanup()
{
// See Item_basic_const::cleanup()
- if (orig_name)
- name= orig_name;
+ if (orig_name.ptr())
+ item_name= orig_name;
}
bool eq(const Item *item, bool binary_cmp) const;
};
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc 2012-03-28 15:24:17 +0000
+++ b/sql/log_event.cc 2012-03-30 15:38:01 +0000
@@ -5805,9 +5805,9 @@ Load_log_event::Load_log_event(THD *thd_
while ((item = li++))
{
num_fields++;
- uchar len = (uchar) strlen(item->name);
+ uchar len= (uchar) item->item_name.length();
field_block_len += len + 1;
- fields_buf.append(item->name, len + 1);
+ fields_buf.append(item->item_name.ptr(), len + 1);
field_lens_buf.append((char*)&len, 1);
}
=== modified file 'sql/partition_info.cc'
--- a/sql/partition_info.cc 2012-03-06 14:29:42 +0000
+++ b/sql/partition_info.cc 2012-03-30 15:38:01 +0000
@@ -1822,7 +1822,7 @@ void partition_info::report_part_expr_er
!(type == HASH_PARTITION && list_of_fields))
{
my_error(ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD, MYF(0),
- item_field->name);
+ item_field->item_name.ptr());
DBUG_VOID_RETURN;
}
}
=== modified file 'sql/procedure.cc'
--- a/sql/procedure.cc 2011-09-07 10:08:09 +0000
+++ b/sql/procedure.cc 2012-03-30 15:38:01 +0000
@@ -84,14 +84,14 @@ setup_procedure(THD *thd,ORDER *param,se
for (i=0 ; i < array_elements(sql_procs) ; i++)
{
if (!my_strcasecmp(system_charset_info,
- (*param->item)->name,sql_procs[i].name))
+ (*param->item)->item_name.ptr(), sql_procs[i].name))
{
Procedure *proc=(*sql_procs[i].init)(thd,param,result,field_list);
*error= !proc;
DBUG_RETURN(proc);
}
}
- my_error(ER_UNKNOWN_PROCEDURE, MYF(0), (*param->item)->name);
+ my_error(ER_UNKNOWN_PROCEDURE, MYF(0), (*param->item)->item_name.ptr());
*error=1;
DBUG_RETURN(0);
}
=== modified file 'sql/procedure.h'
--- a/sql/procedure.h 2011-12-09 21:08:37 +0000
+++ b/sql/procedure.h 2012-03-30 15:38:01 +0000
@@ -37,7 +37,7 @@ class Item_proc :public Item
public:
Item_proc(const char *name_par): Item()
{
- this->name=(char*) name_par;
+ this->item_name.set(name_par);
}
enum Type type() const { return Item::PROC_ITEM; }
virtual void set(double nr)=0;
=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc 2012-03-28 18:50:54 +0000
+++ b/sql/sql_acl.cc 2012-03-30 15:38:01 +0000
@@ -5294,10 +5294,10 @@ bool mysql_show_grants(THD *thd,LEX_USER
Item_string *field=new Item_string("",0,&my_charset_latin1);
List<Item> field_list;
- field->name=buff;
field->max_length=1024;
strxmov(buff,"Grants for ",lex_user->user.str,"@",
lex_user->host.str,NullS);
+ field->item_name.set(buff);
field_list.push_back(field);
if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
=== modified file 'sql/sql_analyse.cc'
--- a/sql/sql_analyse.cc 2011-12-09 21:08:37 +0000
+++ b/sql/sql_analyse.cc 2012-03-30 15:38:01 +0000
@@ -70,7 +70,7 @@ Procedure *
proc_analyse_init(THD *thd, ORDER *param, select_result *result,
List<Item> &field_list)
{
- char *proc_name = (*param->item)->name;
+ char *proc_name = (*param->item)->item_name.ptr();
analyse *pc = new analyse(result);
field_info **f_info;
DBUG_ENTER("proc_analyse_init");
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2012-03-30 13:35:00 +0000
+++ b/sql/sql_base.cc 2012-03-30 15:38:01 +0000
@@ -6484,13 +6484,10 @@ find_field_in_view(THD *thd, TABLE_LIST
the replacing item.
We need to set alias on both ref itself and on ref real item.
*/
- if (*ref && !(*ref)->is_autogenerated_name)
+ if (*ref && !(*ref)->item_name.is_autogenerated())
{
- item->is_autogenerated_name= false;
- item->set_name((*ref)->name, (*ref)->name_length,
- system_charset_info);
- item->real_item()->set_name((*ref)->name, (*ref)->name_length,
- system_charset_info);
+ item->item_name= (*ref)->item_name;
+ item->real_item()->item_name= (*ref)->item_name;
}
if (register_tree_change)
thd->change_item_tree(ref, item);
@@ -6584,13 +6581,10 @@ find_field_in_natural_join(THD *thd, TAB
the replacing item.
We need to set alias on both ref itself and on ref real item.
*/
- if (*ref && !(*ref)->is_autogenerated_name)
+ if (*ref && !(*ref)->item_name.is_autogenerated())
{
- item->is_autogenerated_name= false;
- item->set_name((*ref)->name, (*ref)->name_length,
- system_charset_info);
- item->real_item()->set_name((*ref)->name, (*ref)->name_length,
- system_charset_info);
+ item->item_name= (*ref)->item_name;
+ item->real_item()->item_name= (*ref)->item_name;
}
if (register_tree_change && arena)
thd->restore_active_arena(arena, &backup);
@@ -6627,7 +6621,7 @@ find_field_in_natural_join(THD *thd, TAB
nj_col->table_field->fix_fields(thd, (Item **)&nj_col->table_field))
{
DBUG_PRINT("info", ("column '%s' was dropped by the concurrent connection",
- nj_col->table_field->name));
+ nj_col->table_field->item_name.ptr()));
DBUG_RETURN(NULL);
}
DBUG_ASSERT(nj_col->table_ref->table == nj_col->table_field->field->table);
@@ -7041,7 +7035,8 @@ find_field_in_tables(THD *thd, Item_iden
#endif
}
else
- found= find_field_in_table_ref(thd, table_ref, name, length, item->name,
+ found= find_field_in_table_ref(thd, table_ref, name, length,
+ item->item_name.ptr(),
NULL, NULL, ref, check_privileges,
TRUE, &(item->cached_field_index),
register_tree_change,
@@ -7090,7 +7085,7 @@ find_field_in_tables(THD *thd, Item_iden
cur_table= cur_table->next_name_resolution_table)
{
Field *cur_field= find_field_in_table_ref(thd, cur_table, name, length,
- item->name, db, table_name, ref,
+ item->item_name.ptr(), db, table_name, ref,
(thd->lex->sql_command ==
SQLCOM_SHOW_FIELDS)
? false : check_privileges,
@@ -7107,7 +7102,7 @@ find_field_in_tables(THD *thd, Item_iden
thd->clear_error();
cur_field= find_field_in_table_ref(thd, cur_table, name, length,
- item->name, db, table_name, ref,
+ item->item_name.ptr(), db, table_name, ref,
false,
allow_rowid,
&(item->cached_field_index),
@@ -7262,7 +7257,7 @@ find_item_in_list(Item *find, List<Item>
(if this field created from expression argument of group_concat()),
=> we have to check presence of name before compare
*/
- if (!item_field->name)
+ if (!item_field->item_name.ptr())
continue;
if (table_name)
@@ -7317,8 +7312,7 @@ find_item_in_list(Item *find, List<Item>
int fname_cmp= my_strcasecmp(system_charset_info,
item_field->field_name,
field_name);
- if (!my_strcasecmp(system_charset_info,
- item_field->name,field_name))
+ if (item_field->item_name.eq(field_name))
{
/*
If table name was not given we should scan through aliases
@@ -7362,8 +7356,7 @@ find_item_in_list(Item *find, List<Item>
}
else if (!table_name)
{
- if (is_ref_by_name && find->name && item->name &&
- !my_strcasecmp(system_charset_info,item->name,find->name))
+ if (is_ref_by_name && item->item_name.eq(&find->item_name))
{
found= li.ref();
*counter= i;
@@ -7394,8 +7387,8 @@ find_item_in_list(Item *find, List<Item>
Item_field for tables.
*/
Item_ident *item_ref= (Item_ident *) item;
- if (item_ref->name && item_ref->table_name &&
- !my_strcasecmp(system_charset_info, item_ref->name, field_name) &&
+ if (item_ref->item_name.eq(field_name) &&
+ item_ref->table_name &&
!my_strcasecmp(table_alias_charset, item_ref->table_name,
table_name) &&
(!db_name || (item_ref->db_name &&
@@ -8942,7 +8935,7 @@ fill_record(THD * thd, List<Item> &field
fld= (Item_field*)f++;
if (!(field= fld->filed_for_view_update()))
{
- my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->item_name.ptr());
goto err;
}
table= field->field->table;
@@ -8953,7 +8946,7 @@ fill_record(THD * thd, List<Item> &field
{
if (!(field= fld->filed_for_view_update()))
{
- my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name);
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->item_name.ptr());
goto err;
}
value=v++;
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2012-03-21 14:27:34 +0000
+++ b/sql/sql_class.cc 2012-03-30 15:38:01 +0000
@@ -2621,7 +2621,7 @@ bool select_export::send_data(List<Item>
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
"string", printable_buff,
- item->name, static_cast<long>(row_count));
+ item->item_name.ptr(), static_cast<long>(row_count));
}
else if (from_end_pos < res->ptr() + res->length())
{
=== modified file 'sql/sql_executor.cc'
--- a/sql/sql_executor.cc 2012-03-26 10:29:07 +0000
+++ b/sql/sql_executor.cc 2012-03-30 15:38:01 +0000
@@ -4630,7 +4630,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PA
Item_ref *ref= (Item_ref *) pos;
item->db_name= ref->db_name;
item->table_name= ref->table_name;
- item->name= ref->name;
+ item->item_name= ref->item_name;
}
pos= item;
if (item->field->flags & BLOB_FLAG)
@@ -4830,7 +4830,7 @@ change_to_use_tmp_fields(THD *thd, Ref_p
if (item->real_item()->type() != Item::FIELD_ITEM)
field->orig_table= 0;
- item_field->name= item->name;
+ item_field->item_name= item->item_name;
if (item->type() == Item::REF_ITEM)
{
Item_field *ifield= (Item_field *) item_field;
@@ -4839,13 +4839,13 @@ change_to_use_tmp_fields(THD *thd, Ref_p
ifield->db_name= iref->db_name;
}
#ifndef DBUG_OFF
- if (!item_field->name)
+ if (!item_field->item_name.ptr())
{
char buff[256];
String str(buff,sizeof(buff),&my_charset_bin);
str.length(0);
item->print(&str, QT_ORDINARY);
- item_field->name= sql_strmake(str.ptr(),str.length());
+ item_field->item_name.copy(str.ptr(), str.length());
}
#endif
}
=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc 2012-03-30 13:35:00 +0000
+++ b/sql/sql_lex.cc 2012-03-30 15:38:01 +0000
@@ -2604,7 +2604,7 @@ void st_select_lex::print(THD *thd, Stri
else
str->append(',');
- if (master_unit()->item && item->is_autogenerated_name)
+ if (master_unit()->item && item->item_name.is_autogenerated())
{
/*
Do not print auto-generated aliases in subqueries. It has no purpose
=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc 2012-03-19 17:59:14 +0000
+++ b/sql/sql_load.cc 2012-03-30 15:38:01 +0000
@@ -730,7 +730,7 @@ static bool write_execute_load_query_log
if (item->type() == Item::FIELD_ITEM)
{
pfields.append("`");
- pfields.append(item->name);
+ pfields.append(item->item_name.ptr());
pfields.append("`");
}
else
@@ -753,9 +753,9 @@ static bool write_execute_load_query_log
if (n++)
pfields.append(", ");
pfields.append("`");
- pfields.append(item->name);
+ pfields.append(item->item_name.ptr());
pfields.append("`");
- pfields.append(val->name);
+ pfields.append(val->item_name.ptr());
}
}
@@ -1183,7 +1183,7 @@ read_xml_field(THD *thd, COPY_INFO &info
xmlit.rewind();
tag= xmlit++;
- while(tag && strcmp(tag->field.c_ptr(), item->name) != 0)
+ while(tag && strcmp(tag->field.c_ptr(), item->item_name.ptr()) != 0)
tag= xmlit++;
if (!tag) // found null
=== modified file 'sql/sql_optimizer.cc'
--- a/sql/sql_optimizer.cc 2012-03-28 13:39:57 +0000
+++ b/sql/sql_optimizer.cc 2012-03-30 15:38:01 +0000
@@ -781,7 +781,7 @@ JOIN::optimize()
{
Item *where= conds;
if (join_tab[0].type == JT_EQ_REF &&
- join_tab[0].ref.items[0]->name == in_left_expr_name)
+ join_tab[0].ref.items[0]->item_name.ptr() == in_left_expr_name)
{
remove_subq_pushed_predicates(&where);
save_index_subquery_explain_info(join_tab, where);
@@ -794,7 +794,7 @@ JOIN::optimize()
true /* unique */);
}
else if (join_tab[0].type == JT_REF &&
- join_tab[0].ref.items[0]->name == in_left_expr_name)
+ join_tab[0].ref.items[0]->item_name.ptr() == in_left_expr_name)
{
remove_subq_pushed_predicates(&where);
save_index_subquery_explain_info(join_tab, where);
@@ -805,8 +805,8 @@ JOIN::optimize()
where, NULL, false, false);
}
} else if (join_tab[0].type == JT_REF_OR_NULL &&
- join_tab[0].ref.items[0]->name == in_left_expr_name &&
- having->name == in_having_cond)
+ join_tab[0].ref.items[0]->item_name.ptr() == in_left_expr_name &&
+ having->item_name.ptr() == in_having_cond)
{
join_tab[0].type= JT_INDEX_SUBQUERY;
error= 0;
@@ -8691,7 +8691,7 @@ static bool add_ref_to_table_cond(THD *t
static Item *remove_additional_cond(Item* conds)
{
- if (conds->name == in_additional_cond)
+ if (conds->item_name.ptr() == in_additional_cond)
return 0;
if (conds->type() == Item::COND_ITEM)
{
@@ -8700,7 +8700,7 @@ static Item *remove_additional_cond(Item
Item *item;
while ((item= li++))
{
- if (item->name == in_additional_cond)
+ if (item->item_name.ptr() == in_additional_cond)
{
li.remove();
if (cnd->argument_list()->elements == 1)
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2012-03-14 09:52:49 +0000
+++ b/sql/sql_parse.cc 2012-03-30 15:38:01 +0000
@@ -5831,7 +5831,7 @@ void create_select_for_variable(const ch
if ((var= get_system_var(thd, OPT_SESSION, tmp, null_lex_string)))
{
end= strxmov(buff, "@@session.", var_name, NullS);
- var->set_name(buff, end-buff, system_charset_info);
+ var->item_name.copy(buff, end - buff);
add_item_to_list(thd, var);
}
DBUG_VOID_RETURN;
=== modified file 'sql/sql_profile.cc'
--- a/sql/sql_profile.cc 2012-03-06 14:29:42 +0000
+++ b/sql/sql_profile.cc 2012-03-30 15:38:01 +0000
@@ -124,9 +124,7 @@ int make_profile_table_for_show(THD *thd
NullS, NullS, field_info->field_name);
if (field)
{
- field->set_name(field_info->old_name,
- (uint) strlen(field_info->old_name),
- system_charset_info);
+ field->item_name.copy(field_info->old_name);
if (add_item_to_list(thd, field))
return 1;
}
=== modified file 'sql/sql_resolver.cc'
--- a/sql/sql_resolver.cc 2012-02-29 11:17:52 +0000
+++ b/sql/sql_resolver.cc 2012-03-30 15:38:01 +0000
@@ -1506,7 +1506,7 @@ static bool change_group_ref(THD *thd, I
{
Item *new_item;
if (!(new_item= new Item_ref(context, group_tmp->item, 0,
- item->name)))
+ item->item_name.ptr())))
return 1; // fatal_error is set
thd->change_item_tree(arg, new_item);
arg_changed= TRUE;
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc 2012-03-27 11:50:38 +0000
+++ b/sql/sql_show.cc 2012-03-30 15:38:01 +0000
@@ -6713,8 +6713,7 @@ TABLE *create_schema_table(THD *thd, TAB
item->max_length+= 1;
if (item->decimals > 0)
item->max_length+= 1;
- item->set_name(fields_info->field_name,
- strlen(fields_info->field_name), cs);
+ item->item_name.copy(fields_info->field_name);
break;
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
@@ -6734,8 +6733,7 @@ TABLE *create_schema_table(THD *thd, TAB
{
DBUG_RETURN(0);
}
- item->set_name(fields_info->field_name,
- strlen(fields_info->field_name), cs);
+ item->item_name.copy(fields_info->field_name);
break;
}
field_list.push_back(item);
@@ -6793,9 +6791,7 @@ int make_old_format(THD *thd, ST_SCHEMA_
NullS, NullS, field_info->field_name);
if (field)
{
- field->set_name(field_info->old_name,
- strlen(field_info->old_name),
- system_charset_info);
+ field->item_name.copy(field_info->old_name);
if (add_item_to_list(thd, field))
return 1;
}
@@ -6828,7 +6824,7 @@ int make_schemata_old_format(THD *thd, S
buffer.append(lex->wild->ptr());
buffer.append(')');
}
- field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
+ field->item_name.copy(buffer.ptr(), buffer.length(), system_charset_info);
}
return 0;
}
@@ -6855,16 +6851,15 @@ int make_table_names_old_format(THD *thd
NullS, NullS, field_info->field_name);
if (add_item_to_list(thd, field))
return 1;
- field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
+ field->item_name.copy(buffer.ptr(), buffer.length(), system_charset_info);
if (thd->lex->verbose)
{
- field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
+ field->item_name.copy(buffer.ptr(), buffer.length(), system_charset_info);
field_info= &schema_table->fields_info[3];
field= new Item_field(context, NullS, NullS, field_info->field_name);
if (add_item_to_list(thd, field))
return 1;
- field->set_name(field_info->old_name, strlen(field_info->old_name),
- system_charset_info);
+ field->item_name.copy(field_info->old_name);
}
return 0;
}
@@ -6897,9 +6892,7 @@ int make_columns_old_format(THD *thd, ST
NullS, NullS, field_info->field_name);
if (field)
{
- field->set_name(field_info->old_name,
- strlen(field_info->old_name),
- system_charset_info);
+ field->item_name.copy(field_info->old_name);
if (add_item_to_list(thd, field))
return 1;
}
@@ -6922,9 +6915,7 @@ int make_character_sets_old_format(THD *
NullS, NullS, field_info->field_name);
if (field)
{
- field->set_name(field_info->old_name,
- strlen(field_info->old_name),
- system_charset_info);
+ field->item_name.copy(field_info->old_name);
if (add_item_to_list(thd, field))
return 1;
}
@@ -6958,9 +6949,7 @@ int make_proc_old_format(THD *thd, ST_SC
NullS, NullS, field_info->field_name);
if (field)
{
- field->set_name(field_info->old_name,
- strlen(field_info->old_name),
- system_charset_info);
+ field->item_name.copy(field_info->old_name);
if (add_item_to_list(thd, field))
return 1;
}
@@ -7038,7 +7027,7 @@ int mysql_schema_table(THD *thd, LEX *le
for (org_transl= transl; (item= it++); transl++)
{
transl->item= item;
- transl->name= item->name;
+ transl->name= item->item_name.ptr();
if (!item->fixed && item->fix_fields(thd, &transl->item))
{
DBUG_RETURN(1);
=== modified file 'sql/sql_tmp_table.cc'
--- a/sql/sql_tmp_table.cc 2012-02-27 11:36:40 +0000
+++ b/sql/sql_tmp_table.cc 2012-03-30 10:23:18 +0000
@@ -126,7 +126,7 @@ static Field *create_tmp_field_from_item
switch (item->result_type()) {
case REAL_RESULT:
new_field= new Field_double(item->max_length, maybe_null,
- item->name, item->decimals, TRUE);
+ item->item_name.ptr(), item->decimals, TRUE);
break;
case INT_RESULT:
/*
@@ -137,10 +137,10 @@ static Field *create_tmp_field_from_item
*/
if (item->max_length >= (MY_INT32_NUM_DECIMAL_DIGITS - 1))
new_field=new Field_longlong(item->max_length, maybe_null,
- item->name, item->unsigned_flag);
+ item->item_name.ptr(), item->unsigned_flag);
else
new_field=new Field_long(item->max_length, maybe_null,
- item->name, item->unsigned_flag);
+ item->item_name.ptr(), item->unsigned_flag);
break;
case STRING_RESULT:
DBUG_ASSERT(item->collation.collation);
@@ -159,7 +159,7 @@ static Field *create_tmp_field_from_item
convert_blob_length <= Field_varstring::MAX_SIZE &&
convert_blob_length)
new_field= new Field_varstring(convert_blob_length, maybe_null,
- item->name, table->s,
+ item->item_name.ptr(), table->s,
item->collation.collation);
else
new_field= item->make_string_field(table);
@@ -208,11 +208,11 @@ static Field *create_tmp_field_for_schem
Field *field;
if (item->max_length > MAX_FIELD_VARCHARLENGTH)
field= new Field_blob(item->max_length, item->maybe_null,
- item->name, item->collation.collation);
+ item->item_name.ptr(), item->collation.collation);
else
{
field= new Field_varstring(item->max_length, item->maybe_null,
- item->name,
+ item->item_name.ptr(),
table->s, item->collation.collation);
table->s->db_create_options|= HA_OPTION_PACK_RECORD;
}
@@ -312,8 +312,8 @@ Field *create_tmp_field(THD *thd, TABLE
}
else
result= create_tmp_field_from_field(thd, (*from_field= field->field),
- orig_item ? orig_item->name :
- item->name,
+ orig_item ? orig_item->item_name.ptr() :
+ item->item_name.ptr(),
table,
modify_item ? field :
NULL,
@@ -349,7 +349,7 @@ Field *create_tmp_field(THD *thd, TABLE
Field *result_field=
create_tmp_field_from_field(thd,
sp_result_field,
- item_func_sp->name,
+ item_func_sp->item_name.ptr(),
table,
NULL,
convert_blob_length);
=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc 2012-03-19 17:59:14 +0000
+++ b/sql/sql_update.cc 2012-03-30 15:38:01 +0000
@@ -149,7 +149,7 @@ static bool check_fields(THD *thd, List<
if (!(field= item->filed_for_view_update()))
{
/* item has name, because it comes from VIEW SELECT list */
- my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name);
+ my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->item_name.ptr());
return TRUE;
}
/*
=== modified file 'sql/sql_view.cc'
--- a/sql/sql_view.cc 2012-03-23 13:36:47 +0000
+++ b/sql/sql_view.cc 2012-03-30 15:38:01 +0000
@@ -61,9 +61,9 @@ static void make_unique_view_field_name(
List<Item> &item_list,
Item *last_element)
{
- char *name= (target->orig_name ?
- target->orig_name :
- target->name);
+ char *name= (target->orig_name.ptr() ?
+ target->orig_name.ptr() :
+ target->item_name.ptr());
size_t name_len;
uint attempt;
char buff[NAME_LEN+1];
@@ -82,8 +82,7 @@ static void make_unique_view_field_name(
do
{
check= itc++;
- if (check != target &&
- my_strcasecmp(system_charset_info, buff, check->name) == 0)
+ if (check != target && check->item_name.eq(buff))
{
ok= FALSE;
break;
@@ -94,8 +93,8 @@ static void make_unique_view_field_name(
itc.rewind();
}
- target->orig_name= target->name;
- target->set_name(buff, name_len, system_charset_info);
+ target->orig_name= target->item_name;
+ target->item_name.copy(buff, name_len);
}
@@ -134,17 +133,17 @@ bool check_duplicate_names(List<Item> &i
Item *check;
/* treat underlying fields like set by user names */
if (item->real_item()->type() == Item::FIELD_ITEM)
- item->is_autogenerated_name= FALSE;
+ item->item_name.set_autogenerated(false);
itc.rewind();
while ((check= itc++) && check != item)
{
- if (my_strcasecmp(system_charset_info, item->name, check->name) == 0)
+ if (item->item_name.eq(&check->item_name))
{
if (!gen_unique_view_name)
goto err;
- if (item->is_autogenerated_name)
+ if (item->item_name.is_autogenerated())
make_unique_view_field_name(item, item_list, item);
- else if (check->is_autogenerated_name)
+ else if (check->item_name.is_autogenerated())
make_unique_view_field_name(check, item_list, item);
else
goto err;
@@ -154,7 +153,7 @@ bool check_duplicate_names(List<Item> &i
DBUG_RETURN(FALSE);
err:
- my_error(ER_DUP_FIELDNAME, MYF(0), item->name);
+ my_error(ER_DUP_FIELDNAME, MYF(0), item->item_name.ptr());
DBUG_RETURN(TRUE);
}
@@ -176,11 +175,12 @@ static void make_valid_column_names(List
for (uint column_no= 1; (item= it++); column_no++)
{
- if (!item->is_autogenerated_name || !check_column_name(item->name))
+ if (!item->item_name.is_autogenerated() ||
+ !check_column_name(item->item_name.ptr()))
continue;
name_len= my_snprintf(buff, NAME_LEN, "Name_exp_%u", column_no);
- item->orig_name= item->name;
- item->set_name(buff, name_len, system_charset_info);
+ item->orig_name= item->item_name;
+ item->item_name.copy(buff, name_len);
}
DBUG_VOID_RETURN;
@@ -600,8 +600,8 @@ bool mysql_create_view(THD *thd, TABLE_L
}
while ((item= it++, name= nm++))
{
- item->set_name(name->str, (uint) name->length, system_charset_info);
- item->is_autogenerated_name= FALSE;
+ item->item_name.copy(name->str, (uint) name->length,
+ system_charset_info, false);
}
}
@@ -657,7 +657,7 @@ bool mysql_create_view(THD *thd, TABLE_L
{
Item_field *fld= item->filed_for_view_update();
uint priv= (get_column_grant(thd, &view->grant, view->db,
- view->table_name, item->name) &
+ view->table_name, item->item_name.ptr()) &
VIEW_ANY_ACL);
if (fld && !fld->field->table->s->tmp_table)
@@ -675,7 +675,7 @@ bool mysql_create_view(THD *thd, TABLE_L
{
my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
"create view", thd->security_ctx->priv_user,
- thd->security_ctx->priv_host, report_item->name,
+ thd->security_ctx->priv_host, report_item->item_name.ptr(),
view->table_name);
res= TRUE;
goto err;
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2012-03-27 08:43:25 +0000
+++ b/sql/sql_yacc.yy 2012-03-30 15:38:01 +0000
@@ -8262,12 +8262,11 @@ select_item:
my_error(ER_WRONG_COLUMN_NAME, MYF(0), $4.str);
MYSQL_YYABORT;
}
- $2->is_autogenerated_name= FALSE;
- $2->set_name($4.str, $4.length, system_charset_info);
+ $2->item_name.copy($4.str, $4.length, system_charset_info, false);
}
- else if (!$2->name)
+ else if (!$2->item_name.ptr())
{
- $2->set_name($1, (uint) ($3 - $1), thd->charset());
+ $2->item_name.copy($1, (uint) ($3 - $1), thd->charset());
}
}
;
@@ -9669,8 +9668,7 @@ udf_expr:
*/
if ($4.str)
{
- $2->is_autogenerated_name= FALSE;
- $2->set_name($4.str, $4.length, system_charset_info);
+ $2->item_name.copy($4.str, $4.length, system_charset_info, false);
}
/*
A field has to have its proper name in order for name
@@ -9679,7 +9677,7 @@ udf_expr:
remember_name we may get quoted or escaped names.
*/
else if ($2->type() != Item::FIELD_ITEM)
- $2->set_name($1, (uint) ($3 - $1), YYTHD->charset());
+ $2->item_name.copy($1, (uint) ($3 - $1), YYTHD->charset());
$$= $2;
}
;
@@ -10985,8 +10983,8 @@ procedure_item:
if (add_proc_to_list(thd, $2))
MYSQL_YYABORT;
- if (!$2->name)
- $2->set_name($1, (uint) ($3 - $1), thd->charset());
+ if (!$2->item_name.ptr())
+ $2->item_name.copy($1, (uint) ($3 - $1), thd->charset());
}
;
@@ -12584,7 +12582,7 @@ load_data_set_elem:
if (lex->update_list.push_back($1) ||
lex->value_list.push_back($4))
MYSQL_YYABORT;
- $4->set_name($3, (uint) ($5 - $3), YYTHD->charset());
+ $4->item_name.copy($3, (uint) ($5 - $3), YYTHD->charset());
}
;
=== modified file 'sql/table.cc'
--- a/sql/table.cc 2012-03-27 12:58:14 +0000
+++ b/sql/table.cc 2012-03-30 15:38:01 +0000
@@ -3626,7 +3626,7 @@ bool TABLE_LIST::setup_underlying(THD *t
while ((item= it++))
{
- transl[field_count].name= item->name;
+ transl[field_count].name= item->item_name.ptr();
transl[field_count++].item= item;
}
field_translation= transl;
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (alexander.barkov:3825 to 3826) Bug#12537203 | Alexander Barkov | 31 Mar |