summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2017-06-18 12:28:40 +0300
committerSergei Golubchik <serg@mariadb.org>2017-08-24 01:05:53 +0200
commitcc77f9882dcaa4e02196bb3847cd66f2943eb4c6 (patch)
treee394e188978a41d0c4eca65aafe917310315c9e1
parent874e4e473acc7087fc8e375e9de2b5d1e846b7e9 (diff)
downloadmariadb-git-cc77f9882dcaa4e02196bb3847cd66f2943eb4c6.tar.gz
Changed KEY names to use LEX_CSTRING
-rw-r--r--plugin/handler_socket/handlersocket/database.cpp2
-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
-rw-r--r--storage/innobase/handler/ha_innodb.cc38
-rw-r--r--storage/innobase/handler/handler0alter.cc33
-rw-r--r--storage/mroonga/ha_mroonga.cpp39
-rw-r--r--storage/myisam/ha_myisam.cc2
-rw-r--r--storage/perfschema/pfs_instr_class.cc8
-rw-r--r--storage/rocksdb/ha_rocksdb.cc10
-rw-r--r--storage/rocksdb/rdb_datadic.cc2
-rw-r--r--storage/spider/spd_db_conn.cc4
-rw-r--r--storage/spider/spd_db_mysql.cc4
-rw-r--r--storage/tokudb/ha_tokudb.cc23
-rw-r--r--storage/tokudb/ha_tokudb_admin.cc4
-rw-r--r--storage/tokudb/ha_tokudb_alter_56.cc12
-rw-r--r--storage/tokudb/ha_tokudb_alter_common.cc2
-rw-r--r--storage/tokudb/tokudb_card.h4
31 files changed, 180 insertions, 162 deletions
diff --git a/plugin/handler_socket/handlersocket/database.cpp b/plugin/handler_socket/handlersocket/database.cpp
index 0761c1bc09d..b21d58d243b 100644
--- a/plugin/handler_socket/handlersocket/database.cpp
+++ b/plugin/handler_socket/handlersocket/database.cpp
@@ -1047,7 +1047,7 @@ dbcontext::cmd_open(dbcallback_i& cb, const cmd_open_args& arg)
TABLE *const table = table_vec[tblnum].table;
for (uint i = 0; i < table->s->keys; ++i) {
KEY& kinfo = table->key_info[i];
- if (strcmp(kinfo.name, idx_name_to_open) == 0) {
+ if (strcmp(kinfo.name.str, idx_name_to_open) == 0) {
idxnum = i;
break;
}
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;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index de752e93b55..10af77c7b0e 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -6068,7 +6068,7 @@ innobase_build_index_translation(
/* Fetch index pointers into index_mapping according to mysql
index sequence */
index_mapping[count] = dict_table_get_index_on_name(
- ib_table, table->key_info[count].name);
+ ib_table, table->key_info[count].name.str);
if (index_mapping[count] == 0) {
sql_print_error("Cannot find index %s in InnoDB"
@@ -9785,9 +9785,9 @@ ha_innobase::innobase_get_index(
index = innobase_index_lookup(m_share, keynr);
if (index != NULL) {
- if (!key || ut_strcmp(index->name, key->name) != 0) {
+ if (!key || ut_strcmp(index->name, key->name.str) != 0) {
ib::error() << " Index for key no " << keynr
- << " mysql name " << (key ? key->name : "NULL")
+ << " mysql name " << (key ? key->name.str : "NULL")
<< " InnoDB name " << index->name()
<< " for table " << m_prebuilt->table->name.m_name;
@@ -9797,7 +9797,7 @@ ha_innobase::innobase_get_index(
if (index) {
ib::info() << " Index for key no " << keynr
- << " mysql name " << (key ? key->name : "NULL")
+ << " mysql name " << (key ? key->name.str : "NULL")
<< " InnoDB name " << index->name()
<< " for table " << m_prebuilt->table->name.m_name;
}
@@ -9805,7 +9805,7 @@ ha_innobase::innobase_get_index(
}
- ut_a(ut_strcmp(index->name, key->name) == 0);
+ ut_a(ut_strcmp(index->name, key->name.str) == 0);
} else {
/* Can't find index with keynr in the translation
table. Only print message if the index translation
@@ -9815,14 +9815,14 @@ ha_innobase::innobase_get_index(
" index %s key no %u for"
" table %s through its"
" index translation table",
- key ? key->name : "NULL",
+ key ? key->name.str : "NULL",
keynr,
m_prebuilt->table->name
.m_name);
}
index = dict_table_get_index_on_name(
- m_prebuilt->table, key->name);
+ m_prebuilt->table, key->name.str);
}
} else {
key = 0;
@@ -9833,7 +9833,7 @@ ha_innobase::innobase_get_index(
sql_print_error(
"InnoDB could not find key no %u with name %s"
" from dict cache for table %s",
- keynr, key ? key->name : "NULL",
+ keynr, key ? key->name.str : "NULL",
m_prebuilt->table->name.m_name);
}
@@ -11004,7 +11004,7 @@ ha_innobase::wsrep_append_keys(
if (!tab) {
WSREP_WARN("MariaDB-InnoDB key mismatch %s %s",
table->s->table_name.str,
- key_info->name);
+ key_info->name.str);
}
/* !hasPK == table with no PK, must append all non-unique keys */
if (!hasPK || key_info->flags & HA_NOSAME ||
@@ -11666,7 +11666,7 @@ create_index(
key = form->key_info + key_num;
/* Assert that "GEN_CLUST_INDEX" cannot be used as non-primary index */
- ut_a(innobase_strcasecmp(key->name, innobase_index_reserve_name) != 0);
+ ut_a(innobase_strcasecmp(key->name.str, innobase_index_reserve_name) != 0);
ind_type = 0;
if (key->flags & HA_SPATIAL) {
@@ -11677,7 +11677,7 @@ create_index(
if (ind_type != 0)
{
- index = dict_mem_index_create(table_name, key->name, 0,
+ index = dict_mem_index_create(table_name, key->name.str, 0,
ind_type,
key->user_defined_key_parts);
@@ -11719,7 +11719,7 @@ create_index(
/* We pass 0 as the space id, and determine at a lower level the space
id where to store the table */
- index = dict_mem_index_create(table_name, key->name, 0,
+ index = dict_mem_index_create(table_name, key->name.str, 0,
ind_type, key->user_defined_key_parts);
for (ulint i = 0; i < key->user_defined_key_parts; i++) {
@@ -12354,16 +12354,16 @@ create_table_info_t::innobase_table_flags()
}
}
- if (innobase_strcasecmp(key->name, FTS_DOC_ID_INDEX_NAME)) {
+ if (innobase_strcasecmp(key->name.str, FTS_DOC_ID_INDEX_NAME)) {
continue;
}
/* Do a pre-check on FTS DOC ID index */
if (!(key->flags & HA_NOSAME)
- || strcmp(key->name, FTS_DOC_ID_INDEX_NAME)
+ || strcmp(key->name.str, FTS_DOC_ID_INDEX_NAME)
|| strcmp(key->key_part[0].field->field_name.str,
FTS_DOC_ID_COL_NAME)) {
- fts_doc_id_index_bad = key->name;
+ fts_doc_id_index_bad = key->name.str;
}
if (fts_doc_id_index_bad && (m_flags2 & DICT_TF2_FTS)) {
@@ -12649,7 +12649,7 @@ innobase_parse_hint_from_comment(
KEY* key_info = &table_share->key_info[i];
if (innobase_strcasecmp(
- index->name, key_info->name) == 0) {
+ index->name, key_info->name.str) == 0) {
dict_index_set_merge_threshold(
index,
@@ -12691,7 +12691,7 @@ innobase_parse_hint_from_comment(
KEY* key_info = &table_share->key_info[i];
if (innobase_strcasecmp(
- index->name, key_info->name) == 0) {
+ index->name, key_info->name.str) == 0) {
/* x-lock index is needed to exclude concurrent
pessimistic tree operations */
@@ -14200,7 +14200,7 @@ innobase_get_mysql_key_number_for_index(
InnoDB dict_index_t list */
for (i = 0; i < table->s->keys; i++) {
ind = dict_table_get_index_on_name(
- ib_table, table->key_info[i].name);
+ ib_table, table->key_info[i].name.str);
if (index == ind) {
return(i);
@@ -19072,7 +19072,7 @@ innobase_index_name_is_reserved(
for (key_num = 0; key_num < num_of_keys; key_num++) {
key = &key_info[key_num];
- if (innobase_strcasecmp(key->name,
+ if (innobase_strcasecmp(key->name.str,
innobase_index_reserve_name) == 0) {
/* Push warning to mysql */
push_warning_printf(thd,
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index ceaa07bbd40..6fd2f1099fb 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -919,7 +919,7 @@ ha_innobase::check_if_supported_inplace_alter(
for (uint i = 0; i < ha_alter_info->index_drop_count; i++) {
if (!my_strcasecmp(
system_charset_info,
- ha_alter_info->index_drop_buffer[i]->name,
+ ha_alter_info->index_drop_buffer[i]->name.str,
FTS_DOC_ID_INDEX_NAME)) {
ha_alter_info->unsupported_reason = innobase_get_err_msg(
ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_CHANGE_FTS);
@@ -2000,7 +2000,7 @@ innobase_check_index_keys(
const KEY& key2 = info->key_info_buffer[
info->index_add_buffer[i]];
- if (0 == strcmp(key.name, key2.name)) {
+ if (0 == strcmp(key.name.str, key2.name.str)) {
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0),
key.name);
@@ -2016,7 +2016,7 @@ innobase_check_index_keys(
index; index = dict_table_get_next_index(index)) {
if (index->is_committed()
- && !strcmp(key.name, index->name)) {
+ && !strcmp(key.name.str, index->name)) {
break;
}
}
@@ -2041,7 +2041,8 @@ innobase_check_index_keys(
const KEY* drop_key
= info->index_drop_buffer[i];
- if (0 == strcmp(key.name, drop_key->name)) {
+ if (0 == strcmp(key.name.str,
+ drop_key->name.str)) {
goto name_ok;
}
}
@@ -2225,7 +2226,7 @@ innobase_create_index_def(
index->parser = NULL;
index->key_number = key_number;
index->n_fields = n_fields;
- index->name = mem_heap_strdup(heap, key->name);
+ index->name = mem_heap_strdup(heap, key->name.str);
index->rebuild = new_clustered;
if (key_clustered) {
@@ -2245,8 +2246,8 @@ innobase_create_index_def(
if (key->flags & HA_USES_PARSER) {
for (ulint j = 0; j < altered_table->s->keys; j++) {
- if (ut_strcmp(altered_table->key_info[j].name,
- key->name) == 0) {
+ if (ut_strcmp(altered_table->key_info[j].name.str,
+ key->name.str) == 0) {
ut_ad(altered_table->key_info[j].flags
& HA_USES_PARSER);
@@ -2422,13 +2423,13 @@ innobase_fts_check_doc_id_index(
const KEY& key = altered_table->key_info[i];
if (innobase_strcasecmp(
- key.name, FTS_DOC_ID_INDEX_NAME)) {
+ key.name.str, FTS_DOC_ID_INDEX_NAME)) {
continue;
}
if ((key.flags & HA_NOSAME)
&& key.user_defined_key_parts == 1
- && !strcmp(key.name, FTS_DOC_ID_INDEX_NAME)
+ && !strcmp(key.name.str, FTS_DOC_ID_INDEX_NAME)
&& !strcmp(key.key_part[0].field->field_name.str,
FTS_DOC_ID_COL_NAME)) {
if (fts_doc_col_no) {
@@ -2499,7 +2500,7 @@ innobase_fts_check_doc_id_index_in_def(
for (ulint j = 0; j < n_key; j++) {
const KEY* key = &key_info[j];
- if (innobase_strcasecmp(key->name, FTS_DOC_ID_INDEX_NAME)) {
+ if (innobase_strcasecmp(key->name.str, FTS_DOC_ID_INDEX_NAME)) {
continue;
}
@@ -2507,7 +2508,7 @@ innobase_fts_check_doc_id_index_in_def(
named as "FTS_DOC_ID_INDEX" and on column "FTS_DOC_ID" */
if (!(key->flags & HA_NOSAME)
|| key->user_defined_key_parts != 1
- || strcmp(key->name, FTS_DOC_ID_INDEX_NAME)
+ || strcmp(key->name.str, FTS_DOC_ID_INDEX_NAME)
|| strcmp(key->key_part[0].field->field_name.str,
FTS_DOC_ID_COL_NAME)) {
return(FTS_INCORRECT_DOC_ID_INDEX);
@@ -2579,7 +2580,7 @@ innobase_create_key_defs(
new_primary = n_add > 0
&& !my_strcasecmp(system_charset_info,
- key_info[*add].name, "PRIMARY");
+ key_info[*add].name.str, "PRIMARY");
n_fts_add = 0;
/* If there is a UNIQUE INDEX consisting entirely of NOT NULL
@@ -5886,7 +5887,7 @@ found_fk:
= ha_alter_info->index_drop_buffer[i];
dict_index_t* index
= dict_table_get_index_on_name(
- indexed_table, key->name);
+ indexed_table, key->name.str);
if (!index) {
push_warning_printf(
@@ -5928,7 +5929,7 @@ found_fk:
if (!my_strcasecmp(
system_charset_info,
FTS_DOC_ID_INDEX_NAME,
- table->key_info[i].name)) {
+ table->key_info[i].name.str)) {
/* The index exists in the MySQL
data dictionary. Do not drop it,
even though it is no longer needed
@@ -6340,7 +6341,7 @@ get_error_key_name(
} else if (ha_alter_info->key_count == 0) {
return(dict_table_get_first_index(table)->name);
} else {
- return(ha_alter_info->key_info_buffer[error_key_num].name);
+ return(ha_alter_info->key_info_buffer[error_key_num].name.str);
}
}
@@ -8267,7 +8268,7 @@ alter_stats_norebuild(
char errstr[1024];
if (dict_stats_drop_index(
- ctx->new_table->name.m_name, key->name,
+ ctx->new_table->name.m_name, key->name.str,
errstr, sizeof errstr) != DB_SUCCESS) {
push_warning(thd,
Sql_condition::WARN_LEVEL_WARN,
diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp
index cb353db53b0..a7e4a9c807a 100644
--- a/storage/mroonga/ha_mroonga.cpp
+++ b/storage/mroonga/ha_mroonga.cpp
@@ -2984,7 +2984,7 @@ int ha_mroonga::wrapper_create_index_fulltext(const char *grn_table_name,
if (error) {
DBUG_RETURN(error);
}
- mrn::IndexTableName index_table_name(grn_table_name, key_info->name);
+ mrn::IndexTableName index_table_name(grn_table_name, key_info->name.str);
index_table = grn_table_create(ctx,
index_table_name.c_str(),
index_table_name.length(),
@@ -3060,7 +3060,7 @@ int ha_mroonga::wrapper_create_index_geo(const char *grn_table_name,
if (error)
DBUG_RETURN(error);
- mrn::IndexTableName index_table_name(grn_table_name, key_info->name);
+ mrn::IndexTableName index_table_name(grn_table_name, key_info->name.str);
grn_obj_flags index_table_flags =
GRN_OBJ_TABLE_PAT_KEY |
@@ -3684,7 +3684,7 @@ int ha_mroonga::storage_create_index_table(TABLE *table,
}
{
- mrn::IndexTableName index_table_name(grn_table_name, key_info->name);
+ mrn::IndexTableName index_table_name(grn_table_name, key_info->name.str);
index_table = grn_table_create(ctx,
index_table_name.c_str(),
index_table_name.length(),
@@ -3788,7 +3788,7 @@ int ha_mroonga::storage_create_index(TABLE *table, const char *grn_table_name,
index_table = index_tables[i];
const char *index_column_name;
if (tmp_share->index_table && tmp_share->index_table[i]) {
- index_column_name = key_info->name;
+ index_column_name = key_info->name.str;
} else {
index_column_name = INDEX_COLUMN_NAME;
}
@@ -4097,7 +4097,7 @@ int ha_mroonga::wrapper_open_indexes(const char *name)
continue;
}
- mrn::IndexTableName index_table_name(mapper.table_name(), key_info->name);
+ mrn::IndexTableName index_table_name(mapper.table_name(), key_info->name.str);
grn_index_tables[i] = grn_ctx_get(ctx,
index_table_name.c_str(),
index_table_name.length());
@@ -4395,11 +4395,12 @@ int ha_mroonga::storage_open_indexes(const char *name)
if (ctx->rc == GRN_SUCCESS) {
grn_index_columns[i] = grn_obj_column(ctx,
grn_index_tables[i],
- key_info->name,
- strlen(key_info->name));
+ key_info->name.str,
+ key_info->name.length);
}
} else {
- mrn::IndexTableName index_table_name(mapper.table_name(), key_info->name);
+ mrn::IndexTableName index_table_name(mapper.table_name(),
+ key_info->name.str);
grn_index_tables[i] = grn_ctx_get(ctx,
index_table_name.c_str(),
index_table_name.length());
@@ -8800,7 +8801,7 @@ int ha_mroonga::drop_index(MRN_SHARE *target_share, uint key_index)
if (!target_share->wrapper_mode && target_share->index_table[key_index]) {
const char *table_name = target_share->index_table[key_index];
snprintf(target_name, GRN_TABLE_MAX_KEY_SIZE,
- "%s.%s", table_name, key_info[key_index].name);
+ "%s.%s", table_name, key_info[key_index].name.str);
target_name_length = strlen(target_name);
grn_obj *index_column = grn_ctx_get(ctx, target_name, target_name_length);
if (index_column) {
@@ -8809,7 +8810,7 @@ int ha_mroonga::drop_index(MRN_SHARE *target_share, uint key_index)
} else {
mrn::PathMapper mapper(target_share->table_name);
mrn::IndexTableName index_table_name(mapper.table_name(),
- key_info[key_index].name);
+ key_info[key_index].name.str);
grn_obj *index_table = grn_ctx_get(ctx,
index_table_name.c_str(),
index_table_name.length());
@@ -12782,7 +12783,7 @@ int ha_mroonga::wrapper_rename_index(const char *from, const char *to,
uint i;
for (i = 0; i < tmp_table_share->keys; i++) {
- const char *mysql_index_name = tmp_table_share->key_info[i].name;
+ const char *mysql_index_name = tmp_table_share->key_info[i].name.str;
mrn::IndexTableName from_index_table_name(from_table_name, mysql_index_name);
mrn::IndexTableName to_index_table_name(to_table_name, mysql_index_name);
grn_obj *index_table;
@@ -12845,7 +12846,7 @@ int ha_mroonga::storage_rename_table(const char *from, const char *to,
uint i;
for (i = 0; i < tmp_table_share->keys; i++) {
- const char *mysql_index_name = tmp_table_share->key_info[i].name;
+ const char *mysql_index_name = tmp_table_share->key_info[i].name.str;
mrn::IndexTableName from_index_table_name(from_table_name,
mysql_index_name);
mrn::IndexTableName to_index_table_name(to_table_name,
@@ -13103,7 +13104,7 @@ int ha_mroonga::generic_disable_index(int i, KEY *key_info)
if (share->index_table[i]) {
char index_column_name[GRN_TABLE_MAX_KEY_SIZE];
snprintf(index_column_name, GRN_TABLE_MAX_KEY_SIZE - 1,
- "%s.%s", share->index_table[i], key_info[i].name);
+ "%s.%s", share->index_table[i], key_info[i].name.str);
grn_obj *index_column = grn_ctx_get(ctx,
index_column_name,
strlen(index_column_name));
@@ -13113,7 +13114,7 @@ int ha_mroonga::generic_disable_index(int i, KEY *key_info)
} else {
mrn::PathMapper mapper(share->table_name);
mrn::IndexTableName index_table_name(mapper.table_name(),
- key_info[i].name);
+ key_info[i].name.str);
grn_obj *index_table = grn_ctx_get(ctx,
index_table_name.c_str(),
index_table_name.length());
@@ -13577,7 +13578,7 @@ int ha_mroonga::wrapper_recreate_indexes(THD *thd)
continue;
}
mrn::IndexTableName index_table_name(mapper.table_name(),
- table_share->key_info[i].name);
+ table_share->key_info[i].name.str);
char index_column_full_name[MRN_MAX_PATH_SIZE];
snprintf(index_column_full_name, MRN_MAX_PATH_SIZE,
"%s.%s", index_table_name.c_str(), INDEX_COLUMN_NAME);
@@ -13629,7 +13630,7 @@ int ha_mroonga::storage_recreate_indexes(THD *thd)
continue;
mrn::IndexTableName index_table_name(mapper.table_name(),
- table_share->key_info[i].name);
+ table_share->key_info[i].name.str);
char index_column_full_name[MRN_MAX_PATH_SIZE];
snprintf(index_column_full_name, MRN_MAX_PATH_SIZE,
"%s.%s", index_table_name.c_str(), INDEX_COLUMN_NAME);
@@ -14209,10 +14210,10 @@ bool ha_mroonga::wrapper_inplace_alter_table(
if (!(key->flags & HA_FULLTEXT || mrn_is_geo_key(key))) {
continue;
}
- while (strcmp(key_info[j].name, key->name)) {
+ while (strcmp(key_info[j].name.str, key->name.str)) {
++j;
}
- DBUG_PRINT("info", ("mroonga: key_name=%s", key->name));
+ DBUG_PRINT("info", ("mroonga: key_name=%s", key->name.str));
error = drop_index(share, j);
if (error)
DBUG_RETURN(true);
@@ -14377,7 +14378,7 @@ bool ha_mroonga::storage_inplace_alter_table_index(
n_keys = ha_alter_info->index_drop_count;
for (i = 0; i < n_keys; ++i) {
KEY *key = ha_alter_info->index_drop_buffer[i];
- while (strcmp(key_info[j].name, key->name)) {
+ while (strcmp(key_info[j].name.str, key->name.str)) {
++j;
}
error = drop_index(share, j);
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index f39826d1b50..7ee903200da 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -2350,7 +2350,7 @@ ha_myisam::check_if_supported_inplace_alter(TABLE *new_table,
old_key->flags != new_key->flags ||
old_key->user_defined_key_parts != new_key->user_defined_key_parts ||
old_key->algorithm != new_key->algorithm ||
- strcmp(old_key->name, new_key->name))
+ strcmp(old_key->name.str, new_key->name.str))
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
for (uint j= 0; j < old_key->user_defined_key_parts; j++)
diff --git a/storage/perfschema/pfs_instr_class.cc b/storage/perfschema/pfs_instr_class.cc
index c67c120283d..8f2fdc2594e 100644
--- a/storage/perfschema/pfs_instr_class.cc
+++ b/storage/perfschema/pfs_instr_class.cc
@@ -1193,8 +1193,8 @@ static void set_keys(PFS_table_share *pfs, const TABLE_SHARE *share)
for ( ; pfs_key < pfs_key_last; pfs_key++, key_info++)
{
- len= strlen(key_info->name);
- memcpy(pfs_key->m_name, key_info->name, len);
+ len= key_info->name.length;
+ memcpy(pfs_key->m_name, key_info->name.str, len);
pfs_key->m_name_length= len;
}
@@ -1215,11 +1215,11 @@ static int compare_keys(PFS_table_share *pfs, const TABLE_SHARE *share)
for ( ; pfs_key < pfs_key_last; pfs_key++, key_info++)
{
- len= strlen(key_info->name);
+ len= key_info->name.length;
if (len != pfs_key->m_name_length)
return 1;
- if (memcmp(pfs_key->m_name, key_info->name, len) != 0)
+ if (memcmp(pfs_key->m_name, key_info->name.str, len) != 0)
return 1;
}
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index b31b430b159..4f8ab116923 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -5819,7 +5819,7 @@ std::unordered_map<std::string, uint> ha_rocksdb::get_old_key_positions(
ALTER TABLE t1 DROP INDEX ka, ADD INDEX ka(b), ALGORITHM=INPLACE;
*/
const KEY *const old_key = &old_table_arg->key_info[i];
- const auto &it = new_key_pos.find(old_key->name);
+ const auto &it = new_key_pos.find(old_key->name.str);
if (it == new_key_pos.end()) {
continue;
}
@@ -5847,7 +5847,7 @@ std::unordered_map<std::string, uint> ha_rocksdb::get_old_key_positions(
continue;
}
- old_key_pos[old_key->name] = i;
+ old_key_pos[old_key->name.str] = i;
}
DBUG_RETURN(old_key_pos);
@@ -5862,7 +5862,7 @@ int ha_rocksdb::compare_keys(const KEY *const old_key,
DBUG_ASSERT(new_key != nullptr);
/* Check index name. */
- if (strcmp(old_key->name, new_key->name) != 0) {
+ if (strcmp(old_key->name.str, new_key->name.str) != 0) {
DBUG_RETURN(HA_EXIT_FAILURE);
}
@@ -7840,9 +7840,9 @@ const char *ha_rocksdb::get_key_name(const uint index,
}
DBUG_ASSERT(table_arg->key_info != nullptr);
- DBUG_ASSERT(table_arg->key_info[index].name != nullptr);
+ DBUG_ASSERT(table_arg->key_info[index].name.str != nullptr);
- return table_arg->key_info[index].name;
+ return table_arg->key_info[index].name.str;
}
const char *ha_rocksdb::get_key_comment(const uint index,
diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc
index f0beb42fc24..618771c5410 100644
--- a/storage/rocksdb/rdb_datadic.cc
+++ b/storage/rocksdb/rdb_datadic.cc
@@ -158,7 +158,7 @@ void Rdb_key_def::setup(const TABLE *const tbl,
key_info = &tbl->key_info[m_keyno];
if (!hidden_pk_exists)
pk_info = &tbl->key_info[tbl->s->primary_key];
- m_name = std::string(key_info->name);
+ m_name = std::string(key_info->name.str);
} else {
m_name = HIDDEN_PK_NAME;
}
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index d235fe1eba7..f5a54c6ba9b 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -1666,8 +1666,8 @@ int spider_db_append_key_where_internal(
if (sql_kind == SPIDER_SQL_KIND_HANDLER)
{
- const char *key_name = key_info->name;
- key_name_length = strlen(key_name);
+ const char *key_name = key_info->name.str;
+ key_name_length = key_info->name.length;
if (str->reserve(SPIDER_SQL_READ_LEN +
/* SPIDER_SQL_NAME_QUOTE_LEN */ 2 + key_name_length))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index 89aefe4c080..4e2a41e9fa6 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -2721,8 +2721,8 @@ void spider_db_mysql::set_dup_key_idx(
key_name = spider->share->tgt_pk_names[all_link_idx];
key_name_length = spider->share->tgt_pk_names_lengths[all_link_idx];
} else {
- key_name = table->s->key_info[roop_count].name;
- key_name_length = strlen(key_name);
+ key_name = table->s->key_info[roop_count].name.str;
+ key_name_length = table->s->key_info[roop_count].name.length;
}
DBUG_PRINT("info",("spider key_name=%s", key_name));
if (
diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc
index 1a7c42e970f..b5e47deb623 100644
--- a/storage/tokudb/ha_tokudb.cc
+++ b/storage/tokudb/ha_tokudb.cc
@@ -1434,7 +1434,7 @@ int ha_tokudb::open_secondary_dictionary(
char* newname = NULL;
size_t newname_len = 0;
- sprintf(dict_name, "key-%s", key_info->name);
+ sprintf(dict_name, "key-%s", key_info->name.str);
newname_len = get_max_dict_name_path_length(name);
newname =
@@ -1746,7 +1746,7 @@ int ha_tokudb::initialize_share(const char* name, int mode) {
} else {
share->_key_descriptors[i]._is_unique = false;
share->_key_descriptors[i]._name =
- tokudb::memory::strdup(table_share->key_info[i].name, 0);
+ tokudb::memory::strdup(table_share->key_info[i].name.str, 0);
}
if (table_share->key_info[i].flags & HA_NOSAME) {
@@ -3579,7 +3579,7 @@ int ha_tokudb::is_index_unique(bool* is_unique, DB_TXN* txn, DB* db, KEY* key_in
"Verifying index uniqueness: Checked %llu of %llu rows in key-%s.",
(long long unsigned) cnt,
share->row_count(),
- key_info->name);
+ key_info->name.str);
thd_proc_info(thd, status_msg);
if (thd_kill_level(thd)) {
my_error(ER_QUERY_INTERRUPTED, MYF(0));
@@ -6897,7 +6897,7 @@ void ha_tokudb::trace_create_table_info(const char *name, TABLE * form) {
TOKUDB_HANDLER_TRACE(
"key:%d:%s:%d",
i,
- key->name,
+ key->name.str,
key->user_defined_key_parts);
uint p;
for (p = 0; p < key->user_defined_key_parts; p++) {
@@ -7018,7 +7018,7 @@ int ha_tokudb::create_secondary_dictionary(
goto cleanup;
}
- sprintf(dict_name, "key-%s", key_info->name);
+ sprintf(dict_name, "key-%s", key_info->name.str);
make_name(newname, newname_len, name, dict_name);
prim_key = (hpk) ? NULL : &form->s->key_info[primary_key];
@@ -7368,7 +7368,7 @@ int ha_tokudb::create(
error = write_key_name_to_status(
status_block,
- form->s->key_info[i].name,
+ form->s->key_info[i].name.str,
txn);
if (error) {
goto cleanup;
@@ -8089,7 +8089,8 @@ int ha_tokudb::tokudb_add_index(
//
for (uint i = 0; i < num_of_keys; i++) {
for (uint j = 0; j < table_arg->s->keys; j++) {
- if (strcmp(key_info[i].name, table_arg->s->key_info[j].name) == 0) {
+ if (strcmp(key_info[i].name.str,
+ table_arg->s->key_info[j].name.str) == 0) {
error = HA_ERR_WRONG_COMMAND;
goto cleanup;
}
@@ -8410,7 +8411,7 @@ int ha_tokudb::tokudb_add_index(
// now write stuff to status.tokudb
//
for (uint i = 0; i < num_of_keys; i++) {
- write_key_name_to_status(share->status_block, key_info[i].name, txn);
+ write_key_name_to_status(share->status_block, key_info[i].name.str, txn);
}
share->unlock();
@@ -8526,7 +8527,7 @@ int ha_tokudb::drop_indexes(
error = remove_key_name_from_status(
share->status_block,
- key_info[curr_index].name,
+ key_info[curr_index].name.str,
txn);
if (error) {
goto cleanup;
@@ -8535,7 +8536,7 @@ int ha_tokudb::drop_indexes(
error = delete_or_rename_dictionary(
share->full_table_name(),
NULL,
- key_info[curr_index].name,
+ key_info[curr_index].name.str,
true,
txn,
true);
@@ -8655,7 +8656,7 @@ int ha_tokudb::truncate_dictionary(uint keynr, DB_TXN* txn) {
error = delete_or_rename_dictionary(
share->full_table_name(),
NULL,
- table_share->key_info[keynr].name,
+ table_share->key_info[keynr].name.str,
true, //is_key
txn,
true); // is a delete
diff --git a/storage/tokudb/ha_tokudb_admin.cc b/storage/tokudb/ha_tokudb_admin.cc
index e1443101bb6..bf2e78d248c 100644
--- a/storage/tokudb/ha_tokudb_admin.cc
+++ b/storage/tokudb/ha_tokudb_admin.cc
@@ -939,7 +939,7 @@ int ha_tokudb::do_optimize(THD* thd) {
const char* this_index_name =
i >= table_share->keys ?
"primary" :
- table_share->key_info[i].name;
+ table_share->key_info[i].name.str;
if (strcasecmp(optimize_index_name, this_index_name) != 0) {
continue;
}
@@ -1069,7 +1069,7 @@ int ha_tokudb::check(THD* thd, HA_CHECK_OPT* check_opt) {
DB* db = share->key_file[i];
assert_always(db != NULL);
const char* kname =
- i == primary_key ? "primary" : table_share->key_info[i].name;
+ i == primary_key ? "primary" : table_share->key_info[i].name.str;
snprintf(
write_status_msg,
sizeof(write_status_msg),
diff --git a/storage/tokudb/ha_tokudb_alter_56.cc b/storage/tokudb/ha_tokudb_alter_56.cc
index b4eccf17b57..5b43496eb6f 100644
--- a/storage/tokudb/ha_tokudb_alter_56.cc
+++ b/storage/tokudb/ha_tokudb_alter_56.cc
@@ -234,7 +234,7 @@ static bool is_disjoint_add_drop(Alter_inplace_info *ha_alter_info) {
for (uint a = 0; a < ha_alter_info->index_add_count; a++) {
KEY* add_key =
&ha_alter_info->key_info_buffer[ha_alter_info->index_add_buffer[a]];
- if (strcmp(drop_key->name, add_key->name) == 0) {
+ if (strcmp(drop_key->name.str, add_key->name.str) == 0) {
return false;
}
}
@@ -718,7 +718,7 @@ static bool find_index_of_key(
uint* index_offset_ptr) {
for (uint i = 0; i < table->s->keys; i++) {
- if (strcmp(key_name, table->key_info[i].name) == 0) {
+ if (strcmp(key_name, table->key_info[i].name.str) == 0) {
*index_offset_ptr = i;
return true;
}
@@ -733,7 +733,7 @@ static bool find_index_of_key(
uint* index_offset_ptr) {
for (uint i = 0; i < key_count; i++) {
- if (strcmp(key_name, key_info[i].name) == 0) {
+ if (strcmp(key_name, key_info[i].name.str) == 0) {
*index_offset_ptr = i;
return true;
}
@@ -751,13 +751,13 @@ int ha_tokudb::alter_table_drop_index(
for (uint i = 0; i < ha_alter_info->index_drop_count; i++) {
bool found;
found = find_index_of_key(
- ha_alter_info->index_drop_buffer[i]->name,
+ ha_alter_info->index_drop_buffer[i]->name.str,
table,
&index_drop_offsets[i]);
if (!found) {
// undo of add key in partition engine
found = find_index_of_key(
- ha_alter_info->index_drop_buffer[i]->name,
+ ha_alter_info->index_drop_buffer[i]->name.str,
ha_alter_info->key_info_buffer,
ha_alter_info->key_count,
&index_drop_offsets[i]);
@@ -1005,7 +1005,7 @@ bool ha_tokudb::commit_inplace_alter_table(
uint index_drop_offsets[ha_alter_info->index_drop_count];
for (uint i = 0; i < ha_alter_info->index_drop_count; i++) {
bool found = find_index_of_key(
- ha_alter_info->index_drop_buffer[i]->name,
+ ha_alter_info->index_drop_buffer[i]->name.str,
table,
&index_drop_offsets[i]);
assert_always(found);
diff --git a/storage/tokudb/ha_tokudb_alter_common.cc b/storage/tokudb/ha_tokudb_alter_common.cc
index 17f9a4daa39..b3d39997a81 100644
--- a/storage/tokudb/ha_tokudb_alter_common.cc
+++ b/storage/tokudb/ha_tokudb_alter_common.cc
@@ -59,7 +59,7 @@ static bool tables_have_same_keys(
for (uint32_t i=0; i < table->s->keys; i++) {
KEY* curr_orig_key = &table->key_info[i];
KEY* curr_altered_key = &altered_table->key_info[i];
- if (strcmp(curr_orig_key->name, curr_altered_key->name)) {
+ if (strcmp(curr_orig_key->name.str, curr_altered_key->name.str)) {
if (print_error) {
sql_print_error(
"key %d has different name, %s %s",
diff --git a/storage/tokudb/tokudb_card.h b/storage/tokudb/tokudb_card.h
index f649c2d887f..ea82dcf99dd 100644
--- a/storage/tokudb/tokudb_card.h
+++ b/storage/tokudb/tokudb_card.h
@@ -111,7 +111,7 @@ namespace tokudb {
uint* index_offset_ptr) {
for (uint i = 0; i < table_share->keys; i++) {
- if (strcmp(key_name, table_share->key_info[i].name) == 0) {
+ if (strcmp(key_name, table_share->key_info[i].name.str) == 0) {
*index_offset_ptr = i;
return true;
}
@@ -166,7 +166,7 @@ namespace tokudb {
altered_table_share->key_info[i].user_defined_key_parts;
uint orig_key_index;
if (find_index_of_key(
- altered_table_share->key_info[i].name,
+ altered_table_share->key_info[i].name.str,
table_share,
&orig_key_index)) {
copy_card(