summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.cc13
-rw-r--r--sql/item_subselect.cc6
-rw-r--r--sql/log_event.cc7
-rw-r--r--sql/opt_range.cc18
-rw-r--r--sql/opt_subselect.cc4
-rw-r--r--sql/opt_subselect.h2
-rw-r--r--sql/sp_pcontext.cc2
-rw-r--r--sql/sql_explain.cc5
-rw-r--r--sql/sql_handler.cc2
-rw-r--r--sql/sql_select.cc14
-rw-r--r--sql/sql_show.cc19
-rw-r--r--sql/sql_statistics.cc4
-rw-r--r--sql/sql_table.cc41
-rw-r--r--sql/structs.h3
-rw-r--r--sql/table.cc13
-rw-r--r--sql/unireg.cc2
16 files changed, 85 insertions, 70 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 926551fdd60..dcaf08aa320 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3302,6 +3302,10 @@ void handler::ha_release_auto_increment()
@param msg Error message template to which key value should be
added.
@param errflag Flags for my_error() call.
+
+ @notes
+ The error message is from ER_DUP_ENTRY_WITH_KEY_NAME but to keep things compatibly
+ with old code, the error number is ER_DUP_ENTRY
*/
void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag)
@@ -3326,7 +3330,8 @@ void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag)
str.length(max_length-4);
str.append(STRING_WITH_LEN("..."));
}
- my_printf_error(ER_DUP_ENTRY, msg, errflag, str.c_ptr_safe(), key->name);
+ my_printf_error(ER_DUP_ENTRY, msg, errflag, str.c_ptr_safe(),
+ key->name.str);
}
}
@@ -3561,7 +3566,7 @@ void handler::print_error(int error, myf errflag)
const char *ptr= "???";
uint key_nr= get_dup_key(error);
if ((int) key_nr >= 0)
- ptr= table->key_info[key_nr].name;
+ ptr= table->key_info[key_nr].name.str;
my_error(ER_DROP_INDEX_FK, errflag, ptr);
DBUG_VOID_RETURN;
}
@@ -4637,7 +4642,7 @@ void handler::update_global_index_stats()
DBUG_ASSERT(key_info->cache_name);
if (!key_info->cache_name)
continue;
- key_length= table->s->table_cache_key.length + key_info->name_length + 1;
+ key_length= table->s->table_cache_key.length + key_info->name.length + 1;
mysql_mutex_lock(&LOCK_global_index_stats);
// Gets the global index stats, creating one if necessary.
if (!(index_stats= (INDEX_STATS*) my_hash_search(&global_index_stats,
@@ -6545,7 +6550,7 @@ end:
int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info)
{
INDEX_STATS *index_stats;
- uint key_length= table->s->table_cache_key.length + key_info->name_length + 1;
+ uint key_length= table->s->table_cache_key.length + key_info->name.length + 1;
int res = 0;
DBUG_ENTER("del_global_index_stat");
mysql_mutex_lock(&LOCK_global_index_stats);
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index cdcb5ed9421..011ccdfda40 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -4373,7 +4373,7 @@ void subselect_uniquesubquery_engine::print(String *str,
str->append(&tab->table->s->table_name);
KEY *key_info= tab->table->key_info+ tab->ref.key;
str->append(STRING_WITH_LEN(" on "));
- str->append(key_info->name);
+ str->append(&key_info->name);
if (cond)
{
str->append(STRING_WITH_LEN(" where "));
@@ -4396,7 +4396,7 @@ void subselect_uniquesubquery_engine::print(String *str)
str->append(STRING_WITH_LEN(" in "));
str->append(&tab->table->s->table_name);
str->append(STRING_WITH_LEN(" on "));
- str->append(key_info->name);
+ str->append(&key_info->name);
if (cond)
{
str->append(STRING_WITH_LEN(" where "));
@@ -4415,7 +4415,7 @@ void subselect_indexsubquery_engine::print(String *str,
str->append(tab->table->s->table_name.str, tab->table->s->table_name.length);
KEY *key_info= tab->table->key_info+ tab->ref.key;
str->append(STRING_WITH_LEN(" on "));
- str->append(key_info->name);
+ str->append(&key_info->name);
if (check_null)
str->append(STRING_WITH_LEN(" checking NULL"));
if (cond)
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 9b2e732d413..caec38a0554 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -4993,6 +4993,7 @@ bool test_if_equal_repl_errors(int expected_error, int actual_error)
return 1;
switch (expected_error) {
case ER_DUP_ENTRY:
+ case ER_DUP_ENTRY_WITH_KEY_NAME:
case ER_AUTOINC_READ_FAILED:
return (actual_error == ER_AUTOINC_READ_FAILED ||
actual_error == HA_ERR_AUTOINC_ERANGE);
@@ -12912,7 +12913,7 @@ int Rows_log_event::find_key()
*/
last_part= key->user_defined_key_parts - 1;
DBUG_PRINT("info", ("Index %s rec_per_key[%u]= %lu",
- key->name, last_part, key->rec_per_key[last_part]));
+ key->name.str, last_part, key->rec_per_key[last_part]));
if (!(m_table->file->index_flags(i, last_part, 1) & HA_READ_NEXT))
continue;
@@ -13099,10 +13100,10 @@ int Rows_log_event::find_row(rpl_group_info *rgi)
if (m_key_info)
{
DBUG_PRINT("info",("locating record using key #%u [%s] (index_read)",
- m_key_nr, m_key_info->name));
+ m_key_nr, m_key_info->name.str));
/* We use this to test that the correct key is used in test cases. */
DBUG_EXECUTE_IF("slave_crash_if_wrong_index",
- if(0 != strcmp(m_key_info->name,"expected_key")) abort(););
+ if(0 != strcmp(m_key_info->name.str,"expected_key")) abort(););
/* The key is active: search the table using the index */
if (!table->file->inited &&
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index e7164ab41fa..a8708baa3fa 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -6273,7 +6273,7 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info,
DBUG_ENTER("ror_intersect_add");
DBUG_PRINT("info", ("Current out_rows= %g", info->out_rows));
DBUG_PRINT("info", ("Adding scan on %s",
- info->param->table->key_info[ror_scan->keynr].name));
+ info->param->table->key_info[ror_scan->keynr].name.str));
DBUG_PRINT("info", ("is_cpk_scan: %d",is_cpk_scan));
selectivity_mult = ror_scan_selectivity(info, ror_scan);
@@ -6656,7 +6656,7 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
total_cost += (*ror_scan_mark)->index_read_cost;
records += (*ror_scan_mark)->records;
DBUG_PRINT("info", ("Adding scan on %s",
- param->table->key_info[(*ror_scan_mark)->keynr].name));
+ param->table->key_info[(*ror_scan_mark)->keynr].name.str));
if (total_cost > read_time)
DBUG_RETURN(NULL);
/* F=F-covered by first(I) */
@@ -6818,7 +6818,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree,
read_plan->mrr_buf_size= best_buf_size;
DBUG_PRINT("info",
("Returning range plan for key %s, cost %g, records %lu",
- param->table->key_info[param->real_keynr[best_idx]].name,
+ param->table->key_info[param->real_keynr[best_idx]].name.str,
read_plan->read_cost, (ulong) read_plan->records));
}
}
@@ -11830,7 +11830,7 @@ void QUICK_SELECT_I::add_key_name(String *str, bool *first)
*first= FALSE;
else
str->append(',');
- str->append(key_info->name);
+ str->append(&key_info->name);
}
@@ -11985,7 +11985,7 @@ void QUICK_SELECT_I::add_key_and_length(String *key_names,
key_names->append(',');
used_lengths->append(',');
}
- key_names->append(key_info->name);
+ key_names->append(&key_info->name);
length= longlong10_to_str(max_used_key_length, buf, 10) - buf;
used_lengths->append(buf, length);
}
@@ -14628,7 +14628,7 @@ static void print_sel_tree(PARAM *param, SEL_TREE *tree, key_map *tree_map,
uint keynr= param->real_keynr[idx];
if (tmp.length())
tmp.append(',');
- tmp.append(param->table->key_info[keynr].name);
+ tmp.append(&param->table->key_info[keynr].name);
}
}
if (!tmp.length())
@@ -14654,7 +14654,7 @@ static void print_ror_scans_arr(TABLE *table, const char *msg,
{
if (tmp.length())
tmp.append(',');
- tmp.append(table->key_info[(*start)->keynr].name);
+ tmp.append(&table->key_info[(*start)->keynr].name);
}
if (!tmp.length())
tmp.append(STRING_WITH_LEN("(empty)"));
@@ -14736,7 +14736,7 @@ void QUICK_RANGE_SELECT::dbug_dump(int indent, bool verbose)
{
/* purecov: begin inspected */
fprintf(DBUG_FILE, "%*squick range select, key %s, length: %d\n",
- indent, "", head->key_info[index].name, max_used_key_length);
+ indent, "", head->key_info[index].name.str, max_used_key_length);
if (verbose)
{
@@ -14840,7 +14840,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::dbug_dump(int indent, bool verbose)
{
fprintf(DBUG_FILE,
"%*squick_group_min_max_select: index %s (%d), length: %d\n",
- indent, "", index_info->name, index, max_used_key_length);
+ indent, "", index_info->name.str, index, max_used_key_length);
if (key_infix_len > 0)
{
fprintf(DBUG_FILE, "%*susing key_infix with length %d:\n",
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index a57bc44449d..fff951fb329 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -432,9 +432,9 @@ referred to, we can only generate equalities that refer to the outer (or inner)
tables. Note that this will disallow handling of cases like (CASE-FOR-SUBST).
Currently, solution #2 is implemented.
-
*/
+LEX_CSTRING weedout_key= {STRING_WITH_LEN("weedout_key")};
static
bool subquery_types_allow_materialization(Item_in_subselect *in_subs);
@@ -4242,7 +4242,7 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd)
keyinfo->key_length=0;
keyinfo->rec_per_key=0;
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
- keyinfo->name= (char*) "weedout_key";
+ keyinfo->name= weedout_key;
{
key_part_info->null_bit=0;
key_part_info->field= field;
diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h
index 7954becfad4..9cb19e0cc6c 100644
--- a/sql/opt_subselect.h
+++ b/sql/opt_subselect.h
@@ -298,7 +298,7 @@ public:
pos->table= tab;
// todo need ref_depend_map ?
DBUG_PRINT("info", ("Produced a LooseScan plan, key %s, %s",
- tab->table->key_info[best_loose_scan_key].name,
+ tab->table->key_info[best_loose_scan_key].name.str,
best_loose_scan_start_key? "(ref access)":
"(range/index access)"));
}
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
index f8193f8a9a7..87dfed2a8d3 100644
--- a/sql/sp_pcontext.cc
+++ b/sql/sp_pcontext.cc
@@ -416,6 +416,7 @@ static sp_condition_value
// Errors
cond_invalid_cursor(ER_SP_CURSOR_NOT_OPEN, "24000"),
cond_dup_val_on_index(ER_DUP_ENTRY, "23000"),
+ cond_dup_val_on_index2(ER_DUP_ENTRY_WITH_KEY_NAME, "23000"),
cond_too_many_rows(ER_TOO_MANY_ROWS, "42000");
@@ -426,6 +427,7 @@ static sp_condition sp_predefined_conditions[]=
// Errors
sp_condition(C_STRING_WITH_LEN("INVALID_CURSOR"), &cond_invalid_cursor),
sp_condition(C_STRING_WITH_LEN("DUP_VAL_ON_INDEX"), &cond_dup_val_on_index),
+ sp_condition(C_STRING_WITH_LEN("DUP_VAL_ON_INDEX"), &cond_dup_val_on_index2),
sp_condition(C_STRING_WITH_LEN("TOO_MANY_ROWS"), &cond_too_many_rows)
};
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 9fadbd2e6a3..05df9a21572 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1145,7 +1145,7 @@ void Explain_table_access::fill_key_len_str(String *key_len_str) const
void Explain_index_use::set(MEM_ROOT *mem_root, KEY *key, uint key_len_arg)
{
- set_pseudo_key(mem_root, key->name);
+ set_pseudo_key(mem_root, key->name.str);
key_len= key_len_arg;
uint len= 0;
for (uint i= 0; i < key->usable_key_parts; i++)
@@ -2450,7 +2450,8 @@ int Explain_range_checked_fer::append_possible_keys_stat(MEM_ROOT *alloc,
for (j= 0; j < table->s->keys; j++)
{
if (possible_keys.is_set(j))
- keys_stat_names[j]= key_set.append_str(alloc, table->key_info[j].name);
+ keys_stat_names[j]= key_set.append_str(alloc,
+ table->key_info[j].name.str);
else
keys_stat_names[j]= NULL;
}
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 4a12868979a..947c41e461e 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -571,7 +571,7 @@ mysql_ha_fix_cond_and_key(SQL_HANDLER *handler,
if (handler->keyno < 0 ||
my_strcasecmp(&my_charset_latin1,
keyname,
- table->s->key_info[handler->keyno].name))
+ table->s->key_info[handler->keyno].name.str))
{
if ((handler->keyno= find_type(keyname, &table->s->keynames,
FIND_TYPE_NO_PREFIX) - 1) < 0)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index e50b6a0820a..d44d2836790 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -80,6 +80,9 @@ const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
"index_merge", "hash_ALL", "hash_range",
"hash_index", "hash_index_merge" };
+LEX_CSTRING group_key= {STRING_WITH_LEN("group_key")};
+LEX_CSTRING distinct_key= {STRING_WITH_LEN("distinct_key")};
+
struct st_sargable_param;
static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array);
@@ -6277,7 +6280,7 @@ best_access_path(JOIN *join,
loose_scan_opt.next_ref_key();
DBUG_PRINT("info", ("Considering ref access on key %s",
- keyuse->table->key_info[keyuse->key].name));
+ keyuse->table->key_info[keyuse->key].name.str));
do /* For each keypart */
{
@@ -9389,7 +9392,8 @@ static bool create_hj_key_for_table(JOIN *join, JOIN_TAB *join_tab,
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
keyinfo->flags= HA_GENERATED_KEY;
keyinfo->is_statistics_from_stat_tables= FALSE;
- keyinfo->name= (char *) "$hj";
+ keyinfo->name.str= "$hj";
+ keyinfo->name.length= 3;
keyinfo->rec_per_key= (ulong*) thd->calloc(sizeof(ulong)*key_parts);
if (!keyinfo->rec_per_key)
DBUG_RETURN(TRUE);
@@ -17274,7 +17278,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
keyinfo->collected_stats= NULL;
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
keyinfo->is_statistics_from_stat_tables= FALSE;
- keyinfo->name= (char*) "group_key";
+ keyinfo->name= group_key;
ORDER *cur_group= group;
for (; cur_group ; cur_group= cur_group->next, key_part_info++)
{
@@ -17385,7 +17389,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields,
keyinfo->flags=HA_NOSAME | HA_NULL_ARE_EQUAL | HA_BINARY_PACK_KEY | HA_PACK_KEY;
keyinfo->ext_key_flags= keyinfo->flags;
keyinfo->key_length= 0; // Will compute the sum of the parts below.
- keyinfo->name= (char*) "distinct_key";
+ keyinfo->name= distinct_key;
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
keyinfo->is_statistics_from_stat_tables= FALSE;
keyinfo->read_stats= NULL;
@@ -24446,7 +24450,7 @@ int append_possible_keys(MEM_ROOT *alloc, String_list &list, TABLE *table,
for (j=0 ; j < table->s->keys ; j++)
{
if (possible_keys.is_set(j))
- list.append_str(alloc, table->key_info[j].name);
+ list.append_str(alloc, table->key_info[j].name.str);
}
return 0;
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 6d9f3f23138..68ded844938 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2169,7 +2169,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
bool found_primary=0;
packet->append(STRING_WITH_LEN(",\n "));
- if (i == primary_key && !strcmp(key_info->name, primary_key_name))
+ if (i == primary_key && !strcmp(key_info->name.str, primary_key_name))
{
found_primary=1;
/*
@@ -2188,7 +2188,7 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet,
packet->append(STRING_WITH_LEN("KEY "));
if (!found_primary)
- append_identifier(thd, packet, key_info->name, strlen(key_info->name));
+ append_identifier(thd, packet, key_info->name.str, key_info->name.length);
packet->append(STRING_WITH_LEN(" ("));
@@ -6235,7 +6235,7 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables,
table->field[3]->store((longlong) ((key_info->flags &
HA_NOSAME) ? 0 : 1), TRUE);
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[5]->store(key_info->name.str, key_info->name.length, cs);
table->field[6]->store((longlong) (j+1), TRUE);
str= (key_part->field ? &key_part->field->field_name :
&unknown);
@@ -6483,17 +6483,17 @@ static int get_schema_constraints_record(THD *thd, TABLE_LIST *tables,
if (i != primary_key && !(key_info->flags & HA_NOSAME))
continue;
- if (i == primary_key && !strcmp(key_info->name, primary_key_name))
+ if (i == primary_key && !strcmp(key_info->name.str, primary_key_name))
{
- if (store_constraints(thd, table, db_name, table_name, key_info->name,
- strlen(key_info->name),
+ if (store_constraints(thd, table, db_name, table_name,
+ key_info->name.str, key_info->name.length,
STRING_WITH_LEN("PRIMARY KEY")))
DBUG_RETURN(1);
}
else if (key_info->flags & HA_NOSAME)
{
- if (store_constraints(thd, table, db_name, table_name, key_info->name,
- strlen(key_info->name),
+ if (store_constraints(thd, table, db_name, table_name,
+ key_info->name.str, key_info->name.length,
STRING_WITH_LEN("UNIQUE")))
DBUG_RETURN(1);
}
@@ -6689,8 +6689,7 @@ static int get_schema_key_column_usage_record(THD *thd,
f_idx++;
restore_record(table, s->default_values);
store_key_column_usage(table, db_name, table_name,
- key_info->name,
- strlen(key_info->name),
+ key_info->name.str, key_info->name.length,
key_part->field->field_name.str,
key_part->field->field_name.length,
(longlong) f_idx);
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 3c22ad7172f..73cabf663db 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -1319,8 +1319,8 @@ public:
void set_index_prefix_key_fields(KEY *index_info)
{
set_full_table_name();
- const char *index_name= index_info->name;
- index_name_field->store(index_name, strlen(index_name),
+ const char *index_name= index_info->name.str;
+ index_name_field->store(index_name, index_info->name.length,
system_charset_info);
table_key_info= index_info;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 17df5d6dbde..7ed4d5d3fa4 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2764,9 +2764,9 @@ static int sort_keys(KEY *a, KEY *b)
/* Sort NOT NULL keys before other keys */
return (a_flags & HA_NULL_PART_KEY) ? 1 : -1;
}
- if (a->name == primary_key_name)
+ if (a->name.str == primary_key_name)
return -1;
- if (b->name == primary_key_name)
+ if (b->name.str == primary_key_name)
return 1;
/* Sort keys don't containing partial segments before others */
if ((a_flags ^ b_flags) & HA_KEY_HAS_PART_KEY_SEG)
@@ -3082,7 +3082,7 @@ static void check_duplicate_key(THD *thd, Key *key, KEY *key_info,
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_DUP_INDEX, ER_THD(thd, ER_DUP_INDEX),
- key_info->name);
+ key_info->name.str);
break;
}
}
@@ -3938,12 +3938,13 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
my_error(ER_DUP_KEYNAME, MYF(0), key_name);
DBUG_RETURN(TRUE);
}
- key_info->name=(char*) key_name;
+ key_info->name.str= (char*) key_name;
+ key_info->name.length= strlen(key_name);
}
}
- if (!key_info->name || check_column_name(key_info->name))
+ if (!key_info->name.str || check_column_name(key_info->name.str))
{
- my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key_info->name);
+ my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key_info->name.str);
DBUG_RETURN(TRUE);
}
if (key->type == Key::UNIQUE && !(key_info->flags & HA_NULL_PART_KEY))
@@ -3958,7 +3959,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
if (validate_comment_length(thd, &key->key_create_info.comment,
INDEX_COMMENT_MAXLEN,
ER_TOO_LONG_INDEX_COMMENT,
- key_info->name))
+ key_info->name.str))
DBUG_RETURN(TRUE);
key_info->comment.length= key->key_create_info.comment.length;
@@ -4991,7 +4992,7 @@ static bool
check_if_keyname_exists(const char *name, KEY *start, KEY *end)
{
for (KEY *key=start ; key != end ; key++)
- if (!my_strcasecmp(system_charset_info,name,key->name))
+ if (!my_strcasecmp(system_charset_info, name, key->name.str))
return 1;
return 0;
}
@@ -5773,7 +5774,8 @@ drop_create_field:
for (n_key=0; n_key < table->s->keys; n_key++)
{
if (my_strcasecmp(system_charset_info,
- drop->name, table->key_info[n_key].name) == 0)
+ drop->name,
+ table->key_info[n_key].name.str) == 0)
{
remove_drop= FALSE;
break;
@@ -5871,7 +5873,7 @@ drop_create_field:
for (n_key=0; n_key < table->s->keys; n_key++)
{
if (my_strcasecmp(system_charset_info,
- keyname, table->key_info[n_key].name) == 0)
+ keyname, table->key_info[n_key].name.str) == 0)
{
goto remove_key;
}
@@ -6462,7 +6464,7 @@ static bool fill_alter_inplace_info(THD *thd,
new_key < new_key_end;
new_key++)
{
- if (! strcmp(table_key->name, new_key->name))
+ if (! strcmp(table_key->name.str, new_key->name.str))
break;
}
if (new_key >= new_key_end)
@@ -6471,7 +6473,7 @@ static bool fill_alter_inplace_info(THD *thd,
ha_alter_info->index_drop_buffer
[ha_alter_info->index_drop_count++]=
table_key;
- DBUG_PRINT("info", ("index dropped: '%s'", table_key->name));
+ DBUG_PRINT("info", ("index dropped: '%s'", table_key->name.str));
continue;
}
@@ -6539,7 +6541,7 @@ static bool fill_alter_inplace_info(THD *thd,
[ha_alter_info->index_add_count++]=
new_key - ha_alter_info->key_info_buffer;
/* Mark all old fields which are used in newly created index. */
- DBUG_PRINT("info", ("index changed: '%s'", table_key->name));
+ DBUG_PRINT("info", ("index changed: '%s'", table_key->name.str));
}
/*end of for (; table_key < table_key_end;) */
@@ -6553,7 +6555,7 @@ static bool fill_alter_inplace_info(THD *thd,
/* Search an old key with the same name. */
for (table_key= table->key_info; table_key < table_key_end; table_key++)
{
- if (! strcmp(table_key->name, new_key->name))
+ if (! strcmp(table_key->name.str, new_key->name.str))
break;
}
if (table_key >= table_key_end)
@@ -6562,7 +6564,7 @@ static bool fill_alter_inplace_info(THD *thd,
ha_alter_info->index_add_buffer
[ha_alter_info->index_add_count++]=
new_key - ha_alter_info->key_info_buffer;
- DBUG_PRINT("info", ("index added: '%s'", new_key->name));
+ DBUG_PRINT("info", ("index added: '%s'", new_key->name.str));
}
else
ha_alter_info->create_info->indexes_option_struct[table_key - table->key_info]=
@@ -6634,7 +6636,8 @@ static bool fill_alter_inplace_info(THD *thd,
if (new_key->flags & HA_NOSAME)
{
- bool is_pk= !my_strcasecmp(system_charset_info, new_key->name, primary_key_name);
+ bool is_pk= !my_strcasecmp(system_charset_info,
+ new_key->name.str, primary_key_name);
if ((!(new_key->flags & HA_KEY_HAS_PART_KEY_SEG) &&
!(new_key->flags & HA_NULL_PART_KEY)) ||
@@ -6815,7 +6818,7 @@ bool mysql_compare_tables(TABLE *table,
/* Search a key with the same name. */
for (new_key= key_info_buffer; new_key < new_key_end; new_key++)
{
- if (! strcmp(table_key->name, new_key->name))
+ if (! strcmp(table_key->name.str, new_key->name.str))
break;
}
if (new_key >= new_key_end)
@@ -6854,7 +6857,7 @@ bool mysql_compare_tables(TABLE *table,
/* Search a key with the same name. */
for (table_key= table->key_info; table_key < table_key_end; table_key++)
{
- if (! strcmp(table_key->name, new_key->name))
+ if (! strcmp(table_key->name.str, new_key->name.str))
break;
}
if (table_key >= table_key_end)
@@ -7655,7 +7658,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
for (uint i=0 ; i < table->s->keys ; i++,key_info++)
{
- const char *key_name= key_info->name;
+ const char *key_name= key_info->name.str;
Alter_drop *drop;
drop_it.rewind();
while ((drop=drop_it++))
diff --git a/sql/structs.h b/sql/structs.h
index 97702e5727b..793be462b26 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -109,9 +109,9 @@ typedef struct st_key {
pk2 is explicitly present in idx1, it is not in the extension, so
ext_key_part_map.is_set(1) == false
*/
+ LEX_CSTRING name;
key_part_map ext_key_part_map;
uint block_size;
- uint name_length;
enum ha_key_alg algorithm;
/*
The flag is on if statistical data for the index prefixes
@@ -128,7 +128,6 @@ typedef struct st_key {
LEX_CSTRING *parser_name; /* Fulltext [pre]parser name */
};
KEY_PART_INFO *key_part;
- const char *name; /* Name of key */
/* Unique name for cache; db + \0 + table_name + \0 + key_name + \0 */
uchar *cache_name;
/*
diff --git a/sql/table.cc b/sql/table.cc
index 032bd99d2fb..5182bbbb1d6 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2129,18 +2129,18 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
for (uint key=0 ; key < keys ; key++,keyinfo++)
{
uint usable_parts= 0;
- keyinfo->name=(char*) share->keynames.type_names[key];
- keyinfo->name_length= strlen(keyinfo->name);
+ keyinfo->name.str= share->keynames.type_names[key];
+ keyinfo->name.length= strlen(keyinfo->name.str);
keyinfo->cache_name=
(uchar*) alloc_root(&share->mem_root,
share->table_cache_key.length+
- keyinfo->name_length + 1);
+ keyinfo->name.length + 1);
if (keyinfo->cache_name) // If not out of memory
{
uchar *pos= keyinfo->cache_name;
memcpy(pos, share->table_cache_key.str, share->table_cache_key.length);
- memcpy(pos + share->table_cache_key.length, keyinfo->name,
- keyinfo->name_length+1);
+ memcpy(pos + share->table_cache_key.length, keyinfo->name.str,
+ keyinfo->name.length+1);
}
if (!key)
@@ -6896,7 +6896,8 @@ bool TABLE::add_tmp_key(uint key, uint key_parts,
if (unique)
keyinfo->flags|= HA_NOSAME;
sprintf(buf, "key%i", key);
- if (!(keyinfo->name= strdup_root(&mem_root, buf)))
+ keyinfo->name.length= strlen(buf);
+ if (!(keyinfo->name.str= strmake_root(&mem_root, buf, keyinfo->name.length)))
return TRUE;
keyinfo->rec_per_key= (ulong*) alloc_root(&mem_root,
sizeof(ulong)*key_parts);
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 5b970b3c555..cfcd0851f81 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -478,7 +478,7 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
*pos++=(uchar) NAMES_SEP_CHAR;
for (key=keyinfo ; key != end ; key++)
{
- uchar *tmp=(uchar*) strmov((char*) pos,key->name);
+ uchar *tmp=(uchar*) strmov((char*) pos,key->name.str);
*tmp++= (uchar) NAMES_SEP_CHAR;
*tmp=0;
pos=tmp;