maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #09076
Please review MDEV-8092 Change Create_field::field from "const char *" to LEX_CSTRING
Hi Serg,
Please review a patch for MDEV-8092.
Thanks.
Perhaps something interesting, about #3 in the task description.
I added a debug output and collected some statistics
for "mtr --suite=main", to check how these changes can
potentially affect another task:
MDEV-7954 my_strcasecmp_utf8() takes 0.19% in OLTP RO
Here are the results:
my_strcasecmp_utf8() is now called 18,709,905 times total during
"mtr --suite=main"
9,200,498 of those are called to compare Field/Create_field names in
Column_name::eq_name().
And 3,855,751 calls of my_strcasecmp_utf8() are now optimized away,
because eq_name() immediately return "false" if the two name lengths
are different.
So before this change there were 18,709,905 + 3,855,751 = 22,565,656
calls of my_strcasecmp_utf8().
Looks roughly like 17% improvement in name comparison.
diff --git a/plugin/feedback/feedback.cc b/plugin/feedback/feedback.cc
index dcfa9e0..5e69778 100644
--- a/plugin/feedback/feedback.cc
+++ b/plugin/feedback/feedback.cc
@@ -94,7 +94,7 @@ static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter)
Item_cond_or *res= NULL;
Name_resolution_context nrc;
const char *db= tables->db, *table= tables->alias,
- *field= tables->table->field[0]->field_name;
+ *field= tables->table->field[0]->name().ptr();
CHARSET_INFO *cs= &my_charset_latin1;
if (!filter->str)
diff --git a/plugin/handler_socket/handlersocket/database.cpp b/plugin/handler_socket/handlersocket/database.cpp
index 8ea7b50..88c7877 100644
--- a/plugin/handler_socket/handlersocket/database.cpp
+++ b/plugin/handler_socket/handlersocket/database.cpp
@@ -1088,8 +1088,8 @@ dbcontext::parse_fields(TABLE *const table, const char *str,
Field **fld = 0;
size_t j = 0;
for (fld = table->field; *fld; ++fld, ++j) {
- DBG_FLD(fprintf(stderr, "f %s\n", (*fld)->field_name));
- string_ref fn((*fld)->field_name, strlen((*fld)->field_name));
+ DBG_FLD(fprintf(stderr, "f %s\n", (*fld)->name().ptr()));
+ string_ref fn((*fld)->name().ptr(), (*fld)->name().length());
if (fn == fldnms[i]) {
break;
}
@@ -1099,7 +1099,7 @@ dbcontext::parse_fields(TABLE *const table, const char *str,
std::string(fldnms[i].begin(), fldnms[i].size()).c_str()));
return false;
}
- DBG_FLD(fprintf(stderr, "FLD %s %zu\n", (*fld)->field_name, j));
+ DBG_FLD(fprintf(stderr, "FLD %s %zu\n", (*fld)->name().ptr(), j));
flds.push_back(j);
}
return true;
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index e39f727..60019cd 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -379,14 +379,14 @@ mysql_event_fill_row(THD *thd,
if (rs)
{
- my_error(ER_EVENT_STORE_FAILED, MYF(0), fields[f_num]->field_name, rs);
+ my_error(ER_EVENT_STORE_FAILED, MYF(0), fields[f_num]->name().ptr(), rs);
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
err_truncate:
- my_error(ER_EVENT_DATA_TOO_LONG, MYF(0), fields[f_num]->field_name);
+ my_error(ER_EVENT_DATA_TOO_LONG, MYF(0), fields[f_num]->name().ptr());
DBUG_RETURN(TRUE);
}
@@ -1223,7 +1223,7 @@ Event_db_repository::check_system_tables(THD *thd)
else
{
if (tables.table->s->fields < event_priv_column_position ||
- strncmp(tables.table->field[event_priv_column_position]->field_name,
+ strncmp(tables.table->field[event_priv_column_position]->name().ptr(),
STRING_WITH_LEN("Event_priv")))
{
sql_print_error("mysql.user has no `Event_priv` column at position %d",
diff --git a/sql/field.cc b/sql/field.cc
index 29c9625..9527eb0 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -1327,7 +1327,7 @@ bool Field::can_optimize_range(const Item_bool_func *cond,
*/
Field_num::Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg,
+ const Column_name& field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg),
@@ -1641,9 +1641,11 @@ String *Field::val_int_as_str(String *val_buffer, bool unsigned_val)
/// This is used as a table name when the table structure is not set up
Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
uchar null_bit_arg,
- utype unireg_check_arg, const char *field_name_arg)
- :ptr(ptr_arg), null_ptr(null_ptr_arg), table(0), orig_table(0),
- table_name(0), field_name(field_name_arg), option_list(0),
+ utype unireg_check_arg, const Column_name &field_name_arg)
+ :Column_name(field_name_arg),
+ ptr(ptr_arg), null_ptr(null_ptr_arg), table(0), orig_table(0),
+ table_name(0),
+ option_list(0),
option_struct(0), key_start(0), part_of_key(0),
part_of_key_not_clustered(0), part_of_sortkey(0),
unireg_check(unireg_check_arg), field_length(length_arg),
@@ -1896,14 +1898,14 @@ void Field::make_field(Send_field *field)
if (orig_table && orig_table->alias.ptr())
{
field->table_name= orig_table->alias.ptr();
- field->org_col_name= field_name;
+ field->org_col_name= name().ptr();
}
else
{
field->table_name= "";
field->org_col_name= "";
}
- field->col_name= field_name;
+ field->col_name= name().ptr();
field->charsetnr= charset()->number;
field->length=field_length;
field->type=type();
@@ -2009,13 +2011,13 @@ bool Field_num::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
longlong nr= val_int();
bool neg= !(flags & UNSIGNED_FLAG) && nr < 0;
return int_to_datetime_with_warn(neg, neg ? -nr : nr, ltime, fuzzydate,
- field_name);
+ name().ptr());
}
Field_str::Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg, CHARSET_INFO *charset_arg)
+ const Column_name& field_name_arg, CHARSET_INFO *charset_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
{
@@ -2890,7 +2892,7 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg,
uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg,
+ const Column_name& field_name_arg,
uint8 dec_arg,bool zero_arg,
bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
@@ -2906,7 +2908,7 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg,
Field_new_decimal::Field_new_decimal(uint32 len_arg,
bool maybe_null_arg,
- const char *name,
+ const Column_name &name,
uint8 dec_arg,
bool unsigned_arg)
:Field_num((uchar*) 0, len_arg,
@@ -3242,7 +3244,7 @@ bool Field_new_decimal::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
my_decimal value;
return decimal_to_datetime_with_warn(val_decimal(&value),
- ltime, fuzzydate, field_name);
+ ltime, fuzzydate, name().ptr());
}
@@ -3412,7 +3414,7 @@ Item *Field_new_decimal::get_equal_const_item(THD *thd, const Context &ctx,
Field_time::get_equal_const_item().
*/
my_decimal_round(E_DEC_FATAL_ERROR, val, decimals(), true, &val_buffer2);
- return new (thd->mem_root) Item_decimal(thd, field_name, &val_buffer2,
+ return new (thd->mem_root) Item_decimal(thd, name().ptr(), &val_buffer2,
decimals(), field_length);
}
break;
@@ -4720,7 +4722,7 @@ bool Field_real::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
{
ASSERT_COLUMN_MARKED_FOR_READ;
double nr= val_real();
- return double_to_datetime_with_warn(nr, ltime, fuzzydate, field_name);
+ return double_to_datetime_with_warn(nr, ltime, fuzzydate, name().ptr());
}
@@ -4875,7 +4877,7 @@ void Field_double::sql_type(String &res) const
Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg,
+ const Column_name& field_name_arg,
TABLE_SHARE *share)
:Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
@@ -5821,7 +5823,7 @@ bool Field_time::check_zero_in_date_with_warn(ulonglong fuzzydate)
THD *thd= get_thd();
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE,
- ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE), field_name,
+ ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE), name().ptr(),
thd->get_stmt_da()->current_row_for_warning());
return true;
}
@@ -6199,7 +6201,7 @@ bool Field_year::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
if (tmp || field_length != 4)
tmp+= 1900;
return int_to_datetime_with_warn(false, tmp * 10000,
- ltime, fuzzydate, field_name);
+ ltime, fuzzydate, name().ptr());
}
@@ -7055,7 +7057,7 @@ check_field_for_37426(const void *param_arg)
Check_field_param *param= (Check_field_param*) param_arg;
DBUG_ASSERT(param->field->real_type() == MYSQL_TYPE_STRING);
DBUG_PRINT("debug", ("Field %s - type: %d, size: %d",
- param->field->field_name,
+ param->field->name().ptr(),
param->field->real_type(),
param->field->row_pack_length()));
return param->field->row_pack_length() > 255;
@@ -7138,7 +7140,7 @@ uchar *Field_string::pack(uchar *to, const uchar *from, uint max_length)
{
uint length= MY_MIN(field_length,max_length);
uint local_char_length= max_length/field_charset->mbmaxlen;
- DBUG_PRINT("debug", ("Packing field '%s' - length: %u ", field_name, length));
+ DBUG_PRINT("debug", ("Packing field '%s' - length: %u ", name().ptr(), length));
if (length > local_char_length)
local_char_length= my_charpos(field_charset, from, from+length,
@@ -7310,7 +7312,7 @@ Field *Field_string::make_new_field(MEM_ROOT *root, TABLE *new_table,
if (type() != MYSQL_TYPE_VAR_STRING || keep_type)
field= Field::make_new_field(root, new_table, keep_type);
else if ((field= new (root) Field_varstring(field_length, maybe_null(),
- field_name,
+ name(),
new_table->s, charset())))
{
/*
@@ -7782,7 +7784,7 @@ void Field_varstring::hash(ulong *nr, ulong *nr2)
****************************************************************************/
Field_blob::Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
TABLE_SHARE *share, uint blob_pack_length,
CHARSET_INFO *cs)
:Field_longstr(ptr_arg, BLOB_PACK_LENGTH_TO_MAX_LENGH(blob_pack_length),
@@ -8093,7 +8095,7 @@ Field *Field_blob::new_key_field(MEM_ROOT *root, TABLE *new_table,
{
Field_varstring *res= new (root) Field_varstring(new_ptr, length, 2,
new_null_ptr, new_null_bit, Field::NONE,
- field_name, table->s, charset());
+ name(), table->s, charset());
res->init(new_table);
return res;
}
@@ -8446,7 +8448,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
MYF(0),
Geometry::ci_collection[geom_type]->m_name.str,
Geometry::ci_collection[wkb_type]->m_name.str,
- field_name,
+ name().ptr(),
(ulong) table->in_use->get_stmt_da()->
current_row_for_warning());
goto err_exit;
@@ -9033,7 +9035,7 @@ bool Field_enum::can_optimize_keypart_ref(const Item_bool_func *cond,
Field_bit::Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
- enum utype unireg_check_arg, const char *field_name_arg)
+ enum utype unireg_check_arg, const Column_name& field_name_arg)
: Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg),
bit_ptr(bit_ptr_arg), bit_ofs(bit_ofs_arg), bit_len(len_arg & 7),
@@ -9548,7 +9550,7 @@ void Field_bit::set_default()
Field_bit_as_char::Field_bit_as_char(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg)
+ const Column_name& field_name_arg)
:Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, 0, 0,
unireg_check_arg, field_name_arg)
{
@@ -9662,7 +9664,7 @@ void Column_definition::init_for_tmp_table(enum_field_types sql_type_arg,
{
DBUG_ENTER("Create_field::init_for_tmp_table");
- field_name= "";
+ set_name(empty_lex_str);
sql_type= sql_type_arg;
char_length= length= length_arg;;
unireg_check= Field::NONE;
@@ -9787,21 +9789,21 @@ bool Column_definition::check(THD *thd)
*/
if (vcol_info->expr_item->walk(&Item::check_vcol_func_processor, 0, NULL))
{
- my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), field_name);
+ my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), name().ptr());
DBUG_RETURN(TRUE);
}
}
if (length > MAX_FIELD_BLOBLENGTH)
{
- my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name, MAX_FIELD_BLOBLENGTH);
+ my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), name().ptr(), MAX_FIELD_BLOBLENGTH);
DBUG_RETURN(1);
}
if (decimals >= NOT_FIXED_DEC)
{
my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals),
- field_name, static_cast<ulong>(NOT_FIXED_DEC - 1));
+ name().ptr(), static_cast<ulong>(NOT_FIXED_DEC - 1));
DBUG_RETURN(TRUE);
}
@@ -9819,7 +9821,7 @@ bool Column_definition::check(THD *thd)
(mysql_type_to_time_type(sql_type) != MYSQL_TIMESTAMP_DATETIME) ||
def->decimals < length))
{
- my_error(ER_INVALID_DEFAULT, MYF(0), field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), name().ptr());
DBUG_RETURN(1);
}
else if (def->type() == Item::NULL_ITEM)
@@ -9827,13 +9829,13 @@ bool Column_definition::check(THD *thd)
def= 0;
if ((flags & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG)
{
- my_error(ER_INVALID_DEFAULT, MYF(0), field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), name().ptr());
DBUG_RETURN(1);
}
}
else if (flags & AUTO_INCREMENT_FLAG)
{
- my_error(ER_INVALID_DEFAULT, MYF(0), field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), name().ptr());
DBUG_RETURN(1);
}
}
@@ -9861,7 +9863,7 @@ bool Column_definition::check(THD *thd)
(mysql_type_to_time_type(sql_type) != MYSQL_TIMESTAMP_DATETIME ||
on_update->decimals < length))
{
- my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name);
+ my_error(ER_INVALID_ON_UPDATE, MYF(0), name().ptr());
DBUG_RETURN(1);
}
@@ -9899,13 +9901,13 @@ bool Column_definition::check(THD *thd)
my_decimal_trim(&length, &decimals);
if (length > DECIMAL_MAX_PRECISION)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name,
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, name().ptr(),
DECIMAL_MAX_PRECISION);
DBUG_RETURN(TRUE);
}
if (length < decimals)
{
- my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name);
+ my_error(ER_M_BIGGER_THAN_D, MYF(0), name().ptr());
DBUG_RETURN(TRUE);
}
length=
@@ -9939,7 +9941,7 @@ bool Column_definition::check(THD *thd)
if (res->length() || thd->is_strict_mode())
{
my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0),
- field_name); /* purecov: inspected */
+ name().ptr()); /* purecov: inspected */
DBUG_RETURN(TRUE);
}
else
@@ -9950,7 +9952,7 @@ bool Column_definition::check(THD *thd)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_BLOB_CANT_HAVE_DEFAULT,
ER_THD(thd, ER_BLOB_CANT_HAVE_DEFAULT),
- field_name);
+ name().ptr());
}
def= 0;
}
@@ -9972,7 +9974,7 @@ bool Column_definition::check(THD *thd)
if (length < decimals &&
decimals != NOT_FIXED_DEC)
{
- my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name);
+ my_error(ER_M_BIGGER_THAN_D, MYF(0), name().ptr());
DBUG_RETURN(TRUE);
}
break;
@@ -9986,7 +9988,7 @@ bool Column_definition::check(THD *thd)
if (length < decimals &&
decimals != NOT_FIXED_DEC)
{
- my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name);
+ my_error(ER_M_BIGGER_THAN_D, MYF(0), name().ptr());
DBUG_RETURN(TRUE);
}
break;
@@ -9994,7 +9996,7 @@ bool Column_definition::check(THD *thd)
case MYSQL_TYPE_TIMESTAMP2:
if (length > MAX_DATETIME_PRECISION)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name,
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, name().ptr(),
MAX_DATETIME_PRECISION);
DBUG_RETURN(TRUE);
}
@@ -10012,7 +10014,7 @@ bool Column_definition::check(THD *thd)
case MYSQL_TYPE_TIME2:
if (length > MAX_DATETIME_PRECISION)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name,
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, name().ptr(),
MAX_DATETIME_PRECISION);
DBUG_RETURN(TRUE);
}
@@ -10022,7 +10024,7 @@ bool Column_definition::check(THD *thd)
case MYSQL_TYPE_DATETIME2:
if (length > MAX_DATETIME_PRECISION)
{
- my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name,
+ my_error(ER_TOO_BIG_PRECISION, MYF(0), length, name().ptr(),
MAX_DATETIME_PRECISION);
DBUG_RETURN(TRUE);
}
@@ -10044,7 +10046,7 @@ bool Column_definition::check(THD *thd)
length= 1;
if (length > MAX_BIT_FIELD_LENGTH)
{
- my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name,
+ my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), name().ptr(),
static_cast<ulong>(MAX_BIT_FIELD_LENGTH));
DBUG_RETURN(TRUE);
}
@@ -10089,12 +10091,12 @@ bool Column_definition::check(THD *thd)
sql_type == MYSQL_TYPE_STRING) ? ER_TOO_BIG_FIELDLENGTH :
ER_TOO_BIG_DISPLAYWIDTH,
MYF(0),
- field_name, max_field_charlength); /* purecov: inspected */
+ name().ptr(), max_field_charlength); /* purecov: inspected */
DBUG_RETURN(TRUE);
}
if ((~allowed_type_modifier) & flags & conditional_type_modifiers)
{
- my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name);
+ my_error(ER_WRONG_FIELD_SPEC, MYF(0), name().ptr());
DBUG_RETURN(TRUE);
}
@@ -10197,7 +10199,7 @@ Field *make_field(TABLE_SHARE *share,
Field::geometry_type geom_type, uint srid,
Field::utype unireg_check,
TYPELIB *interval,
- const char *field_name)
+ const Column_name &field_name)
{
uchar *UNINIT_VAR(bit_ptr);
uchar UNINIT_VAR(bit_offset);
@@ -10240,8 +10242,7 @@ Field *make_field(TABLE_SHARE *share,
field_type == MYSQL_TYPE_VAR_STRING)
return new (mem_root)
Field_string(ptr,field_length,null_pos,null_bit,
- unireg_check, field_name,
- field_charset);
+ unireg_check, field_name, field_charset);
if (field_type == MYSQL_TYPE_VARCHAR)
return new (mem_root)
Field_varstring(ptr,field_length,
@@ -10426,9 +10427,9 @@ Field *make_field(TABLE_SHARE *share,
/** Create a field suitable for create of table. */
Column_definition::Column_definition(THD *thd, Field *old_field,
- Field *orig_field)
+ Field *orig_field):
+ Column_name(old_field)
{
- field_name= old_field->field_name;
length= old_field->field_length;
flags= old_field->flags;
unireg_check=old_field->unireg_check;
@@ -10647,7 +10648,7 @@ Field::set_warning(Sql_condition::enum_warning_level level, uint code,
if (thd->count_cuted_fields)
{
thd->cuted_fields+= cut_increment;
- push_warning_printf(thd, level, code, ER_THD(thd, code), field_name,
+ push_warning_printf(thd, level, code, ER_THD(thd, code), name().ptr(),
thd->get_stmt_da()->current_row_for_warning());
return 0;
}
@@ -10680,7 +10681,7 @@ void Field::set_datetime_warning(Sql_condition::enum_warning_level level,
{
THD *thd= get_thd();
if (thd->really_abort_on_warning() && level >= Sql_condition::WARN_LEVEL_WARN)
- make_truncated_value_warning(thd, level, str, ts_type, field_name);
+ make_truncated_value_warning(thd, level, str, ts_type, name().ptr());
else
set_warning(level, code, cuted_increment);
}
@@ -10693,7 +10694,7 @@ void Field::set_warning_truncated_wrong_value(const char *type_arg,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
ER_THD(thd, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
- type_arg, value, field_name,
+ type_arg, value, name().ptr(),
static_cast<ulong>(thd->get_stmt_da()->
current_row_for_warning()));
}
@@ -10761,7 +10762,7 @@ bool Field::validate_value_in_record_with_warn(THD *thd, const uchar *record)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_INVALID_DEFAULT_VALUE_FOR_FIELD,
ER_THD(thd, ER_INVALID_DEFAULT_VALUE_FOR_FIELD),
- ErrConvString(&tmp).ptr(), field_name);
+ ErrConvString(&tmp).ptr(), name().ptr());
}
dbug_tmp_restore_column_map(table->read_set, old_map);
return rc;
diff --git a/sql/field.h b/sql/field.h
index 0591914..a40e307 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -537,6 +537,115 @@ inline bool is_temporal_type_with_time(enum_field_types type)
}
+/**
+ @class Name
+ An arbitrary SQL name, consisting of a NULL-terminated string
+ and its length.
+ Later it can be reused for table and schema names.
+*/
+class Name
+{
+ const char *m_str;
+ uint m_length;
+ /**
+ Maximum possible hard length limit that can ever come to the constructors.
+ Classes that use Name can have stricter length limits.
+ */
+ uint max_name_length() const { return UINT_MAX32; }
+ /**
+ Check that the members are syncronized:
+ - either it's a NULL string (str==NULL and length==0)
+ - or a null-terminated string: str[legnth]=='\0'
+ */
+ bool in_sync() const
+ {
+ return (!m_str && !m_length) ||
+ (m_str[m_length] == '\0');
+ }
+public:
+ Name(const char *str, uint length):
+ m_str(str), m_length(length)
+ {
+ DBUG_ASSERT(length <= max_name_length());
+ DBUG_ASSERT(in_sync());
+ }
+ Name(const LEX_STRING &str):
+ m_str(str.str), m_length(str.length)
+ {
+ DBUG_ASSERT(str.length <= max_name_length());
+ DBUG_ASSERT(in_sync());
+ }
+ void set_name(const Name &other)
+ {
+ *this= other;
+ DBUG_ASSERT(in_sync());
+ }
+ const char *ptr() const { return m_str; }
+ uint length() const { return m_length; }
+ const Name &name() const { return *this; }
+};
+
+
+/**
+ @class Column_name
+ A parent class for a number of classes that refer to a column by its name.
+ Character set of the strings are system_charset_info (utf8).
+ Column names are compared case insensitively.
+
+ Currently used in:
+ - Field
+ - Column_definition
+ - Key_part_spec
+ Having Column_name as a common parent class for the above classes makes it
+ easy to copy and compare their names
+ (e.g. between Field and Column_definition), as well as construct each other.
+*/
+class Column_name: public Name
+{
+public:
+ Column_name(const Column_name &other):
+ Name(other)
+ { }
+ Column_name(const Column_name *other):
+ Name(*other)
+ { }
+ Column_name(const Name &other):
+ Name(other)
+ { }
+ Column_name(const LEX_STRING &other):
+ Name(other.str, other.length)
+ { }
+ Column_name(const LEX_CSTRING &other):
+ Name(other.str, other.length)
+ { }
+ Column_name(const char *str, uint length):
+ Name(str, length)
+ { }
+ /**
+ - This constructor is used to create Fields from Items.
+ We should eventually to reuse Column_name in Item
+ and remove this constructor.
+ - Spider also uses this constructor in a few places in spd_sys_table.cc,
+ to create Field_blob.
+ */
+ Column_name(const char *str):
+ Name(str, str ? strlen(str) : 0)
+ { }
+ bool eq_name(const char *other) const
+ {
+ return !my_strcasecmp(system_charset_info, other, ptr());
+ }
+ bool eq_name(const Column_name *other) const
+ {
+ return length() == other->length() && eq_name(other->ptr());
+ }
+ bool eq_name(const Column_name &other) const
+ {
+ return length() == other.length() && eq_name(other.ptr());
+ }
+};
+
+
/*
Virtual_column_info is the class to contain additional
characteristics that is specific for a virtual/computed
@@ -602,7 +711,7 @@ class Virtual_column_info: public Sql_alloc
}
};
-class Field: public Value_source
+class Field: public Value_source, public Column_name
{
Field(const Item &); /* Prevent use of these */
void operator=(Field &);
@@ -628,7 +737,6 @@ class Field: public Value_source
TABLE *table; // Pointer for table
TABLE *orig_table; // Pointer to original table
const char * const *table_name;
- const char *field_name;
/** reference to the list of options or NULL */
engine_option_value *option_list;
ha_field_option_struct *option_struct; /* structure with parsed options */
@@ -716,7 +824,7 @@ class Field: public Value_source
Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg);
+ const Column_name &field_name_arg);
virtual ~Field() {}
/* Store functions returns 1 on overflow and -1 on fatal error */
virtual int store(const char *to, uint length,CHARSET_INFO *cs)=0;
@@ -1473,7 +1581,7 @@ class Field_num :public Field {
bool zerofill,unsigned_flag; // Purify cannot handle bit fields
Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg,
+ const Column_name& field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg);
enum Item_result result_type () const { return INT_RESULT; }
enum Derivation derivation(void) const { return DERIVATION_NUMERIC; }
@@ -1520,7 +1628,7 @@ class Field_str :public Field {
const Item_equal *item_equal);
Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg, CHARSET_INFO *charset);
+ const Column_name& field_name_arg, CHARSET_INFO *charset);
Item_result result_type () const { return STRING_RESULT; }
uint decimals() const { return NOT_FIXED_DEC; }
int store(double nr);
@@ -1577,7 +1685,7 @@ class Field_longstr :public Field_str
public:
Field_longstr(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg, CHARSET_INFO *charset_arg)
+ const Column_name& field_name_arg, CHARSET_INFO *charset_arg)
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, charset_arg)
{}
@@ -1612,7 +1720,7 @@ class Field_real :public Field_num {
Field_real(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg,
+ const Column_name& field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, dec_arg, zero_arg, unsigned_arg),
@@ -1634,7 +1742,7 @@ class Field_decimal :public Field_real {
public:
Field_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
@@ -1678,10 +1786,10 @@ class Field_new_decimal :public Field_num {
*/
Field_new_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg);
Field_new_decimal(uint32 len_arg, bool maybe_null_arg,
- const char *field_name_arg, uint8 dec_arg,
+ const Column_name& field_name_arg, uint8 dec_arg,
bool unsigned_arg);
enum_field_types type() const { return MYSQL_TYPE_NEWDECIMAL;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
@@ -1727,7 +1835,7 @@ class Field_tiny :public Field_num {
public:
Field_tiny(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name &field_name_arg,
bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
@@ -1771,13 +1879,13 @@ class Field_short :public Field_num {
public:
Field_short(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg)
{}
- Field_short(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_short(uint32 len_arg,bool maybe_null_arg, const Column_name& field_name_arg,
bool unsigned_arg)
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, 0, 0, unsigned_arg)
@@ -1811,7 +1919,7 @@ class Field_medium :public Field_num {
public:
Field_medium(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
@@ -1845,13 +1953,13 @@ class Field_long :public Field_num {
public:
Field_long(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg)
{}
- Field_long(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_long(uint32 len_arg,bool maybe_null_arg, const Column_name& field_name_arg,
bool unsigned_arg)
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg,0,0,unsigned_arg)
@@ -1890,14 +1998,14 @@ class Field_longlong :public Field_num {
public:
Field_longlong(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg)
{}
Field_longlong(uint32 len_arg,bool maybe_null_arg,
- const char *field_name_arg,
+ const Column_name& field_name_arg,
bool unsigned_arg)
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg,0,0,unsigned_arg)
@@ -1939,13 +2047,13 @@ class Field_float :public Field_real {
public:
Field_float(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
dec_arg, zero_arg, unsigned_arg)
{}
- Field_float(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
+ Field_float(uint32 len_arg, bool maybe_null_arg, const Column_name& field_name_arg,
uint8 dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0)
@@ -1974,18 +2082,18 @@ class Field_double :public Field_real {
public:
Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg,
dec_arg, zero_arg, unsigned_arg)
{}
- Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
+ Field_double(uint32 len_arg, bool maybe_null_arg, const Column_name& field_name_arg,
uint8 dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0)
{}
- Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
+ Field_double(uint32 len_arg, bool maybe_null_arg, const Column_name& field_name_arg,
uint8 dec_arg, bool not_fixed_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0)
@@ -2016,7 +2124,7 @@ class Field_null :public Field_str {
static uchar null[1];
public:
Field_null(uchar *ptr_arg, uint32 len_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
CHARSET_INFO *cs)
:Field_str(ptr_arg, len_arg, null, 1,
unireg_check_arg, field_name_arg, cs)
@@ -2063,7 +2171,7 @@ class Field_temporal: public Field {
public:
Field_temporal(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,
- const char *field_name_arg)
+ const Column_name &field_name_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg)
{ flags|= BINARY_FLAG; }
@@ -2129,7 +2237,7 @@ class Field_temporal_with_date: public Field_temporal {
Field_temporal_with_date(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
utype unireg_check_arg,
- const char *field_name_arg)
+ const Column_name& field_name_arg)
:Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
{}
@@ -2149,7 +2257,7 @@ class Field_timestamp :public Field_temporal {
public:
Field_timestamp(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
TABLE_SHARE *share);
enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
@@ -2232,7 +2340,7 @@ class Field_timestamp_with_dec :public Field_timestamp {
Field_timestamp_with_dec(uchar *ptr_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg,
+ const Column_name& field_name_arg,
TABLE_SHARE *share, uint dec_arg) :
Field_timestamp(ptr_arg,
MAX_DATETIME_WIDTH + dec_arg + MY_TEST(dec_arg), null_ptr_arg,
@@ -2266,7 +2374,7 @@ class Field_timestamp_hires :public Field_timestamp_with_dec {
Field_timestamp_hires(uchar *ptr_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg,
+ const Column_name& field_name_arg,
TABLE_SHARE *share, uint dec_arg) :
Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, share, dec_arg)
@@ -2294,7 +2402,7 @@ class Field_timestampf :public Field_timestamp_with_dec {
Field_timestampf(uchar *ptr_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg,
- const char *field_name_arg,
+ const Column_name& field_name_arg,
TABLE_SHARE *share, uint dec_arg) :
Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, share, dec_arg)
@@ -2326,7 +2434,7 @@ class Field_year :public Field_tiny {
public:
Field_year(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg)
+ enum utype unireg_check_arg, const Column_name& field_name_arg)
:Field_tiny(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, 1, 1)
{}
@@ -2350,7 +2458,7 @@ class Field_date :public Field_temporal_with_date {
bool get_TIME(MYSQL_TIME *ltime, const uchar *pos, ulonglong fuzzydate) const;
public:
Field_date(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg)
+ enum utype unireg_check_arg, const Column_name& field_name_arg)
:Field_temporal_with_date(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg) {}
enum_field_types type() const { return MYSQL_TYPE_DATE;}
@@ -2385,7 +2493,7 @@ class Field_newdate :public Field_temporal_with_date {
bool get_TIME(MYSQL_TIME *ltime, const uchar *pos, ulonglong fuzzydate) const;
public:
Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg)
+ enum utype unireg_check_arg, const Column_name& field_name_arg)
:Field_temporal_with_date(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
{}
@@ -2423,7 +2531,7 @@ class Field_time :public Field_temporal {
public:
Field_time(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg,
- const char *field_name_arg)
+ const Column_name& field_name_arg)
:Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg), curdays(0)
{}
@@ -2462,7 +2570,7 @@ class Field_time_with_dec :public Field_time {
uint dec;
public:
Field_time_with_dec(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
uint dec_arg)
:Field_time(ptr_arg, MIN_TIME_WIDTH + dec_arg + MY_TEST(dec_arg),
null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg),
@@ -2486,7 +2594,7 @@ class Field_time_hires :public Field_time_with_dec {
void store_TIME(MYSQL_TIME *ltime);
public:
Field_time_hires(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
uint dec_arg)
:Field_time_with_dec(ptr_arg, null_ptr_arg,
null_bit_arg, unireg_check_arg, field_name_arg,
@@ -2517,7 +2625,7 @@ class Field_timef :public Field_time_with_dec {
}
public:
Field_timef(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
uint dec_arg)
:Field_time_with_dec(ptr_arg, null_ptr_arg,
null_bit_arg, unireg_check_arg, field_name_arg,
@@ -2559,7 +2667,7 @@ class Field_datetime :public Field_temporal_with_date {
public:
Field_datetime(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg,
- const char *field_name_arg)
+ const Column_name& field_name_arg)
:Field_temporal_with_date(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg)
{}
@@ -2626,7 +2734,7 @@ class Field_datetime_with_dec :public Field_datetime {
public:
Field_datetime_with_dec(uchar *ptr_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg,
- const char *field_name_arg, uint dec_arg)
+ const Column_name& field_name_arg, uint dec_arg)
:Field_datetime(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + MY_TEST(dec_arg),
null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg), dec(dec_arg)
@@ -2662,7 +2770,7 @@ class Field_datetime_hires :public Field_datetime_with_dec {
public:
Field_datetime_hires(uchar *ptr_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg,
- const char *field_name_arg, uint dec_arg)
+ const Column_name& field_name_arg, uint dec_arg)
:Field_datetime_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, dec_arg)
{
@@ -2690,7 +2798,7 @@ class Field_datetimef :public Field_datetime_with_dec {
public:
Field_datetimef(uchar *ptr_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg,
- const char *field_name_arg, uint dec_arg)
+ const Column_name& field_name_arg, uint dec_arg)
:Field_datetime_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, dec_arg)
{}
@@ -2720,7 +2828,8 @@ class Field_datetimef :public Field_datetime_with_dec {
static inline Field_timestamp *
new_Field_timestamp(MEM_ROOT *root,uchar *ptr, uchar *null_ptr, uchar null_bit,
- enum Field::utype unireg_check, const char *field_name,
+ enum Field::utype unireg_check,
+ const Column_name& field_name,
TABLE_SHARE *share, uint dec)
{
if (dec==0)
@@ -2736,7 +2845,7 @@ new_Field_timestamp(MEM_ROOT *root,uchar *ptr, uchar *null_ptr, uchar null_bit,
static inline Field_time *
new_Field_time(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit,
- enum Field::utype unireg_check, const char *field_name,
+ enum Field::utype unireg_check, const Column_name &field_name,
uint dec)
{
if (dec == 0)
@@ -2752,7 +2861,7 @@ new_Field_time(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit,
static inline Field_datetime *
new_Field_datetime(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit,
enum Field::utype unireg_check,
- const char *field_name, uint dec)
+ const Column_name &field_name, uint dec)
{
if (dec == 0)
return new (root)
@@ -2775,12 +2884,12 @@ class Field_string :public Field_longstr {
bool can_alter_field_type;
Field_string(uchar *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
CHARSET_INFO *cs)
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, cs),
can_alter_field_type(1) {};
- Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_string(uint32 len_arg,bool maybe_null_arg, const Column_name& field_name_arg,
CHARSET_INFO *cs)
:Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs),
@@ -2863,7 +2972,7 @@ class Field_varstring :public Field_longstr {
Field_varstring(uchar *ptr_arg,
uint32 len_arg, uint length_bytes_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
TABLE_SHARE *share, CHARSET_INFO *cs)
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, cs),
@@ -2872,7 +2981,7 @@ class Field_varstring :public Field_longstr {
share->varchar_fields++;
}
Field_varstring(uint32 len_arg,bool maybe_null_arg,
- const char *field_name_arg,
+ const Column_name& field_name_arg,
TABLE_SHARE *share, CHARSET_INFO *cs)
:Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs),
@@ -2948,9 +3057,9 @@ class Field_blob :public Field_longstr {
public:
Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
TABLE_SHARE *share, uint blob_pack_length, CHARSET_INFO *cs);
- Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_blob(uint32 len_arg,bool maybe_null_arg, const Column_name& field_name_arg,
CHARSET_INFO *cs)
:Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs),
@@ -2958,7 +3067,7 @@ class Field_blob :public Field_longstr {
{
flags|= BLOB_FLAG;
}
- Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_blob(uint32 len_arg,bool maybe_null_arg, const Column_name& field_name_arg,
CHARSET_INFO *cs, bool set_packlength)
:Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs)
@@ -2974,7 +3083,9 @@ class Field_blob :public Field_longstr {
}
}
Field_blob(uint32 packlength_arg)
- :Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, "temp", system_charset_info),
+ :Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE,
+ Column_name(C_STRING_WITH_LEN("temp")),
+ system_charset_info),
packlength(packlength_arg) {}
/* Note that the default copy constructor is used, in clone() */
enum_field_types type() const { return MYSQL_TYPE_BLOB;}
@@ -3104,13 +3215,13 @@ class Field_geom :public Field_blob {
enum storage_type storage;
Field_geom(uchar *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
TABLE_SHARE *share, uint blob_pack_length,
enum geometry_type geom_type_arg, uint field_srid)
:Field_blob(ptr_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, share, blob_pack_length, &my_charset_bin)
{ geom_type= geom_type_arg; srid= field_srid; }
- Field_geom(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+ Field_geom(uint32 len_arg,bool maybe_null_arg, const Column_name& field_name_arg,
TABLE_SHARE *share, enum geometry_type geom_type_arg)
:Field_blob(len_arg, maybe_null_arg, field_name_arg, &my_charset_bin)
{ geom_type= geom_type_arg; srid= 0; }
@@ -3160,7 +3271,7 @@ class Field_enum :public Field_str {
TYPELIB *typelib;
Field_enum(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
uint packlength_arg,
TYPELIB *typelib_arg,
CHARSET_INFO *charset_arg)
@@ -3226,7 +3337,7 @@ class Field_set :public Field_enum {
public:
Field_set(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg,
+ enum utype unireg_check_arg, const Column_name& field_name_arg,
uint32 packlength_arg,
TYPELIB *typelib_arg, CHARSET_INFO *charset_arg)
:Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
@@ -3274,7 +3385,7 @@ class Field_bit :public Field {
uint bytes_in_rec;
Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
- enum utype unireg_check_arg, const char *field_name_arg);
+ enum utype unireg_check_arg, const Column_name& field_name_arg);
enum_field_types type() const { return MYSQL_TYPE_BIT; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BIT; }
uint32 key_length() const { return (uint32) (field_length + 7) / 8; }
@@ -3404,7 +3515,7 @@ class Field_bit_as_char: public Field_bit {
public:
Field_bit_as_char(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
- enum utype unireg_check_arg, const char *field_name_arg);
+ enum utype unireg_check_arg, const Column_name& field_name_arg);
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
uint size_of() const { return sizeof(*this); }
int store(const char *to, uint length, CHARSET_INFO *charset);
@@ -3417,13 +3528,13 @@ class Field_bit_as_char: public Field_bit {
extern const LEX_STRING null_lex_str;
+
/*
Create field class for CREATE TABLE
*/
-class Column_definition: public Sql_alloc
+class Column_definition: public Sql_alloc, public Column_name
{
public:
- const char *field_name;
LEX_STRING comment; // Comment for field
Item *def, *on_update; // Default value
enum enum_field_types sql_type;
@@ -3458,6 +3569,7 @@ class Column_definition: public Sql_alloc
Virtual_column_info *vcol_info;
Column_definition():
+ Column_name(null_lex_str),
comment(null_lex_str),
def(0), on_update(0), sql_type(MYSQL_TYPE_NULL),
flags(0), pack_length(0), key_length(0), interval(0),
@@ -3526,7 +3638,7 @@ class Create_field :public Column_definition
{ }
Create_field(THD *thd, Field *old_field, Field *orig_field):
Column_definition(thd, old_field, orig_field),
- change(old_field->field_name), after(0),
+ change(old_field->name().ptr()), after(0),
field(old_field), create_if_not_exists(false)
{ }
/* Used to make a clone of this object for ALTER/CREATE TABLE */
@@ -3603,7 +3715,7 @@ Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root,
CHARSET_INFO *cs,
Field::geometry_type geom_type, uint srid,
Field::utype unireg_check,
- TYPELIB *interval, const char *field_name);
+ TYPELIB *interval, const Column_name &field_name);
uint pack_length_to_packflag(uint type);
enum_field_types get_blob_type_from_length(ulong length);
uint32 calc_pack_length(enum_field_types type,uint32 length);
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 0ad8cee..287e8f6 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -139,7 +139,7 @@ set_field_to_null(Field *field)
return 0;
case CHECK_FIELD_ERROR_FOR_NULL:
if (!field->table->in_use->no_errors)
- my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name);
+ my_error(ER_BAD_NULL_ERROR, MYF(0), field->name().ptr());
return -1;
}
DBUG_ASSERT(0); // impossible
@@ -208,7 +208,7 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
return 0;
case CHECK_FIELD_ERROR_FOR_NULL:
if (!field->table->in_use->no_errors)
- my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name);
+ my_error(ER_BAD_NULL_ERROR, MYF(0), field->name().ptr());
return -1;
}
DBUG_ASSERT(0); // impossible
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 917b9de..762b6f5 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -538,7 +538,7 @@ const char* dbug_print_table_row(TABLE *table)
else
output.append(",");
- output.append((*pfield)->field_name? (*pfield)->field_name: "NULL");
+ output.append((*pfield)->name().ptr()? (*pfield)->name().ptr(): "NULL");
}
output.append(")=(");
@@ -589,7 +589,7 @@ static void dbug_print_record(TABLE *table, bool print_rowid)
fprintf(DBUG_FILE, "record (");
for (pfield= table->field; *pfield ; pfield++)
- fprintf(DBUG_FILE, "%s%s", (*pfield)->field_name, (pfield[1])? ", ":"");
+ fprintf(DBUG_FILE, "%s%s", (*pfield)->name().ptr(), (pfield[1])? ", ":"");
fprintf(DBUG_FILE, ") = ");
fprintf(DBUG_FILE, "(");
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 5d789fa..ff559d4 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -7944,7 +7944,7 @@ void ha_partition::append_row_to_str(String &str)
{
Field *field= key_part->field;
str.append(" ");
- str.append(field->field_name);
+ str.append(field->name().ptr());
str.append(":");
field_unpack(&str, field, rec, 0, false);
}
@@ -7964,7 +7964,7 @@ void ha_partition::append_row_to_str(String &str)
{
Field *field= *field_ptr;
str.append(" ");
- str.append(field->field_name);
+ str.append(field->name().ptr());
str.append(":");
field_unpack(&str, field, rec, 0, false);
}
diff --git a/sql/handler.cc b/sql/handler.cc
index 193d36a..5d27a84 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3545,7 +3545,7 @@ void handler::print_error(int error, myf errflag)
break;
case HA_ERR_AUTOINC_ERANGE:
textno= error;
- my_error(textno, errflag, table->next_number_field->field_name,
+ my_error(textno, errflag, table->next_number_field->name().ptr(),
table->in_use->get_stmt_da()->current_row_for_warning());
DBUG_VOID_RETURN;
break;
diff --git a/sql/item.cc b/sql/item.cc
index 18879a8..fb4019d 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -855,7 +855,7 @@ bool Item_ident::collect_outer_ref_processor(uchar *param)
bool Item_field::collect_item_field_processor(uchar *arg)
{
DBUG_ENTER("Item_field::collect_item_field_processor");
- DBUG_PRINT("info", ("%s", field->field_name ? field->field_name : "noname"));
+ DBUG_PRINT("info", ("%s", field->name().ptr() ? field->name().ptr() : "noname"));
List<Item_field> *item_list= (List<Item_field>*) arg;
List_iterator<Item_field> item_list_it(*item_list);
Item_field *curr_item;
@@ -872,7 +872,7 @@ bool Item_field::collect_item_field_processor(uchar *arg)
bool Item_field::add_field_to_set_processor(uchar *arg)
{
DBUG_ENTER("Item_field::add_field_to_set_processor");
- DBUG_PRINT("info", ("%s", field->field_name ? field->field_name : "noname"));
+ DBUG_PRINT("info", ("%s", field->name().ptr() ? field->name().ptr() : "noname"));
TABLE *table= (TABLE *) arg;
if (field->table == table)
bitmap_set_bit(&table->tmp_set, field->field_index);
@@ -2173,7 +2173,7 @@ void Item_ident_for_show::make_field(THD *thd, Send_field *tmp_field)
{
tmp_field->table_name= tmp_field->org_table_name= table_name;
tmp_field->db_name= db_name;
- tmp_field->col_name= tmp_field->org_col_name= field->field_name;
+ tmp_field->col_name= tmp_field->org_col_name= field->name().ptr();
tmp_field->charsetnr= field->charset()->number;
tmp_field->length=field->field_length;
tmp_field->type=field->type();
@@ -2185,7 +2185,7 @@ void Item_ident_for_show::make_field(THD *thd, Send_field *tmp_field)
/**********************************************/
Item_field::Item_field(THD *thd, Field *f)
- :Item_ident(thd, 0, NullS, *f->table_name, f->field_name),
+ :Item_ident(thd, 0, NullS, *f->table_name, f->name().ptr()),
item_equal(0),
have_privileges(0), any_privileges(0)
{
@@ -2208,7 +2208,7 @@ Item_field::Item_field(THD *thd, Field *f)
Item_field::Item_field(THD *thd, Name_resolution_context *context_arg,
Field *f)
- :Item_ident(thd, context_arg, f->table->s->db.str, *f->table_name, f->field_name),
+ :Item_ident(thd, context_arg, f->table->s->db.str, *f->table_name, f->name().ptr()),
item_equal(0),
have_privileges(0), any_privileges(0)
{
@@ -2338,7 +2338,7 @@ void Item_field::set_field(Field *field_par)
maybe_null=field->maybe_null();
decimals= field->decimals();
table_name= *field_par->table_name;
- field_name= field_par->field_name;
+ field_name= field_par->name().ptr();
db_name= field_par->table->s->db.str;
alias_name_used= field_par->table->alias_name_used;
unsigned_flag= MY_TEST(field_par->flags & UNSIGNED_FLAG);
@@ -2363,8 +2363,8 @@ void Item_field::set_field(Field *field_par)
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;
+ /* 'name' is pointing at field->name().ptr() of old field */
+ name= (char*) f->name().ptr();
}
@@ -8124,7 +8124,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
field_arg= (Item_field *)real_arg;
if (field_arg->field->flags & NO_DEFAULT_VALUE_FLAG)
{
- my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), field_arg->field->field_name);
+ my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), field_arg->field->name().ptr());
goto error;
}
if (!(def_field= (Field*) thd->alloc(field_arg->field->size_of())))
@@ -8188,7 +8188,7 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions)
Sql_condition::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_FIELD,
ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD),
- field_arg->field_name);
+ field_arg->name().ptr());
}
return 1;
}
@@ -8284,8 +8284,8 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items)
{
Field *tmp_field= field_arg->field;
/* charset doesn't matter here, it's to avoid sigsegv only */
- tmp_field= new Field_null(0, 0, Field::NONE, field_arg->field->field_name,
- &my_charset_bin);
+ tmp_field= new Field_null(0, 0, Field::NONE, field_arg->field->name(),
+ &my_charset_bin);
if (tmp_field)
{
tmp_field->init(field_arg->field->table);
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index f232d77..381ee0b 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -5854,10 +5854,10 @@ void Ordered_key::print(String *str)
str->append(", (");
for (i= 0; i < key_column_count - 1; i++)
{
- str->append(key_columns[i]->field->field_name);
+ str->append(key_columns[i]->field->name().ptr());
str->append(", ");
}
- str->append(key_columns[i]->field->field_name);
+ str->append(key_columns[i]->field->name().ptr());
str->append("), ");
str->append("null_bitmap: (bits=");
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 7e6753e..20450f9 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -4401,7 +4401,7 @@ static void print_partitioning_index(KEY_PART *parts, KEY_PART *parts_end)
fprintf(DBUG_FILE, "partitioning INDEX(");
for (KEY_PART *p=parts; p != parts_end; p++)
{
- fprintf(DBUG_FILE, "%s%s", p==parts?"":" ,", p->field->field_name);
+ fprintf(DBUG_FILE, "%s%s", p==parts?"":" ,", p->field->name().ptr());
}
fputs(");\n", DBUG_FILE);
DBUG_UNLOCK_FILE;
@@ -4440,7 +4440,7 @@ static void dbug_print_segment_range(SEL_ARG *arg, KEY_PART *part)
fputs(" <= ", DBUG_FILE);
}
- fprintf(DBUG_FILE, "%s", part->field->field_name);
+ fprintf(DBUG_FILE, "%s", part->field->name().ptr());
if (!(arg->max_flag & NO_MAX_RANGE))
{
@@ -4479,7 +4479,7 @@ static void dbug_print_singlepoint_range(SEL_ARG **start, uint num)
for (SEL_ARG **arg= start; arg != end; arg++)
{
Field *field= (*arg)->field;
- fprintf(DBUG_FILE, "%s%s=", (arg==start)?"":", ", field->field_name);
+ fprintf(DBUG_FILE, "%s%s=", (arg==start)?"":", ", field->name().ptr());
dbug_print_field(field);
}
fputs("\n", DBUG_FILE);
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 4b21ffe..ea0ca68 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -4012,8 +4012,9 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd)
For the sake of uniformity, always use Field_varstring (altough we could
use Field_string for shorter keys)
*/
- field= new Field_varstring(uniq_tuple_length_arg, FALSE, "rowids", share,
- &my_charset_bin);
+ field= new Field_varstring(uniq_tuple_length_arg, FALSE,
+ Column_name(C_STRING_WITH_LEN("rowids")),
+ share, &my_charset_bin);
if (!field)
DBUG_RETURN(0);
field->table= table;
diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc
index 912ef4a..71fbc16 100644
--- a/sql/opt_table_elimination.cc
+++ b/sql/opt_table_elimination.cc
@@ -1843,7 +1843,7 @@ void Dep_analysis_context::dbug_print_deps()
(long)(eq_mod - equality_mods),
str.c_ptr(),
eq_mod->field->table->table->alias.c_ptr(),
- eq_mod->field->field->field_name);
+ eq_mod->field->field->name().ptr());
}
else
{
@@ -1867,7 +1867,7 @@ void Dep_analysis_context::dbug_print_deps()
{
fprintf(DBUG_FILE, " field %s.%s ->",
table_dep->table->alias.c_ptr(),
- field_dep->field->field_name);
+ field_dep->field->name().ptr());
uint ofs= field_dep->bitmap_offset;
for (uint bit= ofs; bit < ofs + n_equality_mods; bit++)
{
diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc
index 208b2b6..4830ba1 100644
--- a/sql/rpl_record.cc
+++ b/sql/rpl_record.cc
@@ -107,7 +107,7 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
field->max_data_length());
DBUG_PRINT("debug", ("field: %s; real_type: %d, pack_ptr: 0x%lx;"
" pack_ptr':0x%lx; bytes: %d",
- field->field_name, field->real_type(),
+ field->name().ptr(), field->real_type(),
(ulong) old_pack_ptr, (ulong) pack_ptr,
(int) (pack_ptr - old_pack_ptr)));
DBUG_DUMP("packed_data", old_pack_ptr, pack_ptr - old_pack_ptr);
@@ -254,7 +254,7 @@ unpack_row(rpl_group_info *rgi,
conv_field ? conv_field : *field_ptr;
DBUG_PRINT("debug", ("Conversion %srequired for field '%s' (#%ld)",
conv_field ? "" : "not ",
- (*field_ptr)->field_name,
+ (*field_ptr)->name().ptr(),
(long) (field_ptr - begin_ptr)));
DBUG_ASSERT(f != NULL);
@@ -305,7 +305,7 @@ unpack_row(rpl_group_info *rgi,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_BAD_NULL_ERROR,
ER_THD(thd, ER_BAD_NULL_ERROR),
- f->field_name);
+ f->name().ptr());
}
}
else
@@ -323,7 +323,7 @@ unpack_row(rpl_group_info *rgi,
pack_ptr= f->unpack(f->ptr, pack_ptr, row_end, metadata);
DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;"
" pack_ptr: 0x%lx; pack_ptr': 0x%lx; bytes: %d",
- f->field_name, metadata,
+ f->name().ptr(), metadata,
(ulong) old_pack_ptr, (ulong) pack_ptr,
(int) (pack_ptr - old_pack_ptr)));
if (!pack_ptr)
@@ -338,7 +338,7 @@ unpack_row(rpl_group_info *rgi,
WSREP_WARN("ROW event unpack field: %s metadata: 0x%x;"
" pack_ptr: 0x%lx; conv_table %p conv_field %p table %s"
" row_end: 0x%lx",
- f->field_name, metadata,
+ f->name().ptr(), metadata,
(ulong) old_pack_ptr, conv_table, conv_field,
(table_found) ? "found" : "not found", (ulong)row_end
);
@@ -347,7 +347,7 @@ unpack_row(rpl_group_info *rgi,
rgi->rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT,
rgi->gtid_info(),
"Could not read field '%s' of table '%s.%s'",
- f->field_name, table->s->db.str,
+ f->name().ptr(), table->s->db.str,
table->s->table_name.str);
DBUG_RETURN(ER_SLAVE_CORRUPT_EVENT);
}
@@ -370,7 +370,7 @@ unpack_row(rpl_group_info *rgi,
conv_field->sql_type(source_type);
conv_field->val_str(&value_string);
DBUG_PRINT("debug", ("Copying field '%s' of type '%s' with value '%s'",
- (*field_ptr)->field_name,
+ (*field_ptr)->name().ptr(),
source_type.c_ptr_safe(), value_string.c_ptr_safe()));
#endif
copy.set(*field_ptr, f, TRUE);
@@ -381,7 +381,7 @@ unpack_row(rpl_group_info *rgi,
(*field_ptr)->sql_type(target_type);
(*field_ptr)->val_str(&value_string);
DBUG_PRINT("debug", ("Value of field '%s' of type '%s' is now '%s'",
- (*field_ptr)->field_name,
+ (*field_ptr)->name().ptr(),
target_type.c_ptr_safe(), value_string.c_ptr_safe()));
#endif
}
@@ -483,7 +483,7 @@ int prepare_record(TABLE *const table, const uint skip, const bool check)
Sql_condition::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_FIELD,
ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD),
- f->field_name);
+ f->name().ptr());
}
}
diff --git a/sql/rpl_record_old.cc b/sql/rpl_record_old.cc
index 5b87637..8765915 100644
--- a/sql/rpl_record_old.cc
+++ b/sql/rpl_record_old.cc
@@ -143,7 +143,7 @@ unpack_row_old(rpl_group_info *rgi,
{
rgi->rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT, NULL,
"Could not read field `%s` of table `%s`.`%s`",
- f->field_name, table->s->db.str,
+ f->name().ptr(), table->s->db.str,
table->s->table_name.str);
return(ER_SLAVE_CORRUPT_EVENT);
}
@@ -186,7 +186,7 @@ unpack_row_old(rpl_group_info *rgi,
rgi->rli->report(ERROR_LEVEL, ER_NO_DEFAULT_FOR_FIELD, NULL,
"Field `%s` of table `%s`.`%s` "
"has no default value and cannot be NULL",
- (*field_ptr)->field_name, table->s->db.str,
+ (*field_ptr)->name().ptr(), table->s->db.str,
table->s->table_name.str);
error = ER_NO_DEFAULT_FOR_FIELD;
}
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index 1c48d6b..866fc50 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -846,7 +846,7 @@ table_def::compatible_with(THD *thd, rpl_group_info *rgi,
{
DBUG_PRINT("debug", ("Checking column %d -"
" field '%s' can be converted - order: %d",
- col, field->field_name, order));
+ col, field->name().ptr(), order));
DBUG_ASSERT(order >= -1 && order <= 1);
/*
@@ -876,7 +876,7 @@ table_def::compatible_with(THD *thd, rpl_group_info *rgi,
{
DBUG_PRINT("debug", ("Checking column %d -"
" field '%s' can not be converted",
- col, field->field_name));
+ col, field->name().ptr()));
DBUG_ASSERT(col < size() && col < table->s->fields);
DBUG_ASSERT(table->s->db.str && table->s->table_name.str);
DBUG_ASSERT(table->in_use);
@@ -912,7 +912,7 @@ table_def::compatible_with(THD *thd, rpl_group_info *rgi,
table->field[col]->sql_type(target_type);
DBUG_PRINT("debug", ("Field %s - conversion required."
" Source type: '%s', Target type: '%s'",
- tmp_table->field[col]->field_name,
+ tmp_table->field[col]->name().ptr(),
source_type.c_ptr_safe(), target_type.c_ptr_safe()));
}
}
@@ -988,7 +988,7 @@ TABLE *table_def::create_conversion_table(THD *thd, rpl_group_info *rgi,
" column Name: %s.%s.%s.",
target_table->s->db.str,
target_table->s->table_name.str,
- target_table->field[col]->field_name);
+ target_table->field[col]->name().ptr());
goto err;
case MYSQL_TYPE_TINY_BLOB:
@@ -1017,7 +1017,8 @@ TABLE *table_def::create_conversion_table(THD *thd, rpl_group_info *rgi,
DBUG_PRINT("debug", ("sql_type: %d, target_field: '%s', max_length: %d, decimals: %d,"
" maybe_null: %d, unsigned_flag: %d, pack_length: %u",
- binlog_type(col), target_table->field[col]->field_name,
+ binlog_type(col),
+ target_table->field[col]->name().ptr(),
max_length, decimals, TRUE, unsigned_flag,
pack_length));
field_def->init_for_tmp_table(type(col),
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index cf0b8e8..0ab32e5 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -883,7 +883,9 @@ sp_head::create_result_field(uint field_max_length, const char *field_name,
m_return_field_def.geom_type, m_return_field_def.srid,
Field::NONE, /* unreg check */
m_return_field_def.interval,
- field_name ? field_name : (const char *) m_name.str);
+ field_name ?
+ Column_name(field_name, strlen(field_name)) :
+ Column_name(m_name));
field->vcol_info= m_return_field_def.vcol_info;
if (field)
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 5c3b7c2..1060dc3 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -6322,7 +6322,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
/* We assume here that table->field < NO_CACHED_FIELD_INDEX = UINT_MAX */
if (cached_field_index < table->s->fields &&
!my_strcasecmp(system_charset_info,
- table->field[cached_field_index]->field_name, name))
+ table->field[cached_field_index]->name().ptr(), name))
field_ptr= table->field + cached_field_index;
else if (table->s->name_hash.records)
{
@@ -6342,7 +6342,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length,
if (!(field_ptr= table->field))
DBUG_RETURN((Field *)0);
for (; *field_ptr; ++field_ptr)
- if (!my_strcasecmp(system_charset_info, (*field_ptr)->field_name, name))
+ if (!my_strcasecmp(system_charset_info, (*field_ptr)->name().ptr(), name))
break;
}
@@ -6598,7 +6598,7 @@ Field *find_field_in_table_sef(TABLE *table, const char *name)
if (!(field_ptr= table->field))
return (Field *)0;
for (; *field_ptr; ++field_ptr)
- if (!my_strcasecmp(system_charset_info, (*field_ptr)->field_name, name))
+ if (!my_strcasecmp(system_charset_info, (*field_ptr)->name().ptr(), name))
break;
}
if (field_ptr)
@@ -6793,7 +6793,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
if (cur_field)
{
Field *nf=new Field_null(NULL,0,Field::NONE,
- cur_field->field_name,
+ cur_field->name(),
&my_charset_bin);
nf->init(cur_table->table);
cur_field= nf;
@@ -8787,7 +8787,7 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,
ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
- rfield->field_name, table->s->table_name.str);
+ rfield->name().ptr(), table->s->table_name.str);
}
if (rfield->stored_in_db() &&
(value->save_in_field(rfield, 0)) < 0 && !ignore_errors)
@@ -8939,7 +8939,7 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN,
ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN),
- field->field_name, table->s->table_name.str);
+ field->name().ptr(), table->s->table_name.str);
}
if (use_value)
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 6656a84..0b24f4a 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -100,12 +100,6 @@ extern "C" void free_user_var(user_var_entry *entry)
my_free(entry);
}
-bool Key_part_spec::operator==(const Key_part_spec& other) const
-{
- return length == other.length &&
- !my_strcasecmp(system_charset_info, field_name.str,
- other.field_name.str);
-}
/**
Construct an (almost) deep copy of this key. Only those
@@ -231,12 +225,10 @@ bool Foreign_key::validate(List<Create_field> &table_fields)
{
it.rewind();
while ((sql_field= it++) &&
- my_strcasecmp(system_charset_info,
- column->field_name.str,
- sql_field->field_name)) {}
+ !sql_field->eq_name(column)) { }
if (!sql_field)
{
- my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name);
+ my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->name().ptr());
DBUG_RETURN(TRUE);
}
if (type == Key::FOREIGN_KEY && sql_field->vcol_info)
diff --git a/sql/sql_class.h b/sql/sql_class.h
index ae240ae..9b7727b 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -229,17 +229,16 @@ typedef struct st_copy_info {
} COPY_INFO;
-class Key_part_spec :public Sql_alloc {
+class Key_part_spec :public Sql_alloc, public Column_name {
public:
- LEX_STRING field_name;
uint length;
- Key_part_spec(const LEX_STRING &name, uint len)
- : field_name(name), length(len)
+ Key_part_spec(const Column_name &name, uint len)
+ :Column_name(name), length(len)
{}
- Key_part_spec(const char *name, const size_t name_len, uint len)
- : length(len)
- { field_name.str= (char *)name; field_name.length= name_len; }
- bool operator==(const Key_part_spec& other) const;
+ bool operator==(const Key_part_spec& other) const
+ {
+ return eq_name(other);
+ }
/**
Construct a copy of this Key_part_spec. field_name is copied
by-pointer as it is known to never change. At the same time
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 8b3e672..e2fb910 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1104,7 +1104,7 @@ void Explain_index_use::set(MEM_ROOT *mem_root, KEY *key, uint key_len_arg)
uint len= 0;
for (uint i= 0; i < key->usable_key_parts; i++)
{
- key_parts_list.append_str(mem_root, key->key_part[i].field->field_name);
+ key_parts_list.append_str(mem_root, key->key_part[i].field->name().ptr());
len += key->key_part[i].store_length;
if (len >= key_len_arg)
break;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index aa2cae5..c002f36 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -279,7 +279,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
if (check_unique && thd->dup_field)
{
- my_error(ER_FIELD_SPECIFIED_TWICE, MYF(0), thd->dup_field->field_name);
+ my_error(ER_FIELD_SPECIFIED_TWICE, MYF(0), thd->dup_field->name().ptr());
DBUG_RETURN(-1);
}
if (table->default_field)
@@ -1948,7 +1948,7 @@ int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_FIELD,
ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD),
- (*field)->field_name);
+ (*field)->name().ptr());
}
err= 1;
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 9eddd6d..a41357e 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -2850,7 +2850,8 @@ struct LEX: public Query_tables_list
bool is_analyze, bool *printed_anything);
void restore_set_statement_var();
- void init_last_field(Column_definition *field, const char *name, CHARSET_INFO *cs);
+ void init_last_field(Column_definition *field,
+ const LEX_STRING &name, CHARSET_INFO *cs);
void set_last_field_type(const Lex_field_type_st &type);
bool set_bincmp(CHARSET_INFO *cs, bool bin);
// Check if "KEY IF NOT EXISTS name" used outside of ALTER context
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index eb13e3f..9daf770 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -981,7 +981,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
Field *field= ((Item_field *)real_item)->field;
if (field->reset())
{
- my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field->field_name,
+ my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field->name().ptr(),
thd->get_stmt_da()->current_row_for_warning());
DBUG_RETURN(1);
}
@@ -1060,7 +1060,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
Field *field= ((Item_field *)real_item)->field;
if (field->reset())
{
- my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0),field->field_name,
+ my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0),field->name().ptr(),
thd->get_stmt_da()->current_row_for_warning());
DBUG_RETURN(1);
}
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 832f218..dbdf4f8 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -517,9 +517,7 @@ static bool set_up_field_array(THD *thd, TABLE *table,
do
{
field_name= it++;
- if (!my_strcasecmp(system_charset_info,
- field_name,
- field->field_name))
+ if (field->eq_name(field_name))
break;
} while (++inx < num_fields);
if (inx == num_fields)
@@ -2178,9 +2176,7 @@ static Create_field* get_sql_field(char *field_name,
while ((sql_field= it++))
{
- if (!(my_strcasecmp(system_charset_info,
- sql_field->field_name,
- field_name)))
+ if (sql_field->eq_name(field_name))
{
DBUG_RETURN(sql_field);
}
@@ -2242,7 +2238,7 @@ static int add_column_list_values(File fptr, partition_info *part_info,
return 1;
}
if (check_part_field(sql_field->sql_type,
- sql_field->field_name,
+ sql_field->name().ptr(),
&result_type,
&need_cs_check))
return 1;
@@ -2256,7 +2252,7 @@ static int add_column_list_values(File fptr, partition_info *part_info,
Field *field= part_info->part_field_array[i];
result_type= field->result_type();
if (check_part_field(field->real_type(),
- field->field_name,
+ field->name().ptr(),
&result_type,
&need_cs_check))
return 1;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 6a12c05..b3a19f1 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -15656,7 +15656,7 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field,
(org_field->flags & BLOB_FLAG))
new_field= new Field_varstring(convert_blob_length,
org_field->maybe_null(),
- org_field->field_name, table->s,
+ org_field->name(), table->s,
org_field->charset());
else
new_field= org_field->make_new_field(thd->mem_root, table,
@@ -15668,7 +15668,7 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field,
if (item)
item->result_field= new_field;
else
- new_field->field_name= name;
+ new_field->set_name(Name(name, name ? strlen(name) : 0));
new_field->flags|= (org_field->flags & NO_DEFAULT_VALUE_FLAG);
if (org_field->maybe_null() || (item && item->maybe_null))
new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join
@@ -16824,7 +16824,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
(uchar*) 0,
(uint) 0,
Field::NONE,
- NullS, &my_charset_bin);
+ null_lex_str, &my_charset_bin);
if (!key_part_info->field)
goto err;
key_part_info->field->init(table);
@@ -16986,7 +16986,7 @@ TABLE *create_virtual_tmp_table(THD *thd, List<Column_definition> &field_list)
f_maybe_null(cdef->pack_flag) ? 1 : 0,
cdef->pack_flag, cdef->sql_type, cdef->charset,
cdef->geom_type, cdef->srid, cdef->unireg_check,
- cdef->interval, cdef->field_name);
+ cdef->interval, cdef->name());
if (!*field)
goto error;
(*field)->init(table);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 1fb57d1..c640e90 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -419,7 +419,7 @@ static int get_geometry_column_record(THD *thd, TABLE_LIST *tables,
/*G_TABLE_NAME*/
table->field[6]->store(table_name->str, table_name->length, cs);
/*G_GEOMETRY_COLUMN*/
- table->field[7]->store(field->field_name, strlen(field->field_name), cs);
+ table->field[7]->store(field->name().ptr(), field->name().length(), cs);
/*STORAGE_TYPE*/
table->field[8]->store(1LL, TRUE); /*Always 1 (binary implementation)*/
/*GEOMETRY_TYPE*/
@@ -1346,7 +1346,7 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild)
for (ptr=table->field ; (field= *ptr); ptr++)
{
if (!wild || !wild[0] ||
- !wild_case_compare(system_charset_info, field->field_name,wild))
+ !wild_case_compare(system_charset_info, field->name().ptr(), wild))
{
if (table_list->view)
field_list.push_back(new (mem_root)
@@ -1808,7 +1808,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(STRING_WITH_LEN(",\n"));
packet->append(STRING_WITH_LEN(" "));
- append_identifier(thd,packet,field->field_name, strlen(field->field_name));
+ append_identifier(thd,packet, field->name().ptr(), field->name().length());
packet->append(' ');
// check for surprises from the previous call to Field::sql_type()
if (type.ptr() != tmp)
@@ -1933,8 +1933,8 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(',');
if (key_part->field)
- append_identifier(thd,packet,key_part->field->field_name,
- strlen(key_part->field->field_name));
+ append_identifier(thd,packet,key_part->field->name().ptr(),
+ key_part->field->name().length());
if (key_part->field &&
(key_part->length !=
table->field[key_part->fieldnr-1]->key_length() &&
@@ -5288,7 +5288,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
DEBUG_SYNC(thd, "get_schema_column");
if (wild && wild[0] &&
- wild_case_compare(system_charset_info, field->field_name,wild))
+ wild_case_compare(system_charset_info, field->name().ptr(), wild))
continue;
count++;
@@ -5301,7 +5301,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
&tables->grant.privilege, 0, 0, MY_TEST(tables->schema_table));
col_access= get_column_grant(thd, &tables->grant,
db_name->str, table_name->str,
- field->field_name) & COL_ACLS;
+ field->name().ptr()) & COL_ACLS;
if (!tables->schema_table && !col_access)
continue;
char *end= tmp;
@@ -5319,8 +5319,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
table->field[0]->store(STRING_WITH_LEN("def"), cs);
table->field[1]->store(db_name->str, db_name->length, cs);
table->field[2]->store(table_name->str, table_name->length, cs);
- table->field[3]->store(field->field_name, strlen(field->field_name),
- cs);
+ table->field[3]->store(field->name().ptr(), field->name().length(), cs);
table->field[4]->store((longlong) count, TRUE);
if (get_field_default_value(thd, field, &type, 0))
@@ -5645,7 +5644,7 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table,
(uchar*) "", 0, field_def->pack_flag,
field_def->sql_type, field_def->charset,
field_def->geom_type, field_def->srid, Field::NONE,
- field_def->interval, "");
+ field_def->interval, empty_lex_str);
field->table= &tbl;
tbl.in_use= thd;
@@ -5698,7 +5697,7 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table,
(uchar*) "", 0, field_def->pack_flag,
field_def->sql_type, field_def->charset,
field_def->geom_type, field_def->srid, Field::NONE,
- field_def->interval, spvar->name.str);
+ field_def->interval, spvar->name);
field->table= &tbl;
tbl.in_use= thd;
@@ -5796,7 +5795,7 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
(uchar*) "", 0, field_def->pack_flag,
field_def->sql_type, field_def->charset,
field_def->geom_type, field_def->srid, Field::NONE,
- field_def->interval, "");
+ field_def->interval, empty_lex_str);
field->table= &tbl;
tbl.in_use= thd;
@@ -5971,7 +5970,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
table->field[4]->store(db_name->str, db_name->length, cs);
table->field[5]->store(key_info->name, strlen(key_info->name), cs);
table->field[6]->store((longlong) (j+1), TRUE);
- str=(key_part->field ? key_part->field->field_name :
+ str=(key_part->field ? key_part->field->name().ptr() :
"?unknown field?");
table->field[7]->store(str, strlen(str), cs);
if (show_table->file)
@@ -6415,8 +6414,8 @@ static int get_schema_key_column_usage_record(THD *thd,
store_key_column_usage(table, db_name, table_name,
key_info->name,
strlen(key_info->name),
- key_part->field->field_name,
- strlen(key_part->field->field_name),
+ key_part->field->name().ptr(),
+ key_part->field->name().length(),
(longlong) f_idx);
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 324741f..3bf9a77 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -839,8 +839,7 @@ class Column_stat: public Stat_table
void set_key_fields(Field *col)
{
set_full_table_name();
- const char *column_name= col->field_name;
- column_name_field->store(column_name, strlen(column_name),
+ column_name_field->store(col->name().ptr(), col->name().length(),
system_charset_info);
table_field= col;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 40032c3..7f8c18f 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2937,7 +2937,7 @@ int prepare_create_field(Column_definition *sql_field,
MAX_FIELD_CHARLENGTH)
{
my_printf_error(ER_TOO_BIG_FIELDLENGTH, ER(ER_TOO_BIG_FIELDLENGTH),
- MYF(0), sql_field->field_name,
+ MYF(0), sql_field->name().ptr(),
static_cast<ulong>(MAX_FIELD_CHARLENGTH));
DBUG_RETURN(1);
}
@@ -2955,7 +2955,7 @@ int prepare_create_field(Column_definition *sql_field,
if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->unireg_check=Field::INTERVAL_FIELD;
- if (check_duplicates_in_interval("ENUM",sql_field->field_name,
+ if (check_duplicates_in_interval("ENUM", sql_field->name().ptr(),
sql_field->interval,
sql_field->charset, &dup_val_count))
DBUG_RETURN(1);
@@ -2966,14 +2966,14 @@ int prepare_create_field(Column_definition *sql_field,
if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->unireg_check=Field::BIT_FIELD;
- if (check_duplicates_in_interval("SET",sql_field->field_name,
+ if (check_duplicates_in_interval("SET", sql_field->name().ptr(),
sql_field->interval,
sql_field->charset, &dup_val_count))
DBUG_RETURN(1);
/* Check that count of unique members is not more then 64 */
if (sql_field->interval->count - dup_val_count > sizeof(longlong)*8)
{
- my_error(ER_TOO_BIG_SET, MYF(0), sql_field->field_name);
+ my_error(ER_TOO_BIG_SET, MYF(0), sql_field->name().ptr());
DBUG_RETURN(1);
}
break;
@@ -3082,7 +3082,7 @@ void promote_first_timestamp_column(List<Create_field> *column_definitions)
DBUG_PRINT("info", ("First TIMESTAMP column '%s' was promoted to "
"DEFAULT CURRENT_TIMESTAMP ON UPDATE "
"CURRENT_TIMESTAMP",
- column_definition->field_name
+ column_definition->name().ptr()
));
column_definition->unireg_check= Field::TIMESTAMP_DNUN_FIELD;
}
@@ -3152,8 +3152,7 @@ static void check_duplicate_key(THD *thd,
DBUG_ASSERT(c1 && c2);
- if (my_strcasecmp(system_charset_info,
- c1->field_name.str, c2->field_name.str) ||
+ if (!c1->eq_name(c2) ||
(c1->length != c2->length))
{
all_columns_are_identical= false;
@@ -3270,7 +3269,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (sql_field->def == NULL)
{
/* Could not convert */
- my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->name().ptr());
DBUG_RETURN(TRUE);
}
}
@@ -3349,7 +3348,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
{
if ((sql_field->flags & NOT_NULL_FLAG) != 0)
{
- my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->name().ptr());
DBUG_RETURN(TRUE);
}
@@ -3365,7 +3364,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (not_found)
{
- my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->name().ptr());
DBUG_RETURN(TRUE);
}
}
@@ -3383,7 +3382,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
{
if ((sql_field->flags & NOT_NULL_FLAG) != 0)
{
- my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->name().ptr());
DBUG_RETURN(TRUE);
}
@@ -3394,7 +3393,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
def->length(cs->cset->lengthsp(cs, def->ptr(), def->length()));
if (find_type2(interval, def->ptr(), def->length(), cs) == 0) /* not found */
{
- my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->name().ptr());
DBUG_RETURN(TRUE);
}
}
@@ -3421,18 +3420,16 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (!(sql_field->flags & NOT_NULL_FLAG))
null_fields++;
- if (check_column_name(sql_field->field_name))
+ if (check_column_name(sql_field->name().ptr()))
{
- my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name);
+ my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->name().ptr());
DBUG_RETURN(TRUE);
}
/* Check if we have used the same field name before */
for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
{
- if (my_strcasecmp(system_charset_info,
- sql_field->field_name,
- dup_field->field_name) == 0)
+ if (sql_field->eq_name(dup_field))
{
/*
If this was a CREATE ... SELECT statement, accept a field
@@ -3440,7 +3437,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
*/
if (field_no < select_field_pos || dup_no >= select_field_pos)
{
- my_error(ER_DUP_FIELDNAME, MYF(0), sql_field->field_name);
+ my_error(ER_DUP_FIELDNAME, MYF(0), sql_field->name().ptr());
DBUG_RETURN(TRUE);
}
else
@@ -3775,24 +3772,20 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
it.rewind();
field=0;
- while ((sql_field=it++) &&
- my_strcasecmp(system_charset_info,
- column->field_name.str,
- sql_field->field_name))
+ while ((sql_field=it++) && !sql_field->eq_name(column->name()))
field++;
if (!sql_field)
{
- my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str);
+ my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->name().ptr());
DBUG_RETURN(TRUE);
}
while ((dup_column= cols2++) != column)
{
- if (!my_strcasecmp(system_charset_info,
- column->field_name.str, dup_column->field_name.str))
+ if (column->eq_name(dup_column))
{
- my_printf_error(ER_DUP_FIELDNAME,
- ER_THD(thd, ER_DUP_FIELDNAME),MYF(0),
- column->field_name.str);
+ my_printf_error(ER_DUP_FIELDNAME,
+ ER_THD(thd, ER_DUP_FIELDNAME),MYF(0),
+ column->name().ptr());
DBUG_RETURN(TRUE);
}
}
@@ -3806,7 +3799,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field->charset->mbminlen > 1 || // ucs2 doesn't work yet
(ft_key_charset && sql_field->charset != ft_key_charset))
{
- my_error(ER_BAD_FT_COLUMN, MYF(0), column->field_name.str);
+ my_error(ER_BAD_FT_COLUMN, MYF(0), column->name().ptr());
DBUG_RETURN(-1);
}
ft_key_charset=sql_field->charset;
@@ -3842,7 +3835,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
{
if (!(file->ha_table_flags() & HA_CAN_INDEX_BLOBS))
{
- my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name.str,
+ my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->name().ptr(),
file->table_type());
DBUG_RETURN(TRUE);
}
@@ -3851,7 +3844,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
column->length= MAX_LEN_GEOM_POINT_FIELD;
if (!column->length)
{
- my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name.str);
+ my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->name().ptr());
DBUG_RETURN(TRUE);
}
}
@@ -3893,7 +3886,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
key_info->flags|= HA_NULL_PART_KEY;
if (!(file->ha_table_flags() & HA_NULL_IN_KEY))
{
- my_error(ER_NULL_COLUMN_IN_INDEX, MYF(0), column->field_name.str);
+ my_error(ER_NULL_COLUMN_IN_INDEX, MYF(0), column->name().ptr());
DBUG_RETURN(TRUE);
}
if (key->type == Key::SPATIAL)
@@ -3968,7 +3961,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
else if (key_part_length == 0 && (sql_field->flags & NOT_NULL_FLAG))
{
my_error(ER_WRONG_KEY_COLUMN, MYF(0), file->table_type(),
- column->field_name.str);
+ column->name().ptr());
DBUG_RETURN(TRUE);
}
if (key_part_length > file->max_key_part_length() &&
@@ -4027,7 +4020,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
primary_key=1;
}
else if (!(key_name= key->name.str))
- key_name=make_unique_key_name(thd, sql_field->field_name,
+ key_name=make_unique_key_name(thd, sql_field->name().ptr(),
*key_info_buffer, key_info);
if (check_if_keyname_exists(key_name, *key_info_buffer, key_info))
{
@@ -4126,7 +4119,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
'column_name TIMESTAMP DEFAULT 0'.
*/
- my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->name().ptr());
DBUG_RETURN(TRUE);
}
}
@@ -4248,7 +4241,7 @@ static bool prepare_blob_field(THD *thd, Column_definition *sql_field)
if (sql_field->def || thd->is_strict_mode())
{
- my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), sql_field->field_name,
+ my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), sql_field->name().ptr(),
static_cast<ulong>(MAX_FIELD_VARCHARLENGTH /
sql_field->charset->mbmaxlen));
DBUG_RETURN(1);
@@ -4256,7 +4249,7 @@ static bool prepare_blob_field(THD *thd, Column_definition *sql_field)
sql_field->sql_type= MYSQL_TYPE_BLOB;
sql_field->flags|= BLOB_FLAG;
my_snprintf(warn_buff, sizeof(warn_buff), ER_THD(thd, ER_AUTO_CONVERT),
- sql_field->field_name,
+ sql_field->name().ptr(),
(sql_field->charset == &my_charset_bin) ? "VARBINARY" :
"VARCHAR",
(sql_field->charset == &my_charset_bin) ? "BLOB" : "TEXT");
@@ -5671,8 +5664,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
*/
for (f_ptr=table->field; *f_ptr; f_ptr++)
{
- if (my_strcasecmp(system_charset_info,
- sql_field->field_name, (*f_ptr)->field_name) == 0)
+ if (sql_field->eq_name(*f_ptr))
goto drop_create_field;
}
{
@@ -5684,8 +5676,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
Create_field *chk_field;
while ((chk_field= chk_it++) && chk_field != sql_field)
{
- if (my_strcasecmp(system_charset_info,
- sql_field->field_name, chk_field->field_name) == 0)
+ if (sql_field->eq_name(chk_field))
goto drop_create_field;
}
}
@@ -5693,7 +5684,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
drop_create_field:
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_DUP_FIELDNAME, ER_THD(thd, ER_DUP_FIELDNAME),
- sql_field->field_name);
+ sql_field->name().ptr());
it.remove();
if (alter_info->create_list.is_empty())
{
@@ -5720,8 +5711,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
*/
for (f_ptr=table->field; *f_ptr; f_ptr++)
{
- if (my_strcasecmp(system_charset_info,
- sql_field->change, (*f_ptr)->field_name) == 0)
+ if ((*f_ptr)->eq_name(sql_field->change))
{
break;
}
@@ -5762,8 +5752,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
*/
for (f_ptr=table->field; *f_ptr; f_ptr++)
{
- if (my_strcasecmp(system_charset_info,
- drop->name, (*f_ptr)->field_name) == 0)
+ if ((*f_ptr)->eq_name(drop->name))
{
remove_drop= FALSE;
break;
@@ -5866,7 +5855,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
List_iterator<Key_part_spec> part_it(key->columns);
Key_part_spec *kp;
if ((kp= part_it++))
- keyname= kp->field_name.str;
+ keyname= kp->name().ptr();
if (keyname == NULL)
continue;
}
@@ -5907,7 +5896,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
List_iterator<Key_part_spec> part_it(chk_key->columns);
Key_part_spec *kp;
if ((kp= part_it++))
- chkname= kp->field_name.str;
+ chkname= kp->name().ptr();
if (keyname == NULL)
continue;
}
@@ -6241,13 +6230,12 @@ static bool fill_alter_inplace_info(THD *thd,
}
/* Check if field was renamed */
- if (my_strcasecmp(system_charset_info, field->field_name,
- new_field->field_name))
+ if (!new_field->eq_name(field))
{
field->flags|= FIELD_IS_RENAMED;
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_NAME;
rename_column_in_stat_tables(thd, table, field,
- new_field->field_name);
+ new_field->name().ptr());
}
/* Check that NULL behavior is same for old and new fields */
@@ -6678,9 +6666,7 @@ bool mysql_compare_tables(TABLE *table,
create_info->table_options|= HA_OPTION_PACK_RECORD;
/* Check if field was renamed */
- if (my_strcasecmp(system_charset_info,
- field->field_name,
- tmp_new_field->field_name))
+ if (!tmp_new_field->eq_name(field))
DBUG_RETURN(false);
/* Evaluate changes bitmap and send to check_if_incompatible_data() */
@@ -7355,7 +7341,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
while ((drop=drop_it++))
{
if (drop->type == Alter_drop::COLUMN &&
- !my_strcasecmp(system_charset_info,field->field_name, drop->name))
+ field->eq_name(drop->name))
{
/* Reset auto_increment value if it was dropped */
if (MTYP_TYPENR(field->unireg_check) == Field::NEXT_NUMBER &&
@@ -7379,7 +7365,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
while ((def=def_it++))
{
if (def->change &&
- !my_strcasecmp(system_charset_info,field->field_name, def->change))
+ field->eq_name(def->change))
break;
}
if (def)
@@ -7420,7 +7406,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
Alter_column *alter;
while ((alter=alter_it++))
{
- if (!my_strcasecmp(system_charset_info,field->field_name, alter->name))
+ if (field->eq_name(alter->name))
break;
}
if (alter)
@@ -7500,7 +7486,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
find_it.rewind();
while ((find=find_it++))
{
- if (!my_strcasecmp(system_charset_info, def->after, find->field_name))
+ if (find->eq_name(def->after))
break;
}
if (!find)
@@ -7570,7 +7556,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
{
if (!key_part->field)
continue; // Wrong field (from UNIREG)
- const char *key_part_name=key_part->field->field_name;
+ const Column_name *key_part_name= key_part->field;
Create_field *cfield;
uint key_part_length;
@@ -7579,12 +7565,10 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
{
if (cfield->change)
{
- if (!my_strcasecmp(system_charset_info, key_part_name,
- cfield->change))
+ if (key_part_name->eq_name(cfield->change))
break;
}
- else if (!my_strcasecmp(system_charset_info,
- key_part_name, cfield->field_name))
+ else if (cfield->eq_name(key_part_name))
break;
}
if (!cfield)
@@ -7631,9 +7615,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
key_part_length= 0; // Use whole field
}
key_part_length /= key_part->field->charset()->mbmaxlen;
- key_parts.push_back(new Key_part_spec(cfield->field_name,
- strlen(cfield->field_name),
- key_part_length),
+ key_parts.push_back(new Key_part_spec(*cfield, key_part_length),
thd->mem_root);
}
if (table->s->tmp_table == NO_TMP_TABLE)
@@ -7783,10 +7765,7 @@ static Create_field *get_field_by_old_name(Alter_info *alter_info,
while ((new_field= new_field_it++))
{
- if (new_field->field &&
- (my_strcasecmp(system_charset_info,
- new_field->field->field_name,
- old_name) == 0))
+ if (new_field->field && new_field->field->eq_name(old_name))
break;
}
return new_field;
@@ -7841,8 +7820,7 @@ fk_check_column_changes(THD *thd, Alter_info *alter_info,
{
Field *old_field= new_field->field;
- if (my_strcasecmp(system_charset_info, old_field->field_name,
- new_field->field_name))
+ if (!new_field->eq_name(old_field))
{
/*
Copy algorithm doesn't support proper renaming of columns in
@@ -9222,7 +9200,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
thd->abort_on_warning= true;
make_truncated_value_warning(thd, Sql_condition::WARN_LEVEL_WARN,
f_val, strlength(f_val), t_type,
- alter_ctx.datetime_field->field_name);
+ alter_ctx.datetime_field->name().ptr());
thd->abort_on_warning= save_abort_on_warning;
}
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 8e75258..7977b08 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -135,7 +135,7 @@ void TEST_filesort(SORT_FIELD *sortorder,uint s_length)
out.append(*sortorder->field->table_name);
out.append('.');
}
- out.append(sortorder->field->field_name ? sortorder->field->field_name:
+ out.append(sortorder->field->name().ptr() ? sortorder->field->name().ptr():
"tmp_table_column");
}
else
@@ -236,11 +236,11 @@ static void print_keyuse(KEYUSE *keyuse)
keyuse->val->print(&str, QT_ORDINARY);
str.append('\0');
if (keyuse->is_for_hash_join())
- fieldname= keyuse->table->field[keyuse->keypart]->field_name;
+ fieldname= keyuse->table->field[keyuse->keypart]->name().ptr();
else if (keyuse->keypart == FT_KEYPART)
fieldname= "FT_KEYPART";
else
- fieldname= key_info->key_part[keyuse->keypart].field->field_name;
+ fieldname= key_info->key_part[keyuse->keypart].field->name().ptr();
ll2str(keyuse->used_tables, buf2, 16, 0);
fprintf(DBUG_FILE, "KEYUSE: %s.%s=%s optimize: %u used_tables: %s "
"ref_table_rows: %lu keypart_map: %0lx\n",
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 7787768..87f4402 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -855,12 +855,13 @@ static void add_key_to_list(LEX *lex, LEX_STRING *field_name,
lex->alter_info.key_list.push_back(key, mem_root);
}
-void LEX::init_last_field(Column_definition *field, const char *field_name,
- CHARSET_INFO *cs)
+void LEX::init_last_field(Column_definition *field,
+ const LEX_STRING &field_name,
+ CHARSET_INFO *cs)
{
last_field= field;
- field->field_name= field_name;
+ field->set_name(field_name);
/* reset LEX fields that are used in Create_field::set_and_check() */
charset= cs;
@@ -2935,7 +2936,7 @@ sp_param_name_and_type:
sp_variable *spvar= spc->add_variable(thd, $1);
- lex->init_last_field(&spvar->field_def, $1.str,
+ lex->init_last_field(&spvar->field_def, $1,
thd->variables.collation_database);
$<spvar>$= spvar;
}
@@ -2948,7 +2949,7 @@ sp_param_name_and_type:
{
MYSQL_YYABORT;
}
- spvar->field_def.field_name= spvar->name.str;
+ spvar->field_def.set_name(spvar->name);
spvar->field_def.pack_flag |= FIELDFLAG_MAYBE_NULL;
$$= spvar;
@@ -3030,7 +3031,7 @@ sp_decl:
lex->sphead->reset_lex(thd);
pctx->declare_var_boundary($2);
- thd->lex->init_last_field(&spvar->field_def, spvar->name.str,
+ thd->lex->init_last_field(&spvar->field_def, spvar->name,
thd->variables.collation_database);
}
type_with_opt_collate
@@ -3062,8 +3063,8 @@ sp_decl:
spvar->field_def= *lex->last_field;
spvar->default_value= dflt_value_item;
- spvar->field_def.field_name= spvar->name.str;
-
+ spvar->field_def.set_name(spvar->name);
+
if (lex->sphead->fill_field_definition(thd, lex,
&spvar->field_def))
{
@@ -6133,7 +6134,7 @@ field_spec:
if (!f)
MYSQL_YYABORT;
- lex->init_last_field(f, $1.str, NULL);
+ lex->init_last_field(f, $1, NULL);
$<create_field>$= f;
}
field_type { Lex->set_last_field_type($3); }
@@ -6254,7 +6255,7 @@ field_type:
if (err || tmp_length > PRECISION_FOR_DOUBLE)
{
my_error(ER_WRONG_FIELD_SPEC, MYF(0),
- Lex->last_field->field_name);
+ Lex->last_field->name().ptr());
MYSQL_YYABORT;
}
else if (tmp_length > PRECISION_FOR_FLOAT)
@@ -7591,7 +7592,7 @@ alter_list_item:
{
Lex->alter_info.flags|= Alter_info::ALTER_CHANGE_COLUMN;
Lex->create_last_non_select_table= Lex->last_table();
- $4->change= $4->field_name;
+ $4->change= $4->name().ptr();
$4->after= $5;
}
| DROP opt_column opt_if_exists_table_element field_ident opt_restrict
@@ -16330,7 +16331,8 @@ sf_tail:
RETURNS_SYM /* $9 */
{ /* $10 */
LEX *lex= Lex;
- lex->init_last_field(&lex->sphead->m_return_field_def, NULL,
+ lex->init_last_field(&lex->sphead->m_return_field_def,
+ null_lex_str,
thd->variables.collation_database);
}
type_with_opt_collate /* $11 */
diff --git a/sql/table.cc b/sql/table.cc
index 933cfaa..a37a39d 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -198,8 +198,8 @@ View_creation_ctx * View_creation_ctx::create(THD *thd,
static uchar *get_field_name(Field **buff, size_t *length,
my_bool not_used __attribute__((unused)))
{
- *length= (uint) strlen((*buff)->field_name);
- return (uchar*) (*buff)->field_name;
+ *length= (uint) (*buff)->name().length();
+ return (uchar*) (*buff)->name().ptr();
}
@@ -3757,7 +3757,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
{
Field *field= table->field[i];
- if (strncmp(field->field_name, field_def->name.str,
+ if (strncmp(field->name().ptr(), field_def->name.str,
field_def->name.length))
{
/*
@@ -3769,7 +3769,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def)
"expected column '%s' at position %d, found '%s'.",
table->s->db.str, table->alias.c_ptr(),
field_def->name.str, i,
- field->field_name);
+ field->name().ptr());
}
field->sql_type(sql_type);
/*
@@ -5312,7 +5312,7 @@ void Field_iterator_view::set(TABLE_LIST *table)
const char *Field_iterator_table::name()
{
- return (*ptr)->field_name;
+ return (*ptr)->name().ptr();
}
@@ -6917,11 +6917,11 @@ int update_virtual_fields(THD *thd, TABLE *table,
{
/* Compute the actual value of the virtual fields */
error= vcol_info->expr_item->save_in_field(vfield, 0);
- DBUG_PRINT("info", ("field '%s' - updated", vfield->field_name));
+ DBUG_PRINT("info", ("field '%s' - updated", vfield->name().ptr()));
}
else
{
- DBUG_PRINT("info", ("field '%s' - skipped", vfield->field_name));
+ DBUG_PRINT("info", ("field '%s' - skipped", vfield->name().ptr()));
}
}
thd->reset_arena_for_cached_items(0);
diff --git a/sql/unireg.cc b/sql/unireg.cc
index f565fc9..d1f5980 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -517,7 +517,7 @@ static bool pack_header(THD *thd, uchar *forminfo,
while ((field=it++))
{
if (validate_comment_length(thd, &field->comment, COLUMN_COMMENT_MAXLEN,
- ER_TOO_LONG_FIELD_COMMENT, field->field_name))
+ ER_TOO_LONG_FIELD_COMMENT, field->name().ptr()))
DBUG_RETURN(1);
if (field->vcol_info)
@@ -565,7 +565,7 @@ static bool pack_header(THD *thd, uchar *forminfo,
length=field->pack_length;
if ((uint) field->offset+ (uint) data_offset+ length > reclength)
reclength=(uint) (field->offset+ data_offset + length);
- n_length+= (ulong) strlen(field->field_name)+1;
+ n_length+= (ulong) field->name().length() + 1;
field->interval_id=0;
field->save_interval= 0;
if (field->interval)
@@ -713,7 +713,7 @@ static size_t packed_fields_length(List<Create_field> &create_fields)
FRM_VCOL_HEADER_SIZE(field->interval);
}
length+= FCOMP;
- length+= strlen(field->field_name)+1;
+ length+= field->name().length() + 1;
length+= field->comment.length;
}
length++;
@@ -785,7 +785,7 @@ static bool pack_fields(uchar *buff, List<Create_field> &create_fields,
it.rewind();
while ((field=it++))
{
- buff= (uchar*)strmov((char*) buff, field->field_name);
+ buff= (uchar*)strmov((char*) buff, field->name().ptr());
*buff++=NAMES_SEP_CHAR;
}
*buff++= 0;
@@ -934,7 +934,7 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options,
field->unireg_check,
field->save_interval ? field->save_interval :
field->interval,
- field->field_name);
+ field->name());
if (!regfield)
{
error= 1;
@@ -961,7 +961,7 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options,
/* If not ok or warning of level 'note' */
if (res != 0 && res != 3)
{
- my_error(ER_INVALID_DEFAULT, MYF(0), regfield->field_name);
+ my_error(ER_INVALID_DEFAULT, MYF(0), regfield->name().ptr());
error= 1;
delete regfield; //To avoid memory leak
goto err;
diff --git a/storage/cassandra/ha_cassandra.cc b/storage/cassandra/ha_cassandra.cc
index aa4a9bb..3fb8e11 100644
--- a/storage/cassandra/ha_cassandra.cc
+++ b/storage/cassandra/ha_cassandra.cc
@@ -411,7 +411,7 @@ int ha_cassandra::check_field_options(Field **fields)
{
if (dyncol_set || (*field)->type() != MYSQL_TYPE_BLOB)
{
- my_error(ER_WRONG_FIELD_SPEC, MYF(0), (*field)->field_name);
+ my_error(ER_WRONG_FIELD_SPEC, MYF(0), (*field)->name().ptr());
DBUG_RETURN(HA_WRONG_CREATE_OPTION);
}
dyncol_set= 1;
@@ -1497,14 +1497,14 @@ bool ha_cassandra::setup_field_converters(Field **field_arg, uint n_fields)
for (field= field_arg + 1, i= 1; *field; field++, i++)
{
if ((!dyncol_set || dyncol_field != i) &&
- !strcmp((*field)->field_name, col_name))
+ !strcmp((*field)->name().ptr(), col_name))
{
n_mapped++;
ColumnDataConverter **conv= field_converters + (*field)->field_index;
if (!(*conv= map_field_to_validator(*field, col_type)))
{
se->print_error("Failed to map column %s to datatype %s",
- (*field)->field_name, col_type);
+ (*field)->name().ptr(), col_type);
my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str());
DBUG_RETURN(true);
}
@@ -1543,7 +1543,7 @@ bool ha_cassandra::setup_field_converters(Field **field_arg, uint n_fields)
DBUG_ASSERT(first_unmapped);
se->print_error("Field `%s` could not be mapped to any field in Cassandra",
- first_unmapped->field_name);
+ first_unmapped->name().ptr());
my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str());
DBUG_RETURN(true);
}
@@ -1552,14 +1552,14 @@ bool ha_cassandra::setup_field_converters(Field **field_arg, uint n_fields)
Setup type conversion for row_key.
*/
se->get_rowkey_type(&col_name, &col_type);
- if (col_name && strcmp(col_name, (*field_arg)->field_name))
+ if (col_name && strcmp(col_name, (*field_arg)->name().ptr()))
{
se->print_error("PRIMARY KEY column must match Cassandra's name '%s'",
col_name);
my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str());
DBUG_RETURN(true);
}
- if (!col_name && strcmp("rowkey", (*field_arg)->field_name))
+ if (!col_name && strcmp("rowkey", (*field_arg)->name().ptr()))
{
se->print_error("target column family has no key_alias defined, "
"PRIMARY KEY column must be named 'rowkey'");
@@ -1742,14 +1742,14 @@ int ha_cassandra::read_cassandra_columns(bool unpack_pk)
{
uint fieldnr= (*field)->field_index;
if ((!dyncol_set || dyncol_field != fieldnr) &&
- !strcmp((*field)->field_name, cass_name))
+ !strcmp((*field)->name().ptr(), cass_name))
{
found= 1;
(*field)->set_notnull();
if (field_converters[fieldnr]->cassandra_to_mariadb(cass_value,
cass_value_len))
{
- print_conversion_error((*field)->field_name, cass_value,
+ print_conversion_error((*field)->name().ptr(), cass_value,
cass_value_len);
res=1;
goto err;
@@ -1770,7 +1770,7 @@ int ha_cassandra::read_cassandra_columns(bool unpack_pk)
se->print_error("Unable to convert value for field `%s`"
" from Cassandra's data format. Name"
" length exceed limit of %u: '%s'",
- table->field[dyncol_field]->field_name,
+ table->field[dyncol_field]->name().ptr(),
(uint)MAX_NAME_LENGTH, cass_name);
my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str());
res=1;
@@ -1782,7 +1782,7 @@ int ha_cassandra::read_cassandra_columns(bool unpack_pk)
se->print_error("Unable to convert value for field `%s`"
" from Cassandra's data format. Sum of all names"
" length exceed limit of %lu",
- table->field[dyncol_field]->field_name,
+ table->field[dyncol_field]->name().ptr(),
cass_name, (uint)MAX_TOTAL_NAME_LENGTH);
my_error(ER_INTERNAL_ERROR, MYF(0), se->error_str());
res=1;
@@ -1841,7 +1841,7 @@ int ha_cassandra::read_cassandra_columns(bool unpack_pk)
se->get_read_rowkey(&cass_value, &cass_value_len);
if (rowkey_converter->cassandra_to_mariadb(cass_value, cass_value_len))
{
- print_conversion_error((*field)->field_name, cass_value, cass_value_len);
+ print_conversion_error((*field)->name().ptr(), cass_value, cass_value_len);
res=1;
goto err;
}
@@ -1953,7 +1953,7 @@ int ha_cassandra::write_row(uchar *buf)
if (rowkey_converter->mariadb_to_cassandra(&cass_key, &cass_key_len))
{
my_error(ER_WARN_DATA_OUT_OF_RANGE, MYF(0),
- rowkey_converter->field->field_name, insert_lineno);
+ rowkey_converter->field->name().ptr(), insert_lineno);
dbug_tmp_restore_column_map(table->read_set, old_map);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
@@ -1987,11 +1987,11 @@ int ha_cassandra::write_row(uchar *buf)
&cass_data_len))
{
my_error(ER_WARN_DATA_OUT_OF_RANGE, MYF(0),
- field_converters[i]->field->field_name, insert_lineno);
+ field_converters[i]->field->name().ptr(), insert_lineno);
dbug_tmp_restore_column_map(table->read_set, old_map);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
- se->add_insert_column(field_converters[i]->field->field_name, 0,
+ se->add_insert_column(field_converters[i]->field->name().ptr(), 0,
cass_data, cass_data_len);
}
}
@@ -2074,7 +2074,7 @@ int ha_cassandra::rnd_init(bool scan)
{
se->clear_read_columns();
for (uint i= 1; i < table->s->fields; i++)
- se->add_read_column(table->field[i]->field_name);
+ se->add_read_column(table->field[i]->name().ptr());
}
se->read_batch_size= THDVAR(table->in_use, rnd_batch_size);
@@ -2355,7 +2355,7 @@ class Column_name_enumerator_impl : public Column_name_enumerator
if (idx == obj->table->s->fields)
return NULL;
else
- return obj->table->field[idx++]->field_name;
+ return obj->table->field[idx++]->name().ptr();
}
};
@@ -2386,7 +2386,7 @@ int ha_cassandra::update_row(const uchar *old_data, uchar *new_data)
if (rowkey_converter->mariadb_to_cassandra(&new_key, &new_key_len))
{
my_error(ER_WARN_DATA_OUT_OF_RANGE, MYF(0),
- rowkey_converter->field->field_name, insert_lineno);
+ rowkey_converter->field->name().ptr(), insert_lineno);
dbug_tmp_restore_column_map(table->read_set, old_map);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
@@ -2449,11 +2449,11 @@ int ha_cassandra::update_row(const uchar *old_data, uchar *new_data)
if (field_converters[i]->mariadb_to_cassandra(&cass_data, &cass_data_len))
{
my_error(ER_WARN_DATA_OUT_OF_RANGE, MYF(0),
- field_converters[i]->field->field_name, insert_lineno);
+ field_converters[i]->field->name().ptr(), insert_lineno);
dbug_tmp_restore_column_map(table->read_set, old_map);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
}
- se->add_insert_column(field_converters[i]->field->field_name, 0,
+ se->add_insert_column(field_converters[i]->field->name().ptr(), 0,
cass_data, cass_data_len);
}
}
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 926a77f..bef1639 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -1342,7 +1342,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
pcf->Flags= 0;
// Now get column information
- pcf->Name= (char*)fp->field_name;
+ pcf->Name= (char*)fp->name().ptr();
if (fop && fop->special) {
pcf->Fieldfmt= (char*)fop->special;
@@ -1539,7 +1539,7 @@ PIXDEF ha_connect::GetIndexInfo(TABLE_SHARE *s)
// Get the the key parts info
for (int k= 0; (unsigned)k < kp.user_defined_key_parts; k++) {
- pn= (char*)kp.key_part[k].field->field_name;
+ pn= (char*)kp.key_part[k].field->name().ptr();
name= PlugDup(g, pn);
// Allocate the key part description block
@@ -1655,7 +1655,7 @@ int ha_connect::GetColNameLen(Field *fp)
if (fop && fop->special)
n= strlen(fop->special) + 1;
else
- n= strlen(fp->field_name);
+ n= fp->name_length();
return n;
} // end of GetColNameLen
@@ -1667,7 +1667,7 @@ char *ha_connect::GetColName(Field *fp)
{
PFOS fop= GetFieldOptionStruct(fp);
- return (fop && fop->special) ? fop->special : (char*)fp->field_name;
+ return (fop && fop->special) ? fop->special : (char*)fp->name().ptr();
} // end of GetColName
/****************************************************************************/
@@ -1682,7 +1682,7 @@ void ha_connect::AddColName(char *cp, Field *fp)
// The prefix * mark the column as "special"
strcat(strcpy(cp, "*"), strupr(fop->special));
else
- strcpy(cp, (char*)fp->field_name);
+ strcpy(cp, (char*)fp->name().ptr());
} // end of AddColName
#endif // 0
@@ -1768,12 +1768,12 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
for (field= table->field; fp= *field; field++) {
if (bitmap_is_set(map, fp->field_index)) {
- n1+= (strlen(fp->field_name) + 1);
+ n1+= (fp->name().length() + 1);
k1++;
} // endif
if (ump && bitmap_is_set(ump, fp->field_index)) {
- n2+= (strlen(fp->field_name) + 1);
+ n2+= (fp->name().length() + 1);
k2++;
} // endif
@@ -1784,8 +1784,8 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
for (field= table->field; fp= *field; field++)
if (bitmap_is_set(map, fp->field_index)) {
- strcpy(p, (char*)fp->field_name);
- p+= (strlen(p) + 1);
+ strcpy(p, (char*)fp->name().ptr());
+ p+= (fp->name().length() + 1);
} // endif used field
*p= '\0'; // mark end of list
@@ -1796,7 +1796,7 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
for (field= table->field; fp= *field; field++)
if (bitmap_is_set(ump, fp->field_index)) {
- strcpy(p, (char*)fp->field_name);
+ strcpy(p, (char*)fp->name().ptr());
if (part_id && bitmap_is_set(part_id, fp->field_index)) {
// Trying to update a column used for partitioning
@@ -1861,9 +1861,9 @@ bool ha_connect::CheckColumnList(PGLOBAL g)
if ((rc= setjmp(g->jumper[++g->jump_level])) == 0) {
for (field= table->field; fp= *field; field++)
if (bitmap_is_set(map, fp->field_index)) {
- if (!(colp= tdbp->ColDB(g, (PSZ)fp->field_name, 0))) {
+ if (!(colp= tdbp->ColDB(g, (PSZ)fp->name().ptr(), 0))) {
sprintf(g->Message, "Column %s not found in %s",
- fp->field_name, tdbp->GetName());
+ fp->name().ptr(), tdbp->GetName());
brc= true;
goto fin;
} // endif colp
@@ -1953,14 +1953,14 @@ int ha_connect::MakeRecord(char *buf)
// This is a used field, fill the buffer with value
for (colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
if ((!mrr || colp->GetKcol()) &&
- !stricmp(colp->GetName(), (char*)fp->field_name))
+ !stricmp(colp->GetName(), (char*)fp->name().ptr()))
break;
if (!colp) {
if (mrr)
continue;
- htrc("Column %s not found\n", fp->field_name);
+ htrc("Column %s not found\n", fp->name().ptr());
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
DBUG_RETURN(HA_ERR_WRONG_IN_RECORD);
} // endif colp
@@ -2016,7 +2016,7 @@ int ha_connect::MakeRecord(char *buf)
sprintf(buf, "Out of range value %.140s for column '%s' at row %ld",
value->GetCharString(val),
- fp->field_name,
+ fp->name().ptr(),
thd->get_stmt_da()->current_row_for_warning());
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, buf);
@@ -2074,11 +2074,11 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *)
&& tdbp->GetAmType() != TYPE_AM_ODBC) ||
bitmap_is_set(table->write_set, fp->field_index)) {
for (colp= tp->GetSetCols(); colp; colp= colp->GetNext())
- if (!stricmp(colp->GetName(), fp->field_name))
+ if (!stricmp(colp->GetName(), fp->name().ptr()))
break;
if (!colp) {
- htrc("Column %s not found\n", fp->field_name);
+ htrc("Column %s not found\n", fp->name().ptr());
rc= HA_ERR_WRONG_IN_RECORD;
goto err;
} else
@@ -2270,10 +2270,10 @@ bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
if (q) {
oom|= qry->Append(q);
- oom|= qry->Append((PSZ)fp->field_name);
+ oom|= qry->Append((PSZ)fp->name().ptr());
oom|= qry->Append(q);
} else
- oom|= qry->Append((PSZ)fp->field_name);
+ oom|= qry->Append((PSZ)fp->name().ptr());
switch (ranges[i]->flag) {
case HA_READ_KEY_EXACT:
@@ -2530,7 +2530,7 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond)
return NULL;
if (pField->field->table != table ||
- !(colp[i]= tdbp->ColDB(g, (PSZ)pField->field->field_name, 0)))
+ !(colp[i]= tdbp->ColDB(g, (PSZ)pField->field->name().ptr(), 0)))
return NULL; // Column does not belong to this table
// These types are not yet implemented (buggy)
@@ -2548,7 +2548,7 @@ PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond)
if (trace) {
htrc("Field index=%d\n", pField->field->field_index);
- htrc("Field name=%s\n", pField->field->field_name);
+ htrc("Field name=%s\n", pField->field->name().ptr());
} // endif trace
} else {
@@ -2760,11 +2760,11 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
} else if (tty == TYPE_AM_TBL)
return NULL;
else
- fnm= pField->field->field_name;
+ fnm= pField->field->name().ptr();
if (trace) {
htrc("Field index=%d\n", pField->field->field_index);
- htrc("Field name=%s\n", pField->field->field_name);
+ htrc("Field name=%s\n", pField->field->name().ptr());
htrc("Field type=%d\n", pField->field->type());
htrc("Field_type=%d\n", args[i]->field_type());
} // endif trace
@@ -5991,7 +5991,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (fp->flags & (BLOB_FLAG | ENUM_FLAG | SET_FLAG)) {
sprintf(g->Message, "Unsupported type for column %s",
- fp->field_name);
+ fp->name().ptr());
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR;
DBUG_RETURN(rc);
@@ -6027,11 +6027,11 @@ int ha_connect::create(const char *name, TABLE *table_arg,
case MYSQL_TYPE_STRING:
if (!fp->field_length) {
sprintf(g->Message, "Unsupported 0 length for column %s",
- fp->field_name);
+ fp->name().ptr());
rc= HA_ERR_INTERNAL_ERROR;
my_printf_error(ER_UNKNOWN_ERROR,
"Unsupported 0 length for column %s",
- MYF(0), fp->field_name);
+ MYF(0), fp->name().ptr());
DBUG_RETURN(rc);
} // endif fp
@@ -6046,12 +6046,12 @@ int ha_connect::create(const char *name, TABLE *table_arg,
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_GEOMETRY:
default:
-// fprintf(stderr, "Unsupported type column %s\n", fp->field_name);
+// fprintf(stderr, "Unsupported type column %s\n", fp->name().ptr());
sprintf(g->Message, "Unsupported type for column %s",
- fp->field_name);
+ fp->name().ptr());
rc= HA_ERR_INTERNAL_ERROR;
my_printf_error(ER_UNKNOWN_ERROR, "Unsupported type for column %s",
- MYF(0), fp->field_name);
+ MYF(0), fp->name().ptr());
DBUG_RETURN(rc);
break;
} // endswitch type
@@ -6066,12 +6066,12 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (dbf) {
bool b= false;
- if ((b= strlen(fp->field_name) > 10))
+ if ((b= fp->name().length() > 10))
sprintf(g->Message, "DBF: Column name '%s' is too long (max=10)",
- fp->field_name);
+ fp->name().ptr());
else if ((b= fp->field_length > 255))
sprintf(g->Message, "DBF: Column length too big for '%s' (max=255)",
- fp->field_name);
+ fp->name().ptr());
if (b) {
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp
index 331a7f4..f4f2ccf 100644
--- a/storage/connect/tabutil.cpp
+++ b/storage/connect/tabutil.cpp
@@ -171,7 +171,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
// Get column name
crp = qrp->Colresp; // Column_Name
- colname = (char *)fp->field_name;
+ colname = (char *)fp->name().ptr();
crp->Kdata->SetValue(colname, i);
chset = (char *)fp->charset()->name;
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index 3a5b269..91f87e4 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -896,7 +896,7 @@ int ha_example::create(const char *name, TABLE *table_arg,
ha_field_option_struct *field_options= (*field)->option_struct;
DBUG_ASSERT(field_options);
DBUG_PRINT("info", ("field: %s complex: '%-.64s'",
- (*field)->field_name,
+ (*field)->name().ptr(),
(field_options->complex_param_to_parse_it_in_engine ?
field_options->complex_param_to_parse_it_in_engine :
"<NULL>")));
@@ -975,7 +975,7 @@ ha_example::check_if_supported_inplace_alter(TABLE* altered_table,
{
push_warning_printf(ha_thd(), Sql_condition::WARN_LEVEL_NOTE,
ER_UNKNOWN_ERROR, "EXAMPLE DEBUG: Field %`s COMPLEX '%s' -> '%s'",
- table->s->field[i]->field_name,
+ table->s->field[i]->name().ptr(),
f_old->complex_param_to_parse_it_in_engine,
f_new->complex_param_to_parse_it_in_engine);
}
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index e75c3ca..20143c49 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -579,6 +579,12 @@ static bool append_ident(String *string, const char *name, size_t length,
}
+bool append_ident(String *string, const Name &name, const char quote)
+{
+ return append_ident(string, name.ptr(), name.length(), quote);
+}
+
+
static int parse_url_error(FEDERATED_SHARE *share, TABLE *table, int error_num)
{
char buf[FEDERATED_QUERY_BUFFER_SIZE];
@@ -973,8 +979,7 @@ uint ha_federated::convert_row_to_internal_format(uchar *record,
static bool emit_key_part_name(String *to, KEY_PART_INFO *part)
{
DBUG_ENTER("emit_key_part_name");
- if (append_ident(to, part->field->field_name,
- strlen(part->field->field_name), ident_quote_char))
+ if (append_ident(to, part->field->name(), ident_quote_char))
DBUG_RETURN(1); // Out of memory
DBUG_RETURN(0);
}
@@ -1535,8 +1540,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table)
query.append(STRING_WITH_LEN("SELECT "));
for (field= table->field; *field; field++)
{
- append_ident(&query, (*field)->field_name,
- strlen((*field)->field_name), ident_quote_char);
+ append_ident(&query, (*field)->name(), ident_quote_char);
query.append(STRING_WITH_LEN(", "));
}
/* chops off trailing comma */
@@ -1767,8 +1771,7 @@ bool ha_federated::append_stmt_insert(String *query)
if (bitmap_is_set(table->write_set, (*field)->field_index))
{
/* append the field name */
- append_ident(&insert_string, (*field)->field_name,
- strlen((*field)->field_name), ident_quote_char);
+ append_ident(&insert_string, (*field)->name(), ident_quote_char);
/* append commas between both fields and fieldnames */
/*
@@ -2181,9 +2184,7 @@ int ha_federated::update_row(const uchar *old_data, uchar *new_data)
{
if (bitmap_is_set(table->write_set, (*field)->field_index))
{
- size_t field_name_length= strlen((*field)->field_name);
- append_ident(&update_string, (*field)->field_name, field_name_length,
- ident_quote_char);
+ append_ident(&update_string, (*field)->name(), ident_quote_char);
update_string.append(STRING_WITH_LEN(" = "));
if ((*field)->is_null())
@@ -2207,9 +2208,7 @@ int ha_federated::update_row(const uchar *old_data, uchar *new_data)
if (bitmap_is_set(table->read_set, (*field)->field_index))
{
- size_t field_name_length= strlen((*field)->field_name);
- append_ident(&where_string, (*field)->field_name, field_name_length,
- ident_quote_char);
+ append_ident(&where_string, (*field)->name(), ident_quote_char);
if (field_in_record_is_null(table, *field, (char*) old_data))
where_string.append(STRING_WITH_LEN(" IS NULL "));
else
@@ -2290,8 +2289,7 @@ int ha_federated::delete_row(const uchar *buf)
found++;
if (bitmap_is_set(table->read_set, cur_field->field_index))
{
- append_ident(&delete_string, (*field)->field_name,
- strlen((*field)->field_name), ident_quote_char);
+ append_ident(&delete_string, (*field)->name(), ident_quote_char);
data_string.length(0);
if (cur_field->is_null())
{
diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc
index 28b9b33..6566721 100644
--- a/storage/federatedx/ha_federatedx.cc
+++ b/storage/federatedx/ha_federatedx.cc
@@ -518,6 +518,12 @@ bool append_ident(String *string, const char *name, uint length,
}
+bool append_ident(String *string, const Name &name, const char quote)
+{
+ return append_ident(string, name.ptr(), name.length(), quote);
+}
+
+
static int parse_url_error(FEDERATEDX_SHARE *share, TABLE_SHARE *table_s,
int error_num)
{
@@ -894,8 +900,7 @@ uint ha_federatedx::convert_row_to_internal_format(uchar *record,
static bool emit_key_part_name(String *to, KEY_PART_INFO *part)
{
DBUG_ENTER("emit_key_part_name");
- if (append_ident(to, part->field->field_name,
- strlen(part->field->field_name), ident_quote_char))
+ if (append_ident(to, part->field->name(), ident_quote_char))
DBUG_RETURN(1); // Out of memory
DBUG_RETURN(0);
}
@@ -1597,8 +1602,7 @@ static FEDERATEDX_SHARE *get_share(const char *table_name, TABLE *table)
query.append(STRING_WITH_LEN("SELECT "));
for (field= table->field; *field; field++)
{
- append_ident(&query, (*field)->field_name,
- strlen((*field)->field_name), ident_quote_char);
+ append_ident(&query, (*field)->name(), ident_quote_char);
query.append(STRING_WITH_LEN(", "));
}
/* chops off trailing comma */
@@ -1911,8 +1915,7 @@ bool ha_federatedx::append_stmt_insert(String *query)
if (bitmap_is_set(table->write_set, (*field)->field_index))
{
/* append the field name */
- append_ident(&insert_string, (*field)->field_name,
- strlen((*field)->field_name), ident_quote_char);
+ append_ident(&insert_string, (*field)->name(), ident_quote_char);
/* append commas between both fields and fieldnames */
/*
@@ -2339,9 +2342,7 @@ int ha_federatedx::update_row(const uchar *old_data, uchar *new_data)
{
if (bitmap_is_set(table->write_set, (*field)->field_index))
{
- uint field_name_length= strlen((*field)->field_name);
- append_ident(&update_string, (*field)->field_name, field_name_length,
- ident_quote_char);
+ append_ident(&update_string, (*field)->name(), ident_quote_char);
update_string.append(STRING_WITH_LEN(" = "));
if ((*field)->is_null())
@@ -2365,9 +2366,7 @@ int ha_federatedx::update_row(const uchar *old_data, uchar *new_data)
if (bitmap_is_set(table->read_set, (*field)->field_index))
{
- uint field_name_length= strlen((*field)->field_name);
- append_ident(&where_string, (*field)->field_name, field_name_length,
- ident_quote_char);
+ append_ident(&where_string, (*field)->name(), ident_quote_char);
if (field_in_record_is_null(table, *field, (char*) old_data))
where_string.append(STRING_WITH_LEN(" IS NULL "));
else
@@ -2452,8 +2451,7 @@ int ha_federatedx::delete_row(const uchar *buf)
found++;
if (bitmap_is_set(table->read_set, cur_field->field_index))
{
- append_ident(&delete_string, (*field)->field_name,
- strlen((*field)->field_name), ident_quote_char);
+ append_ident(&delete_string, (*field)->name(), ident_quote_char);
data_string.length(0);
if (cur_field->is_null())
{
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index daa649a..cbdda04 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -5384,7 +5384,7 @@ ha_innobase::innobase_initialize_autoinc()
ut_a(prebuilt->trx == thd_to_trx(user_thd));
- col_name = field->field_name;
+ col_name = field->name().ptr();
index = innobase_get_index(table->s->next_number_index);
/* Execute SELECT MAX(col_name) FROM TABLE; */
@@ -8212,7 +8212,7 @@ calc_row_difference(
if (field_mysql_type == MYSQL_TYPE_LONGLONG
&& prebuilt->table->fts
&& innobase_strcasecmp(
- field->field_name, FTS_DOC_ID_COL_NAME) == 0) {
+ field->name().ptr(), FTS_DOC_ID_COL_NAME) == 0) {
doc_id = (doc_id_t) mach_read_from_n_little_endian(
n_ptr, 8);
if (doc_id == 0) {
@@ -10360,7 +10360,7 @@ create_table_check_doc_id_col(
col_len = field->pack_length();
- if (innobase_strcasecmp(field->field_name,
+ if (innobase_strcasecmp(field->name().ptr(),
FTS_DOC_ID_COL_NAME) == 0) {
/* Note the name is case sensitive due to
@@ -10368,7 +10368,7 @@ create_table_check_doc_id_col(
if (col_type == DATA_INT
&& !field->real_maybe_null()
&& col_len == sizeof(doc_id_t)
- && (strcmp(field->field_name,
+ && (strcmp(field->name().ptr(),
FTS_DOC_ID_COL_NAME) == 0)) {
*doc_id_col = i;
} else {
@@ -10380,7 +10380,7 @@ create_table_check_doc_id_col(
"of BIGINT NOT NULL type, and named "
"in all capitalized characters");
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
- field->field_name);
+ field->name().ptr());
*doc_id_col = ULINT_UNDEFINED;
}
@@ -10525,7 +10525,7 @@ create_table_def(
"column type and try to re-create "
"the table with an appropriate "
"column type.",
- table->name, field->field_name);
+ table->name, field->name().ptr());
goto err_col;
}
@@ -10575,9 +10575,9 @@ create_table_def(
/* First check whether the column to be added has a
system reserved name. */
- if (dict_col_name_is_reserved(field->field_name)){
+ if (dict_col_name_is_reserved(field->name().ptr())){
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
- field->field_name);
+ field->name().ptr());
err_col:
dict_mem_table_free(table);
mem_heap_free(heap);
@@ -10588,7 +10588,7 @@ create_table_def(
}
dict_mem_table_add_col(table, heap,
- field->field_name,
+ field->name().ptr(),
col_type,
dtype_form_prtype(
(ulint) field->type()
@@ -10666,7 +10666,7 @@ create_index(
for (ulint i = 0; i < key->user_defined_key_parts; i++) {
KEY_PART_INFO* key_part = key->key_part + i;
dict_mem_index_add_field(
- index, key_part->field->field_name, 0);
+ index, key_part->field->name().ptr(), 0);
}
DBUG_RETURN(convert_error_code_to_mysql(
@@ -10717,8 +10717,8 @@ create_index(
field = form->field[j];
if (0 == innobase_strcasecmp(
- field->field_name,
- key_part->field->field_name)) {
+ field->name().ptr(),
+ key_part->field->name().ptr())) {
/* Found the corresponding column */
goto found;
@@ -10751,7 +10751,7 @@ create_index(
"inappropriate data type. Table "
"name %s, column name %s.",
table_name,
- key_part->field->field_name);
+ key_part->field->name().ptr());
prefix_len = 0;
}
@@ -10762,7 +10762,7 @@ create_index(
field_lengths[i] = key_part->length;
dict_mem_index_add_field(
- index, key_part->field->field_name, prefix_len);
+ index, key_part->field->name().ptr(), prefix_len);
}
ut_ad(key->flags & HA_FULLTEXT || !(index->type & DICT_FTS));
@@ -11240,7 +11240,7 @@ innobase_table_flags(
/* Do a pre-check on FTS DOC ID index */
if (!(key->flags & HA_NOSAME)
|| strcmp(key->name, FTS_DOC_ID_INDEX_NAME)
- || strcmp(key->key_part[0].field->field_name,
+ || strcmp(key->key_part[0].field->name().ptr(),
FTS_DOC_ID_COL_NAME)) {
fts_doc_id_index_bad = key->name;
}
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index ae082b2..3b1362a 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -479,7 +479,7 @@ ha_innobase::check_if_supported_inplace_alter(
&& innobase_fulltext_exist(altered_table)
&& !my_strcasecmp(
system_charset_info,
- key_part->field->field_name,
+ key_part->field->name().ptr(),
FTS_DOC_ID_COL_NAME)) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_HIDDEN_FTS);
@@ -536,7 +536,7 @@ ha_innobase::check_if_supported_inplace_alter(
if (!my_strcasecmp(
system_charset_info,
- (*fp)->field_name,
+ (*fp)->name().ptr(),
FTS_DOC_ID_COL_NAME)) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_CHANGE_FTS);
@@ -805,7 +805,7 @@ innobase_find_equiv_index(
}
if (innobase_strcasecmp(col_names[j],
- key_part.field->field_name)) {
+ key_part.field->name().ptr())) {
/* Name mismatch */
goto no_match;
}
@@ -928,7 +928,7 @@ innobase_get_foreign_key_info(
/* Get all the foreign key column info for the
current table */
while ((column = key_part_iterator++)) {
- column_names[i] = column->field_name.str;
+ column_names[i] = column->name().ptr();
ut_ad(i < MAX_NUM_FK_COLUMNS);
i++;
}
@@ -1029,7 +1029,7 @@ innobase_get_foreign_key_info(
while ((column = key_part_iterator++)) {
referenced_column_names[i] =
- column->field_name.str;
+ column->name().ptr();
ut_ad(i < MAX_NUM_FK_COLUMNS);
i++;
}
@@ -1463,7 +1463,7 @@ innobase_check_index_keys(
}
my_error(ER_WRONG_KEY_COLUMN, MYF(0), "InnoDB",
- field->field_name);
+ field->name().ptr());
return(ER_WRONG_KEY_COLUMN);
}
@@ -1479,7 +1479,7 @@ innobase_check_index_keys(
}
my_error(ER_WRONG_KEY_COLUMN, MYF(0), "InnoDB",
- field->field_name);
+ field->name().ptr());
return(ER_WRONG_KEY_COLUMN);
}
}
@@ -1518,7 +1518,7 @@ innobase_create_index_field_def(
ut_a(field);
index_field->col_no = key_part->fieldnr;
- index_field->col_name = altered_table ? field->field_name : fields[key_part->fieldnr]->field_name;
+ index_field->col_name = altered_table ? field->name().ptr() : fields[key_part->fieldnr]->name().ptr();
col_type = get_innobase_type_from_mysql_type(&is_unsigned, field);
@@ -1641,19 +1641,19 @@ innobase_fts_check_doc_id_col(
stored_in_db()))
sql_idx++;
if (my_strcasecmp(system_charset_info,
- field->field_name, FTS_DOC_ID_COL_NAME)) {
+ field->name().ptr(), FTS_DOC_ID_COL_NAME)) {
continue;
}
- if (strcmp(field->field_name, FTS_DOC_ID_COL_NAME)) {
+ if (strcmp(field->name().ptr(), FTS_DOC_ID_COL_NAME)) {
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
- field->field_name);
+ field->name().ptr());
} else if (field->type() != MYSQL_TYPE_LONGLONG
|| field->pack_length() != 8
|| field->real_maybe_null()
|| !(field->flags & UNSIGNED_FLAG)) {
my_error(ER_INNODB_FT_WRONG_DOCID_COLUMN, MYF(0),
- field->field_name);
+ field->name().ptr());
} else {
*fts_doc_col_no = i;
}
@@ -1724,7 +1724,7 @@ innobase_fts_check_doc_id_index(
if ((key.flags & HA_NOSAME)
&& key.user_defined_key_parts == 1
&& !strcmp(key.name, FTS_DOC_ID_INDEX_NAME)
- && !strcmp(key.key_part[0].field->field_name,
+ && !strcmp(key.key_part[0].field->name().ptr(),
FTS_DOC_ID_COL_NAME)) {
if (fts_doc_col_no) {
*fts_doc_col_no = ULINT_UNDEFINED;
@@ -1803,7 +1803,7 @@ innobase_fts_check_doc_id_index_in_def(
if (!(key->flags & HA_NOSAME)
|| key->user_defined_key_parts != 1
|| strcmp(key->name, FTS_DOC_ID_INDEX_NAME)
- || strcmp(key->key_part[0].field->field_name,
+ || strcmp(key->key_part[0].field->name().ptr(),
FTS_DOC_ID_COL_NAME)) {
return(FTS_INCORRECT_DOC_ID_INDEX);
}
@@ -2415,7 +2415,7 @@ innobase_check_foreigns(
if (!new_field || (new_field->flags & NOT_NULL_FLAG)) {
if (innobase_check_foreigns_low(
user_table, drop_fk, n_drop_fk,
- (*fp)->field_name, !new_field)) {
+ (*fp)->name().ptr(), !new_field)) {
return(true);
}
}
@@ -2642,7 +2642,7 @@ innobase_get_col_names(
for (uint old_i = 0; table->field[old_i]; old_i++) {
if (new_field->field == table->field[old_i]) {
- cols[old_i] = new_field->field_name;
+ cols[old_i] = new_field->name().ptr();
break;
}
}
@@ -2920,7 +2920,7 @@ prepare_inplace_alter_table_dict(
dict_mem_table_free(
ctx->new_table);
my_error(ER_WRONG_KEY_COLUMN, MYF(0),
- field->field_name);
+ field->name().ptr());
goto new_clustered_failed;
}
} else {
@@ -2947,16 +2947,16 @@ prepare_inplace_alter_table_dict(
}
}
- if (dict_col_name_is_reserved(field->field_name)) {
+ if (dict_col_name_is_reserved(field->name().ptr())) {
dict_mem_table_free(ctx->new_table);
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
- field->field_name);
+ field->name().ptr());
goto new_clustered_failed;
}
dict_mem_table_add_col(
ctx->new_table, ctx->heap,
- field->field_name,
+ field->name().ptr(),
col_type,
dtype_form_prtype(field_type, charset_no),
col_len);
@@ -3546,7 +3546,7 @@ ha_innobase::prepare_inplace_alter_table(
cf_it.rewind();
while (Create_field* cf = cf_it++) {
if (cf->field == *fp) {
- name = cf->field_name;
+ name = cf->name().ptr();
goto check_if_ok_to_rename;
}
}
@@ -3556,7 +3556,7 @@ ha_innobase::prepare_inplace_alter_table(
/* Prohibit renaming a column from FTS_DOC_ID
if full-text indexes exist. */
if (!my_strcasecmp(system_charset_info,
- (*fp)->field_name,
+ (*fp)->name().ptr(),
FTS_DOC_ID_COL_NAME)
&& innobase_fulltext_exist(altered_table)) {
my_error(ER_INNODB_FT_WRONG_DOCID_COLUMN,
@@ -4697,8 +4697,8 @@ innobase_rename_columns_try(
if (cf->field == *fp) {
if (innobase_rename_column_try(
ctx->old_table, trx, table_name, i,
- cf->field->field_name,
- cf->field_name,
+ cf->field->name().ptr(),
+ cf->name().ptr(),
ctx->need_rebuild())) {
return(true);
}
@@ -4745,8 +4745,8 @@ innobase_rename_columns_cache(
while (Create_field* cf = cf_it++) {
if (cf->field == *fp) {
dict_mem_table_col_rename(user_table, i,
- cf->field->field_name,
- cf->field_name);
+ cf->field->name().ptr(),
+ cf->name().ptr());
goto processed_field;
}
}
@@ -4806,7 +4806,7 @@ commit_get_autoinc(
dict_table_autoinc_lock(ctx->old_table);
err = row_search_max_autoinc(
- index, autoinc_field->field_name, &max_value_table);
+ index, autoinc_field->name().ptr(), &max_value_table);
if (err != DB_SUCCESS) {
ut_ad(0);
diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp
index 9266d2d..c2be5aa 100644
--- a/storage/mroonga/ha_mroonga.cpp
+++ b/storage/mroonga/ha_mroonga.cpp
@@ -3213,7 +3213,7 @@ int ha_mroonga::storage_create(const char *name, TABLE *table,
int key_parts = KEY_N_KEY_PARTS(key_info);
if (key_parts == 1) {
Field *pkey_field = key_info->key_part[0].field;
- const char *column_name = pkey_field->field_name;
+ const char *column_name = pkey_field->name().ptr();
is_id = (strcmp(MRN_COLUMN_NAME_ID, column_name) == 0);
grn_builtin_type gtype = mrn_grn_type_from_field(ctx, pkey_field, false);
@@ -3307,8 +3307,8 @@ int ha_mroonga::storage_create(const char *name, TABLE *table,
uint n_columns = table->s->fields;
for (uint i = 0; i < n_columns; i++) {
Field *field = table->s->field[i];
- const char *column_name = field->field_name;
- int column_name_size = strlen(column_name);
+ const char *column_name = field->name().ptr();
+ int column_name_size = field->name().length();
if (strcmp(MRN_COLUMN_NAME_ID, column_name) == 0) {
continue;
@@ -3374,7 +3374,7 @@ int ha_mroonga::storage_create_validate_pseudo_column(TABLE *table)
n_columns = table->s->fields;
for (i = 0; i < n_columns; i++) {
Field *field = table->s->field[i];
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
if (strcmp(MRN_COLUMN_NAME_ID, column_name) == 0) {
switch (field->type()) {
case MYSQL_TYPE_TINY :
@@ -3422,18 +3422,18 @@ bool ha_mroonga::storage_create_foreign_key(TABLE *table,
}
List_iterator<Key_part_spec> key_part_col_iterator(key->columns);
Key_part_spec *key_part_col = key_part_col_iterator++;
- LEX_STRING field_name = key_part_col->field_name;
- DBUG_PRINT("info", ("mroonga: field_name=%s", field_name.str));
- DBUG_PRINT("info", ("mroonga: field->field_name=%s", field->field_name));
- if (strcmp(field->field_name, field_name.str))
+ Name field_name= key_part_col->name();
+ DBUG_PRINT("info", ("mroonga: field_name.ptr()=%s", field_name.ptr()));
+ DBUG_PRINT("info", ("mroonga: field->name().ptr()=%s", field->name().ptr()));
+ if (strcmp(field->name().ptr(), field_name.ptr()))
{
continue;
}
Foreign_key *fk = (Foreign_key *) key;
List_iterator<Key_part_spec> key_part_ref_col_iterator(fk->ref_columns);
Key_part_spec *key_part_ref_col = key_part_ref_col_iterator++;
- LEX_STRING ref_field_name = key_part_ref_col->field_name;
- DBUG_PRINT("info", ("mroonga: ref_field_name=%s", ref_field_name.str));
+ Name ref_field_name = key_part_ref_col->name();
+ DBUG_PRINT("info", ("mroonga: ref_field_name.ptr()=%s", ref_field_name.ptr()));
#ifdef MRN_FOREIGN_KEY_USE_CONST_STRING
LEX_CSTRING ref_db_name = fk->ref_db;
#else
@@ -3537,7 +3537,7 @@ bool ha_mroonga::storage_create_foreign_key(TABLE *table,
DBUG_RETURN(false);
}
Field *ref_field = &ref_key_info->key_part->field[0];
- if (strcmp(ref_field->field_name, ref_field_name.str)) {
+ if (strcmp(ref_field->name().ptr(), ref_field_name.ptr())) {
mrn_open_mutex_lock(table->s);
mrn_free_tmp_table_share(tmp_ref_table_share);
mrn_open_mutex_unlock(table->s);
@@ -3546,7 +3546,7 @@ bool ha_mroonga::storage_create_foreign_key(TABLE *table,
char err_msg[MRN_BUFFER_SIZE];
sprintf(err_msg,
"refference column [%s.%s.%s] is not used for primary key",
- table->s->db.str, ref_table_name.str, ref_field_name.str);
+ table->s->db.str, ref_table_name.str, ref_field_name.ptr());
my_message(error, err_msg, MYF(0));
DBUG_RETURN(false);
}
@@ -3554,8 +3554,8 @@ bool ha_mroonga::storage_create_foreign_key(TABLE *table,
mrn_free_tmp_table_share(tmp_ref_table_share);
mrn_open_mutex_unlock(table->s);
grn_obj_flags col_flags = GRN_OBJ_PERSISTENT;
- column = grn_column_create(ctx, table_obj, field->field_name,
- strlen(field->field_name),
+ column = grn_column_create(ctx, table_obj, field->name().ptr(),
+ field->name().length(),
NULL, col_flags, grn_table_ref);
if (ctx->rc) {
grn_obj_unlink(ctx, grn_table_ref);
@@ -3564,7 +3564,7 @@ bool ha_mroonga::storage_create_foreign_key(TABLE *table,
DBUG_RETURN(false);
}
- mrn::IndexColumnName index_column_name(grn_table_name, field->field_name);
+ mrn::IndexColumnName index_column_name(grn_table_name, field->name().ptr());
grn_obj_flags ref_col_flags = GRN_OBJ_COLUMN_INDEX | GRN_OBJ_PERSISTENT;
column_ref = grn_column_create(ctx, grn_table_ref,
index_column_name.c_str(),
@@ -3618,7 +3618,7 @@ int ha_mroonga::storage_create_validate_index(TABLE *table)
continue;
}
Field *field = key_info->key_part[0].field;
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
if (strcmp(MRN_COLUMN_NAME_ID, column_name) == 0) {
if (key_info->algorithm == HA_KEY_ALG_HASH) {
continue; // hash index is ok
@@ -3755,8 +3755,8 @@ int ha_mroonga::storage_create_index(TABLE *table, const char *grn_table_name,
bool is_multiple_column_index = KEY_N_KEY_PARTS(key_info) > 1;
if (!is_multiple_column_index) {
Field *field = key_info->key_part[0].field;
- column_name = field->field_name;
- column_name_size = strlen(column_name);
+ column_name = field->name().ptr();
+ column_name_size = field->name().length();
if (strcmp(MRN_COLUMN_NAME_ID, column_name) == 0) {
// skipping _id virtual column
DBUG_RETURN(0);
@@ -3813,8 +3813,8 @@ int ha_mroonga::storage_create_index(TABLE *table, const char *grn_table_name,
int j, n_key_parts = KEY_N_KEY_PARTS(key_info);
for (j = 0; j < n_key_parts; j++) {
Field *field = key_info->key_part[j].field;
- const char *column_name = field->field_name;
- int column_name_size = strlen(column_name);
+ const char *column_name = field->name().ptr();
+ int column_name_size = field->name().length();
grn_obj *source_column = grn_obj_column(ctx, grn_table,
column_name, column_name_size);
grn_id source_id = grn_obj_id(ctx, source_column);
@@ -4113,8 +4113,8 @@ int ha_mroonga::wrapper_open_indexes(const char *name)
/* just for backward compatibility before 1.0. */
Field *field = key_info->key_part[0].field;
grn_index_columns[i] = grn_obj_column(ctx, grn_index_tables[i],
- field->field_name,
- strlen(field->field_name));
+ field->name().ptr(),
+ field->name().length());
}
if (ctx->rc) {
@@ -4291,8 +4291,8 @@ int ha_mroonga::storage_open_columns(void)
for (int i = 0; i < n_columns; i++) {
Field *field = table->field[i];
- const char *column_name = field->field_name;
- int column_name_size = strlen(column_name);
+ const char *column_name = field->name().ptr();
+ int column_name_size = field->name().length();
if (table_share->blob_fields)
{
blob_buffers[i].set_charset(field->charset());
@@ -4406,8 +4406,8 @@ int ha_mroonga::storage_open_indexes(const char *name)
/* just for backward compatibility before 1.0. */
Field *field = key_info->key_part[0].field;
grn_index_columns[i] = grn_obj_column(ctx, grn_index_tables[i],
- field->field_name,
- strlen(field->field_name));
+ field->name().ptr(),
+ field->name().length());
}
}
}
@@ -5398,7 +5398,7 @@ int ha_mroonga::storage_write_row(uchar *buf)
mrn::DebugColumnAccess debug_column_access(table, table->read_set);
for (i = 0; i < n_columns; i++) {
Field *field = table->field[i];
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
if (field->is_null()) continue;
@@ -5492,7 +5492,7 @@ int ha_mroonga::storage_write_row(uchar *buf)
GRN_VOID_INIT(&colbuf);
for (i = 0; i < n_columns; i++) {
Field *field = table->field[i];
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
if (field->is_null())
continue;
@@ -6004,7 +6004,7 @@ int ha_mroonga::storage_update_row(const uchar *old_data, uchar *new_data)
for (i = 0; i < n_columns; i++) {
Field *field = table->field[i];
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
if (bitmap_is_set(table->write_set, field->field_index)) {
if (field->is_null()) continue;
@@ -6041,7 +6041,7 @@ int ha_mroonga::storage_update_row(const uchar *old_data, uchar *new_data)
GRN_VOID_INIT(&colbuf);
for (i = 0; i < n_columns; i++) {
Field *field = table->field[i];
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
if (bitmap_is_set(table->write_set, field->field_index)) {
mrn::DebugColumnAccess debug_column_access(table, table->read_set);
DBUG_PRINT("info", ("mroonga: update column %d(%d)",i,field->field_index));
@@ -6062,7 +6062,7 @@ int ha_mroonga::storage_update_row(const uchar *old_data, uchar *new_data)
bool have_pkey = false;
for (j = 0; j < KEY_N_KEY_PARTS(pkey_info); j++) {
Field *pkey_field = pkey_info->key_part[j].field;
- if (strcmp(pkey_field->field_name, column_name) == 0) {
+ if (strcmp(pkey_field->name().ptr(), column_name) == 0) {
if (!replacing_) {
char message[MRN_BUFFER_SIZE];
snprintf(message, MRN_BUFFER_SIZE,
@@ -6731,7 +6731,7 @@ ha_rows ha_mroonga::storage_records_in_range(uint key_nr, key_range *range_min,
DBUG_RETURN(row_count);
} else {
Field *field = key_info->key_part[0].field;
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
mrn_change_encoding(ctx, field->charset());
if (strcmp(MRN_COLUMN_NAME_ID, column_name) == 0) {
@@ -7023,7 +7023,7 @@ int ha_mroonga::storage_index_read_map(uchar *buf, const uchar *key,
DBUG_RETURN(error);
if (find_flag == HA_READ_KEY_EXACT) {
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
key_min = key_min_entity;
key_max = key_min_entity;
@@ -7575,7 +7575,7 @@ int ha_mroonga::storage_read_range_first(const key_range *start_key,
}
} else {
Field *field = key_info->key_part[0].field;
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
error = mrn_change_encoding(ctx, field->charset());
if (error)
DBUG_RETURN(error);
@@ -9105,7 +9105,7 @@ grn_obj *ha_mroonga::find_column_type(Field *field, MRN_SHARE *mrn_share, int i,
char error_message[MRN_BUFFER_SIZE];
snprintf(error_message, MRN_BUFFER_SIZE,
"unknown custom Groonga type name for <%s> column: <%s>",
- field->field_name, grn_type_name);
+ field->name().ptr(), grn_type_name);
GRN_LOG(ctx, GRN_LOG_ERROR, "%s", error_message);
my_message(error_code, error_message, MYF(0));
@@ -9783,8 +9783,8 @@ bool ha_mroonga::is_primary_key_field(Field *field) const
DBUG_RETURN(false);
}
- if (strcmp(field->field_name,
- key_info->key_part[0].field->field_name) == 0) {
+ if (strcmp(field->name().ptr(),
+ key_info->key_part[0].field->name().ptr()) == 0) {
DBUG_RETURN(true);
} else {
DBUG_RETURN(false);
@@ -9887,8 +9887,8 @@ void ha_mroonga::check_fast_order_limit(grn_table_sort_key **sort_keys,
if (item->type() == Item::FIELD_ITEM)
{
Field *field = static_cast<Item_field *>(item)->field;
- const char *column_name = field->field_name;
- int column_name_size = strlen(column_name);
+ const char *column_name = field->name().ptr();
+ int column_name_size = field->name().length();
if (should_normalize(field))
{
@@ -10981,11 +10981,11 @@ void ha_mroonga::storage_store_fields(uchar *buf, grn_id record_id)
if (bitmap_is_set(table->read_set, field->field_index) ||
bitmap_is_set(table->write_set, field->field_index)) {
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
if (ignoring_no_key_columns) {
KEY *key_info = &(table->s->key_info[active_index]);
- if (strcmp(key_info->key_part[0].field->field_name, column_name)) {
+ if (strcmp(key_info->key_part[0].field->name().ptr(), column_name)) {
continue;
}
}
@@ -10998,7 +10998,7 @@ void ha_mroonga::storage_store_fields(uchar *buf, grn_id record_id)
field->set_notnull();
field->store((int)record_id);
} else if (primary_key_field &&
- strcmp(primary_key_field->field_name, column_name) == 0) {
+ strcmp(primary_key_field->name().ptr(), column_name) == 0) {
// for primary key column
storage_store_field_column(field, true, i, record_id);
} else {
@@ -11461,7 +11461,7 @@ int ha_mroonga::storage_encode_key_set(Field *field, const uchar *key,
MRN_DBUG_ENTER_METHOD();
int error = 0;
Field_set unpacker((uchar *)key, field->field_length, (uchar *)(key - 1),
- field->null_bit, field->unireg_check, field->field_name,
+ field->null_bit, field->unireg_check, field->name(),
field->pack_length(),
static_cast<Field_set*>(field)->typelib,
static_cast<Field_set*>(field)->charset());
@@ -12896,7 +12896,7 @@ int ha_mroonga::storage_rename_foreign_key(MRN_SHARE *tmp_share,
MRN_DBUG_ENTER_METHOD();
for (i = 0; i < n_columns; ++i) {
Field *field = tmp_table_share->field[i];
- const char *column_name = field->field_name;
+ const char *column_name = field->name().ptr();
uint column_name_size = strlen(column_name);
if (strcmp(MRN_COLUMN_NAME_ID, column_name) == 0) {
@@ -14563,8 +14563,8 @@ bool ha_mroonga::storage_inplace_alter_table_add_column(
}
Field *field = altered_table->s->field[i];
- const char *column_name = field->field_name;
- int column_name_size = strlen(column_name);
+ const char *column_name = field->name().ptr();
+ int column_name_size = field->name().length();
int error = mrn_add_column_param(tmp_share, field, i);
if (error) {
@@ -14644,8 +14644,8 @@ bool ha_mroonga::storage_inplace_alter_table_drop_column(
continue;
}
- const char *column_name = field->field_name;
- int column_name_size = strlen(column_name);
+ const char *column_name = field->name().ptr();
+ int column_name_size = field->name().length();
grn_obj *column_obj;
column_obj = grn_obj_column(ctx, table_obj, column_name, column_name_size);
@@ -14689,7 +14689,7 @@ bool ha_mroonga::storage_inplace_alter_table_rename_column(
List_iterator_fast<Create_field> create_fields(alter_info->create_list);
while (Create_field *create_field = create_fields++) {
if (create_field->field == field) {
- new_name = create_field->field_name;
+ new_name = create_field->name().ptr();
break;
}
}
@@ -14698,7 +14698,7 @@ bool ha_mroonga::storage_inplace_alter_table_rename_column(
continue;
}
- const char *old_name = field->field_name;
+ const char *old_name = field->name().ptr();
grn_obj *column_obj;
column_obj = grn_obj_column(ctx, table_obj, old_name, strlen(old_name));
if (column_obj) {
@@ -15871,8 +15871,8 @@ char *ha_mroonga::storage_get_foreign_key_create_info()
create_info_str.length(0);
for (i = 0; i < n_columns; ++i) {
Field *field = table_share->field[i];
- const char *column_name = field->field_name;
- uint column_name_size = strlen(column_name);
+ const char *column_name = field->name().ptr();
+ uint column_name_size = field->name().length();
if (strcmp(MRN_COLUMN_NAME_ID, column_name) == 0) {
continue;
@@ -15946,8 +15946,8 @@ char *ha_mroonga::storage_get_foreign_key_create_info()
uint ref_pkey_nr = tmp_ref_table_share->primary_key;
KEY *ref_key_info = &tmp_ref_table_share->key_info[ref_pkey_nr];
Field *ref_field = &ref_key_info->key_part->field[0];
- append_identifier(ha_thd(), &create_info_str, ref_field->field_name,
- strlen(ref_field->field_name));
+ append_identifier(ha_thd(), &create_info_str, ref_field->name().ptr(),
+ ref_field->name().length());
mrn_open_mutex_lock(table_share);
mrn_free_tmp_table_share(tmp_ref_table_share);
mrn_open_mutex_unlock(table_share);
@@ -16078,8 +16078,8 @@ int ha_mroonga::storage_get_foreign_key_list(THD *thd,
MRN_DBUG_ENTER_METHOD();
for (i = 0; i < n_columns; ++i) {
Field *field = table_share->field[i];
- const char *column_name = field->field_name;
- uint column_name_size = strlen(column_name);
+ const char *column_name = field->name().ptr();
+ uint column_name_size = field->name().length();
if (strcmp(MRN_COLUMN_NAME_ID, column_name) == 0) {
continue;
@@ -16153,8 +16153,8 @@ int ha_mroonga::storage_get_foreign_key_list(THD *thd,
KEY *ref_key_info = &tmp_ref_table_share->key_info[ref_pkey_nr];
Field *ref_field = &ref_key_info->key_part->field[0];
LEX_STRING *ref_col_name = thd_make_lex_string(thd, NULL,
- ref_field->field_name,
- strlen(ref_field->field_name),
+ ref_field->name().ptr(),
+ ref_field->name().length(),
TRUE);
f_key_info.referenced_fields.push_back(ref_col_name);
mrn_open_mutex_lock(table_share);
diff --git a/storage/mroonga/lib/mrn_multiple_column_key_codec.cpp b/storage/mroonga/lib/mrn_multiple_column_key_codec.cpp
index c7ef9dd..fcdd059 100644
--- a/storage/mroonga/lib/mrn_multiple_column_key_codec.cpp
+++ b/storage/mroonga/lib/mrn_multiple_column_key_codec.cpp
@@ -678,7 +678,7 @@ namespace mrn {
"data: <%.*s>",
normalized_length,
UINT_MAX16,
- field->field_name,
+ field->name().ptr(),
blob_data_length, blob_data);
memcpy(grn_key, normalized, blob_data_length);
new_blob_data_length = blob_data_length;
diff --git a/storage/sequence/sequence.cc b/storage/sequence/sequence.cc
index 7b20615..efcadce 100644
--- a/storage/sequence/sequence.cc
+++ b/storage/sequence/sequence.cc
@@ -418,7 +418,7 @@ create_group_by_handler(THD *thd, Query *query)
if (field->table != query->from->table)
return 0;
/* Check that we are using a SUM() on the primary key */
- if (strcmp(field->field_name, "seq"))
+ if (strcmp(field->name().ptr(), "seq"))
return 0;
}
diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc
index 568d369..2206822 100644
--- a/storage/sphinx/ha_sphinx.cc
+++ b/storage/sphinx/ha_sphinx.cc
@@ -1027,7 +1027,7 @@ static bool ParseUrl ( CSphSEShare * share, TABLE * table, bool bCreate )
for ( int i=0; i<share->m_iTableFields; i++ )
{
- share->m_sTableField[i] = sphDup ( table->field[i]->field_name );
+ share->m_sTableField[i] = sphDup ( table->field[i]->name().ptr() );
share->m_eTableFieldType[i] = table->field[i]->type();
}
}
@@ -2321,7 +2321,7 @@ int ha_sphinx::write_row ( byte * )
for ( Field ** ppField = table->field; *ppField; ppField++ )
{
- sQuery.append ( (*ppField)->field_name );
+ sQuery.append ( (*ppField)->name().ptr() );
if ( ppField[1] )
sQuery.append ( ", " );
}
@@ -3417,7 +3417,7 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * )
if ( eType!=MYSQL_TYPE_TIMESTAMP && !IsIntegerFieldType(eType) && eType!=MYSQL_TYPE_VARCHAR && eType!=MYSQL_TYPE_FLOAT )
{
my_snprintf ( sError, sizeof(sError), "%s: %dth column (attribute %s) MUST be integer, bigint, timestamp, varchar, or float",
- name, i+1, table->field[i]->field_name );
+ name, i+1, table->field[i]->name().ptr() );
break;
}
}
@@ -3429,10 +3429,10 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * )
if (
table->s->keys!=1 ||
table->key_info[0].user_defined_key_parts!=1 ||
- strcasecmp ( table->key_info[0].key_part[0].field->field_name, table->field[2]->field_name ) )
+ strcasecmp ( table->key_info[0].key_part[0].field->name().ptr(), table->field[2]->name().ptr() ) )
{
my_snprintf ( sError, sizeof(sError), "%s: there must be an index on '%s' column",
- name, table->field[2]->field_name );
+ name, table->field[2]->name().ptr() );
break;
}
@@ -3447,7 +3447,7 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * )
sError[0] = '\0';
// check that 1st column is id, is of int type, and has an index
- if ( strcmp ( table->field[0]->field_name, "id" ) )
+ if ( strcmp ( table->field[0]->name().ptr(), "id" ) )
{
my_snprintf ( sError, sizeof(sError), "%s: 1st column must be called 'id'", name );
break;
@@ -3463,7 +3463,7 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * )
if (
table->s->keys!=1 ||
table->key_info[0].user_defined_key_parts!=1 ||
- strcasecmp ( table->key_info[0].key_part[0].field->field_name, "id" ) )
+ strcasecmp ( table->key_info[0].key_part[0].field->name().ptr(), "id" ) )
{
my_snprintf ( sError, sizeof(sError), "%s: 'id' column must be indexed", name );
break;
@@ -3476,7 +3476,7 @@ int ha_sphinx::create ( const char * name, TABLE * table, HA_CREATE_INFO * )
if ( eType!=MYSQL_TYPE_TIMESTAMP && !IsIntegerFieldType(eType) && eType!=MYSQL_TYPE_VARCHAR && eType!=MYSQL_TYPE_FLOAT )
{
my_snprintf ( sError, sizeof(sError), "%s: column %d(%s) is of unsupported type (use int/bigint/timestamp/varchar/float)",
- name, i+1, table->field[i]->field_name );
+ name, i+1, table->field[i]->name().ptr() );
break;
}
}
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index b4602e5..a5028c7 100644
--- a/storage/spider/ha_spider.cc
+++ b/storage/spider/ha_spider.cc
@@ -7711,7 +7711,7 @@ int ha_spider::cmp_ref(
) {
if ((ret = (*field)->cmp_binary_offset(ptr_diff)))
{
- DBUG_PRINT("info",("spider different at %s", (*field)->field_name));
+ DBUG_PRINT("info",("spider different at %s", (*field)->name().ptr()));
break;
}
}
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index 30ad38e..0f69cbe 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -2774,7 +2774,7 @@ int spider_db_fetch_row(
) {
int error_num;
DBUG_ENTER("spider_db_fetch_row");
- DBUG_PRINT("info", ("spider field_name %s", field->field_name));
+ DBUG_PRINT("info", ("spider field_name %s", field->name().ptr()));
DBUG_PRINT("info", ("spider fieldcharset %s", field->charset()->csname));
field->move_field_offset(ptr_diff);
error_num = row->store_to_field(field, share->access_charset);
@@ -2897,7 +2897,7 @@ int spider_db_fetch_table(
my_bitmap_map *tmp_map =
dbug_tmp_use_all_columns(table, table->write_set);
#endif
- DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->field_name));
+ DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->name().ptr()));
if ((error_num =
spider_db_fetch_row(share, *field, row, ptr_diff)))
DBUG_RETURN(error_num);
@@ -3068,7 +3068,7 @@ int spider_db_fetch_key(
my_bitmap_map *tmp_map =
dbug_tmp_use_all_columns(table, table->write_set);
#endif
- DBUG_PRINT("info", ("spider bitmap is set %s", field->field_name));
+ DBUG_PRINT("info", ("spider bitmap is set %s", field->name().ptr()));
if ((error_num =
spider_db_fetch_row(share, field, row, ptr_diff)))
DBUG_RETURN(error_num);
@@ -3182,7 +3182,7 @@ int spider_db_fetch_minimum_columns(
my_bitmap_map *tmp_map =
dbug_tmp_use_all_columns(table, table->write_set);
#endif
- DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->field_name));
+ DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->name().ptr()));
if ((error_num = spider_db_fetch_row(share, *field, row, ptr_diff)))
DBUG_RETURN(error_num);
#ifndef DBUG_OFF
@@ -5035,7 +5035,7 @@ int spider_db_seek_tmp_table(
my_bitmap_map *tmp_map =
dbug_tmp_use_all_columns(table, table->write_set);
#endif
- DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->field_name));
+ DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->name().ptr()));
if ((error_num =
spider_db_fetch_row(spider->share, *field, row, ptr_diff)))
DBUG_RETURN(error_num);
@@ -5122,7 +5122,7 @@ int spider_db_seek_tmp_key(
my_bitmap_map *tmp_map =
dbug_tmp_use_all_columns(table, table->write_set);
#endif
- DBUG_PRINT("info", ("spider bitmap is set %s", field->field_name));
+ DBUG_PRINT("info", ("spider bitmap is set %s", field->name().ptr()));
if ((error_num =
spider_db_fetch_row(spider->share, field, row, ptr_diff)))
DBUG_RETURN(error_num);
@@ -5212,7 +5212,7 @@ int spider_db_seek_tmp_minimum_columns(
my_bitmap_map *tmp_map =
dbug_tmp_use_all_columns(table, table->write_set);
#endif
- DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->field_name));
+ DBUG_PRINT("info", ("spider bitmap is set %s", (*field)->name().ptr()));
if ((error_num =
spider_db_fetch_row(spider->share, *field, row, ptr_diff)))
DBUG_RETURN(error_num);
@@ -5224,7 +5224,7 @@ int spider_db_seek_tmp_minimum_columns(
else if (bitmap_is_set(table->read_set, (*field)->field_index))
{
DBUG_PRINT("info", ("spider bitmap is cleared %s",
- (*field)->field_name));
+ (*field)->name().ptr()));
bitmap_clear_bit(table->read_set, (*field)->field_index);
}
}
@@ -9474,7 +9474,7 @@ int spider_db_udf_copy_key_row(
int error_num;
DBUG_ENTER("spider_db_udf_copy_key_row");
if ((error_num = spider_db_append_name_with_quote_str(str,
- (char *) field->field_name, dbton_id)))
+ (char *) field->name().ptr(), dbton_id)))
DBUG_RETURN(error_num);
if (str->reserve(joint_length + *length + SPIDER_SQL_AND_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index 92f9525..1101eed 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -4415,7 +4415,7 @@ int spider_mysql_share::create_column_name_str()
str->init_calc_mem(89);
str->set_charset(spider_share->access_charset);
if ((error_num = spider_db_append_name_with_quote_str(str,
- (char *) (*field)->field_name, dbton_id)))
+ (char *) (*field)->name().ptr(), dbton_id)))
goto error;
}
DBUG_RETURN(0);
@@ -11731,7 +11731,7 @@ int spider_mysql_copy_table::append_table_columns(
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN);
if ((error_num = spider_db_append_name_with_quote_str(&sql,
- (char *) (*field)->field_name, spider_dbton_mysql.dbton_id)))
+ (char *) (*field)->name().ptr(), spider_dbton_mysql.dbton_id)))
DBUG_RETURN(error_num);
if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + SPIDER_SQL_COMMA_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -11860,7 +11860,7 @@ int spider_mysql_copy_table::append_key_order_str(
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN);
if ((error_num = spider_db_append_name_with_quote_str(&sql,
- (char *) field->field_name, spider_dbton_mysql.dbton_id)))
+ (char *) field->name().ptr(), spider_dbton_mysql.dbton_id)))
DBUG_RETURN(error_num);
if (key_part->key_part_flag & HA_REVERSE_SORT)
{
@@ -11890,7 +11890,7 @@ int spider_mysql_copy_table::append_key_order_str(
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN);
if ((error_num = spider_db_append_name_with_quote_str(&sql,
- (char *) field->field_name, spider_dbton_mysql.dbton_id)))
+ (char *) field->name().ptr(), spider_dbton_mysql.dbton_id)))
DBUG_RETURN(error_num);
if (key_part->key_part_flag & HA_REVERSE_SORT)
{
@@ -12020,7 +12020,7 @@ int spider_mysql_copy_table::copy_key_row(
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
sql.q_append(SPIDER_SQL_NAME_QUOTE_STR, SPIDER_SQL_NAME_QUOTE_LEN);
if ((error_num = spider_db_append_name_with_quote_str(&sql,
- (char *) field->field_name, spider_dbton_mysql.dbton_id)))
+ (char *) field->name().ptr(), spider_dbton_mysql.dbton_id)))
DBUG_RETURN(error_num);
if (sql.reserve(SPIDER_SQL_NAME_QUOTE_LEN + joint_length + *length +
SPIDER_SQL_AND_LEN))
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 4aa5457..48a54e6 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -5867,7 +5867,7 @@ ha_innobase::innobase_initialize_autoinc()
ut_a(prebuilt->trx == thd_to_trx(user_thd));
- col_name = field->field_name;
+ col_name = field->name().ptr();
index = innobase_get_index(table->s->next_number_index);
/* Execute SELECT MAX(col_name) FROM TABLE; */
@@ -8727,7 +8727,7 @@ calc_row_difference(
if (field_mysql_type == MYSQL_TYPE_LONGLONG
&& prebuilt->table->fts
&& innobase_strcasecmp(
- field->field_name, FTS_DOC_ID_COL_NAME) == 0) {
+ field->name().ptr(), FTS_DOC_ID_COL_NAME) == 0) {
doc_id = (doc_id_t) mach_read_from_n_little_endian(
n_ptr, 8);
if (doc_id == 0) {
@@ -10921,7 +10921,7 @@ create_table_check_doc_id_col(
col_len = field->pack_length();
- if (innobase_strcasecmp(field->field_name,
+ if (innobase_strcasecmp(field->name().ptr(),
FTS_DOC_ID_COL_NAME) == 0) {
/* Note the name is case sensitive due to
@@ -10929,7 +10929,7 @@ create_table_check_doc_id_col(
if (col_type == DATA_INT
&& !field->real_maybe_null()
&& col_len == sizeof(doc_id_t)
- && (strcmp(field->field_name,
+ && (strcmp(field->name().ptr(),
FTS_DOC_ID_COL_NAME) == 0)) {
*doc_id_col = i;
} else {
@@ -10941,7 +10941,7 @@ create_table_check_doc_id_col(
"of BIGINT NOT NULL type, and named "
"in all capitalized characters");
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
- field->field_name);
+ field->name().ptr());
*doc_id_col = ULINT_UNDEFINED;
}
@@ -11087,7 +11087,7 @@ create_table_def(
"column type and try to re-create "
"the table with an appropriate "
"column type.",
- table->name, field->field_name);
+ table->name, field->name().ptr());
goto err_col;
}
@@ -11137,9 +11137,9 @@ create_table_def(
/* First check whether the column to be added has a
system reserved name. */
- if (dict_col_name_is_reserved(field->field_name)){
+ if (dict_col_name_is_reserved(field->name().ptr())){
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
- field->field_name);
+ field->name().ptr());
err_col:
dict_mem_table_free(table);
mem_heap_free(heap);
@@ -11150,7 +11150,7 @@ create_table_def(
}
dict_mem_table_add_col(table, heap,
- field->field_name,
+ field->name().ptr(),
col_type,
dtype_form_prtype(
(ulint) field->type()
@@ -11228,7 +11228,7 @@ create_index(
for (ulint i = 0; i < key->user_defined_key_parts; i++) {
KEY_PART_INFO* key_part = key->key_part + i;
dict_mem_index_add_field(
- index, key_part->field->field_name, 0);
+ index, key_part->field->name().ptr(), 0);
}
DBUG_RETURN(convert_error_code_to_mysql(
@@ -11279,8 +11279,8 @@ create_index(
field = form->field[j];
if (0 == innobase_strcasecmp(
- field->field_name,
- key_part->field->field_name)) {
+ field->name().ptr(),
+ key_part->field->name().ptr())) {
/* Found the corresponding column */
goto found;
@@ -11313,7 +11313,7 @@ create_index(
"inappropriate data type. Table "
"name %s, column name %s.",
table_name,
- key_part->field->field_name);
+ key_part->field->name().ptr());
prefix_len = 0;
}
@@ -11324,7 +11324,7 @@ create_index(
field_lengths[i] = key_part->length;
dict_mem_index_add_field(
- index, key_part->field->field_name, prefix_len);
+ index, key_part->field->name().ptr(), prefix_len);
}
ut_ad(key->flags & HA_FULLTEXT || !(index->type & DICT_FTS));
@@ -11799,7 +11799,7 @@ innobase_table_flags(
/* Do a pre-check on FTS DOC ID index */
if (!(key->flags & HA_NOSAME)
|| strcmp(key->name, FTS_DOC_ID_INDEX_NAME)
- || strcmp(key->key_part[0].field->field_name,
+ || strcmp(key->key_part[0].field->name().ptr(),
FTS_DOC_ID_COL_NAME)) {
fts_doc_id_index_bad = key->name;
}
diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc
index 2f89bf7..9cefdf3 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -484,7 +484,7 @@ ha_innobase::check_if_supported_inplace_alter(
&& innobase_fulltext_exist(altered_table)
&& !my_strcasecmp(
system_charset_info,
- key_part->field->field_name,
+ key_part->field->name().ptr(),
FTS_DOC_ID_COL_NAME)) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_HIDDEN_FTS);
@@ -541,7 +541,7 @@ ha_innobase::check_if_supported_inplace_alter(
if (!my_strcasecmp(
system_charset_info,
- (*fp)->field_name,
+ (*fp)->name().ptr(),
FTS_DOC_ID_COL_NAME)) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_CHANGE_FTS);
@@ -810,7 +810,7 @@ innobase_find_equiv_index(
}
if (innobase_strcasecmp(col_names[j],
- key_part.field->field_name)) {
+ key_part.field->name().ptr())) {
/* Name mismatch */
goto no_match;
}
@@ -932,7 +932,7 @@ innobase_get_foreign_key_info(
/* Get all the foreign key column info for the
current table */
while ((column = key_part_iterator++)) {
- column_names[i] = column->field_name.str;
+ column_names[i] = column->name().ptr();
ut_ad(i < MAX_NUM_FK_COLUMNS);
i++;
}
@@ -1033,7 +1033,7 @@ innobase_get_foreign_key_info(
while ((column = key_part_iterator++)) {
referenced_column_names[i] =
- column->field_name.str;
+ column->name().ptr();
ut_ad(i < MAX_NUM_FK_COLUMNS);
i++;
}
@@ -1466,7 +1466,7 @@ innobase_check_index_keys(
}
my_error(ER_WRONG_KEY_COLUMN, MYF(0), "InnoDB",
- field->field_name);
+ field->name().ptr());
return(ER_WRONG_KEY_COLUMN);
}
@@ -1482,7 +1482,7 @@ innobase_check_index_keys(
}
my_error(ER_WRONG_KEY_COLUMN, MYF(0), "InnoDB",
- field->field_name);
+ field->name().ptr());
return(ER_WRONG_KEY_COLUMN);
}
}
@@ -1521,7 +1521,7 @@ innobase_create_index_field_def(
ut_a(field);
index_field->col_no = key_part->fieldnr;
- index_field->col_name = altered_table ? field->field_name : fields[key_part->fieldnr]->field_name;
+ index_field->col_name = altered_table ? field->name().ptr() : fields[key_part->fieldnr]->name().ptr();
col_type = get_innobase_type_from_mysql_type(&is_unsigned, field);
@@ -1645,19 +1645,19 @@ innobase_fts_check_doc_id_col(
stored_in_db()))
sql_idx++;
if (my_strcasecmp(system_charset_info,
- field->field_name, FTS_DOC_ID_COL_NAME)) {
+ field->name().ptr(), FTS_DOC_ID_COL_NAME)) {
continue;
}
- if (strcmp(field->field_name, FTS_DOC_ID_COL_NAME)) {
+ if (strcmp(field->name().ptr(), FTS_DOC_ID_COL_NAME)) {
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
- field->field_name);
+ field->name().ptr());
} else if (field->type() != MYSQL_TYPE_LONGLONG
|| field->pack_length() != 8
|| field->real_maybe_null()
|| !(field->flags & UNSIGNED_FLAG)) {
my_error(ER_INNODB_FT_WRONG_DOCID_COLUMN, MYF(0),
- field->field_name);
+ field->name().ptr());
} else {
*fts_doc_col_no = i;
}
@@ -1728,7 +1728,7 @@ innobase_fts_check_doc_id_index(
if ((key.flags & HA_NOSAME)
&& key.user_defined_key_parts == 1
&& !strcmp(key.name, FTS_DOC_ID_INDEX_NAME)
- && !strcmp(key.key_part[0].field->field_name,
+ && !strcmp(key.key_part[0].field->name().ptr(),
FTS_DOC_ID_COL_NAME)) {
if (fts_doc_col_no) {
*fts_doc_col_no = ULINT_UNDEFINED;
@@ -1807,7 +1807,7 @@ innobase_fts_check_doc_id_index_in_def(
if (!(key->flags & HA_NOSAME)
|| key->user_defined_key_parts != 1
|| strcmp(key->name, FTS_DOC_ID_INDEX_NAME)
- || strcmp(key->key_part[0].field->field_name,
+ || strcmp(key->key_part[0].field->name().ptr(),
FTS_DOC_ID_COL_NAME)) {
return(FTS_INCORRECT_DOC_ID_INDEX);
}
@@ -2419,7 +2419,7 @@ innobase_check_foreigns(
if (!new_field || (new_field->flags & NOT_NULL_FLAG)) {
if (innobase_check_foreigns_low(
user_table, drop_fk, n_drop_fk,
- (*fp)->field_name, !new_field)) {
+ (*fp)->name().ptr(), !new_field)) {
return(true);
}
}
@@ -2646,7 +2646,7 @@ innobase_get_col_names(
for (uint old_i = 0; table->field[old_i]; old_i++) {
if (new_field->field == table->field[old_i]) {
- cols[old_i] = new_field->field_name;
+ cols[old_i] = new_field->name().ptr();
break;
}
}
@@ -2930,7 +2930,7 @@ prepare_inplace_alter_table_dict(
dict_mem_table_free(
ctx->new_table);
my_error(ER_WRONG_KEY_COLUMN, MYF(0),
- field->field_name);
+ field->name().ptr());
goto new_clustered_failed;
}
} else {
@@ -2957,16 +2957,16 @@ prepare_inplace_alter_table_dict(
}
}
- if (dict_col_name_is_reserved(field->field_name)) {
+ if (dict_col_name_is_reserved(field->name().ptr())) {
dict_mem_table_free(ctx->new_table);
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
- field->field_name);
+ field->name().ptr());
goto new_clustered_failed;
}
dict_mem_table_add_col(
ctx->new_table, ctx->heap,
- field->field_name,
+ field->name().ptr(),
col_type,
dtype_form_prtype(field_type, charset_no),
col_len);
@@ -3565,7 +3565,7 @@ ha_innobase::prepare_inplace_alter_table(
cf_it.rewind();
while (Create_field* cf = cf_it++) {
if (cf->field == *fp) {
- name = cf->field_name;
+ name = cf->name().ptr();
goto check_if_ok_to_rename;
}
}
@@ -3575,7 +3575,7 @@ ha_innobase::prepare_inplace_alter_table(
/* Prohibit renaming a column from FTS_DOC_ID
if full-text indexes exist. */
if (!my_strcasecmp(system_charset_info,
- (*fp)->field_name,
+ (*fp)->name().ptr(),
FTS_DOC_ID_COL_NAME)
&& innobase_fulltext_exist(altered_table)) {
my_error(ER_INNODB_FT_WRONG_DOCID_COLUMN,
@@ -4716,8 +4716,8 @@ innobase_rename_columns_try(
if (cf->field == *fp) {
if (innobase_rename_column_try(
ctx->old_table, trx, table_name, i,
- cf->field->field_name,
- cf->field_name,
+ cf->field->name().ptr(),
+ cf->name().ptr(),
ctx->need_rebuild())) {
return(true);
}
@@ -4764,8 +4764,8 @@ innobase_rename_columns_cache(
while (Create_field* cf = cf_it++) {
if (cf->field == *fp) {
dict_mem_table_col_rename(user_table, i,
- cf->field->field_name,
- cf->field_name);
+ cf->field->name().ptr(),
+ cf->name().ptr());
goto processed_field;
}
}
@@ -4825,7 +4825,7 @@ commit_get_autoinc(
dict_table_autoinc_lock(ctx->old_table);
err = row_search_max_autoinc(
- index, autoinc_field->field_name, &max_value_table);
+ index, autoinc_field->name().ptr(), &max_value_table);
if (err != DB_SUCCESS) {
ut_ad(0);
Follow ups