1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Optimize LEX_STRING comparisons

- Added inline lex_string_cmp() to replace my_strcase_cmp().
- Added inline lex_string_eq to first compares lengths before comparing strings
This commit is contained in:
Michael Widenius
2017-06-18 14:00:28 +03:00
committed by Sergei Golubchik
parent cc77f9882d
commit 25c06f5282
14 changed files with 137 additions and 137 deletions

View File

@@ -1184,8 +1184,7 @@ bool Item::eq(const Item *item, bool binary_cmp) const
type() can be only among basic constant types. type() can be only among basic constant types.
*/ */
return type() == item->type() && name.str && item->name.str && return type() == item->type() && name.str && item->name.str &&
name.length == item->name.length && !lex_string_cmp(system_charset_info, &name, &item->name);
!my_strcasecmp(system_charset_info, name.str, item->name.str);
} }
@@ -3086,8 +3085,8 @@ bool Item_field::eq(const Item *item, bool binary_cmp) const
(In cases where we would choose wrong we would have to generate a (In cases where we would choose wrong we would have to generate a
ER_NON_UNIQ_ERROR). ER_NON_UNIQ_ERROR).
*/ */
return (!my_strcasecmp(system_charset_info, item_field->name.str, return (!lex_string_cmp(system_charset_info, &item_field->name,
field_name.str) && &field_name) &&
(!item_field->table_name || !table_name || (!item_field->table_name || !table_name ||
(!my_strcasecmp(table_alias_charset, item_field->table_name, (!my_strcasecmp(table_alias_charset, item_field->table_name,
table_name) && table_name) &&
@@ -5030,8 +5029,8 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
/* SELECT list element with explicit alias */ /* SELECT list element with explicit alias */
if ((*(cur_group->item))->name.str && if ((*(cur_group->item))->name.str &&
!(*(cur_group->item))->is_autogenerated_name && !(*(cur_group->item))->is_autogenerated_name &&
!my_strcasecmp(system_charset_info, !lex_string_cmp(system_charset_info,
(*(cur_group->item))->name.str, field_name->str)) &(*(cur_group->item))->name, field_name))
{ {
++cur_match_degree; ++cur_match_degree;
} }
@@ -5046,8 +5045,8 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
DBUG_ASSERT(l_field_name->str != 0); DBUG_ASSERT(l_field_name->str != 0);
if (!my_strcasecmp(system_charset_info, if (!lex_string_cmp(system_charset_info,
l_field_name->str, field_name->str)) l_field_name, field_name))
++cur_match_degree; ++cur_match_degree;
else else
continue; continue;
@@ -9116,8 +9115,8 @@ bool Item_trigger_field::eq(const Item *item, bool binary_cmp) const
{ {
return item->type() == TRIGGER_FIELD_ITEM && return item->type() == TRIGGER_FIELD_ITEM &&
row_version == ((Item_trigger_field *)item)->row_version && row_version == ((Item_trigger_field *)item)->row_version &&
!my_strcasecmp(system_charset_info, field_name.str, !lex_string_cmp(system_charset_info, &field_name,
((Item_trigger_field *)item)->field_name.str); &((Item_trigger_field *)item)->field_name);
} }

View File

@@ -2303,9 +2303,7 @@ sp_head::backpatch_goto(THD *thd, sp_label *lab,sp_label *lab_begin_block)
*/ */
continue; continue;
} }
if (my_strcasecmp(system_charset_info, if (lex_string_cmp(system_charset_info, &bp->lab->name, &lab->name) == 0)
bp->lab->name.str,
lab->name.str) == 0)
{ {
if (bp->instr_type == GOTO) if (bp->instr_type == GOTO)
{ {

View File

@@ -132,8 +132,8 @@ sp_pcontext *sp_pcontext::push_context(THD *thd, sp_pcontext::enum_scope scope)
bool cmp_labels(sp_label *a, sp_label *b) bool cmp_labels(sp_label *a, sp_label *b)
{ {
return (my_strcasecmp(system_charset_info, a->name.str, b->name.str) == 0 return (lex_string_cmp(system_charset_info, &a->name, &b->name) == 0 &&
&& a->type == b->type); a->type == b->type);
} }
sp_pcontext *sp_pcontext::pop_context() sp_pcontext *sp_pcontext::pop_context()
@@ -304,7 +304,7 @@ sp_label *sp_pcontext::find_goto_label(const LEX_CSTRING *name, bool recusive)
while ((lab= li++)) while ((lab= li++))
{ {
if (my_strcasecmp(system_charset_info, name->str, lab->name.str) == 0) if (lex_string_cmp(system_charset_info, name, &lab->name) == 0)
return lab; return lab;
} }
@@ -341,7 +341,7 @@ sp_label *sp_pcontext::find_label(const LEX_CSTRING *name)
while ((lab= li++)) while ((lab= li++))
{ {
if (my_strcasecmp(system_charset_info, name->str, lab->name.str) == 0) if (lex_string_cmp(system_charset_info, name, &lab->name) == 0)
return lab; return lab;
} }

View File

@@ -1594,12 +1594,10 @@ static const char *fix_plugin_ptr(const char *name)
*/ */
static bool fix_user_plugin_ptr(ACL_USER *user) static bool fix_user_plugin_ptr(ACL_USER *user)
{ {
if (my_strcasecmp(system_charset_info, user->plugin.str, if (lex_string_eq(&user->plugin, &native_password_plugin_name) == 0)
native_password_plugin_name.str) == 0)
user->plugin= native_password_plugin_name; user->plugin= native_password_plugin_name;
else else
if (my_strcasecmp(system_charset_info, user->plugin.str, if (lex_string_eq(&user->plugin, &old_password_plugin_name) == 0)
old_password_plugin_name.str) == 0)
user->plugin= old_password_plugin_name; user->plugin= old_password_plugin_name;
else else
return true; return true;
@@ -1639,12 +1637,10 @@ static bool fix_lex_user(THD *thd, LEX_USER *user)
DBUG_ASSERT(user->plugin.length || !user->auth.length); DBUG_ASSERT(user->plugin.length || !user->auth.length);
DBUG_ASSERT(!(user->plugin.length && (user->pwtext.length || user->pwhash.length))); DBUG_ASSERT(!(user->plugin.length && (user->pwtext.length || user->pwhash.length)));
if (my_strcasecmp(system_charset_info, user->plugin.str, if (lex_string_eq(&user->plugin, &native_password_plugin_name) == 0)
native_password_plugin_name.str) == 0)
check_length= SCRAMBLED_PASSWORD_CHAR_LENGTH; check_length= SCRAMBLED_PASSWORD_CHAR_LENGTH;
else else
if (my_strcasecmp(system_charset_info, user->plugin.str, if (lex_string_eq(&user->plugin, &old_password_plugin_name) == 0)
old_password_plugin_name.str) == 0)
check_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; check_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323;
else else
if (user->plugin.length) if (user->plugin.length)
@@ -11200,7 +11196,7 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr)
if (!is_role) if (!is_role)
{ {
if (data->user->default_rolename.length && if (data->user->default_rolename.length &&
!strcmp(data->user->default_rolename.str, role->user.str)) !lex_string_eq(&data->user->default_rolename, &role->user))
table->field[3]->store(STRING_WITH_LEN("YES"), cs); table->field[3]->store(STRING_WITH_LEN("YES"), cs);
else else
table->field[3]->store(STRING_WITH_LEN("NO"), cs); table->field[3]->store(STRING_WITH_LEN("NO"), cs);
@@ -12769,8 +12765,8 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
restarted and a server auth plugin will read the data that the client restarted and a server auth plugin will read the data that the client
has just send. Cache them to return in the next server_mpvio_read_packet(). has just send. Cache them to return in the next server_mpvio_read_packet().
*/ */
if (my_strcasecmp(system_charset_info, mpvio->acl_user->plugin.str, if (lex_string_eq(&mpvio->acl_user->plugin,
plugin_name(mpvio->plugin)->str) != 0) plugin_name(mpvio->plugin)) != 0)
{ {
mpvio->cached_client_reply.pkt= passwd; mpvio->cached_client_reply.pkt= passwd;
mpvio->cached_client_reply.pkt_len= passwd_len; mpvio->cached_client_reply.pkt_len= passwd_len;
@@ -13200,8 +13196,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
{ {
DBUG_ASSERT(mpvio.acl_user); DBUG_ASSERT(mpvio.acl_user);
DBUG_ASSERT(command == COM_CHANGE_USER || DBUG_ASSERT(command == COM_CHANGE_USER ||
my_strcasecmp(system_charset_info, auth_plugin_name->str, lex_string_eq(auth_plugin_name, &mpvio.acl_user->plugin));
mpvio.acl_user->plugin.str));
auth_plugin_name= &mpvio.acl_user->plugin; auth_plugin_name= &mpvio.acl_user->plugin;
res= do_auth_once(thd, auth_plugin_name, &mpvio); res= do_auth_once(thd, auth_plugin_name, &mpvio);
} }

View File

@@ -1136,10 +1136,10 @@ void update_non_unique_table_error(TABLE_LIST *update,
update->view == duplicate->view || update->view == duplicate->view ||
update->view_name.length != duplicate->view_name.length || update->view_name.length != duplicate->view_name.length ||
update->view_db.length != duplicate->view_db.length || update->view_db.length != duplicate->view_db.length ||
my_strcasecmp(table_alias_charset, lex_string_cmp(table_alias_charset,
update->view_name.str, duplicate->view_name.str) != 0 || &update->view_name, &duplicate->view_name) != 0 ||
my_strcasecmp(table_alias_charset, lex_string_cmp(table_alias_charset,
update->view_db.str, duplicate->view_db.str) != 0) &update->view_db, &duplicate->view_db) != 0)
{ {
/* /*
it is not the same view repeated (but it can be parts of the same copy it is not the same view repeated (but it can be parts of the same copy
@@ -6107,8 +6107,8 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
item is not fix_field()'ed yet. item is not fix_field()'ed yet.
*/ */
if (item_field->field_name.str && item_field->table_name && if (item_field->field_name.str && item_field->table_name &&
!my_strcasecmp(system_charset_info, item_field->field_name.str, !lex_string_cmp(system_charset_info, &item_field->field_name,
field_name->str) && field_name) &&
!my_strcasecmp(table_alias_charset, item_field->table_name, !my_strcasecmp(table_alias_charset, item_field->table_name,
table_name) && table_name) &&
(!db_name || (item_field->db_name && (!db_name || (item_field->db_name &&
@@ -6137,11 +6137,11 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
} }
else else
{ {
int fname_cmp= my_strcasecmp(system_charset_info, bool fname_cmp= lex_string_cmp(system_charset_info,
item_field->field_name.str, &item_field->field_name,
field_name->str); field_name);
if (!my_strcasecmp(system_charset_info, if (!lex_string_cmp(system_charset_info,
item_field->name.str,field_name->str)) &item_field->name, field_name))
{ {
/* /*
If table name was not given we should scan through aliases If table name was not given we should scan through aliases
@@ -6187,7 +6187,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
{ {
if (is_ref_by_name && find->name.str && item->name.str && if (is_ref_by_name && find->name.str && item->name.str &&
find->name.length == item->name.length && find->name.length == item->name.length &&
!my_strcasecmp(system_charset_info,item->name.str, find->name.str)) !lex_string_cmp(system_charset_info, &item->name, &find->name))
{ {
found= li.ref(); found= li.ref();
*counter= i; *counter= i;
@@ -6404,8 +6404,8 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
here. These columns must be checked only on unqualified reference here. These columns must be checked only on unqualified reference
by name (e.g. in SELECT list). by name (e.g. in SELECT list).
*/ */
if (!my_strcasecmp(system_charset_info, field_name_1->str, if (!lex_string_cmp(system_charset_info, field_name_1,
cur_field_name_2->str)) cur_field_name_2))
{ {
DBUG_PRINT ("info", ("match c1.is_common=%d", nj_col_1->is_common)); DBUG_PRINT ("info", ("match c1.is_common=%d", nj_col_1->is_common));
if (cur_nj_col_2->is_common || if (cur_nj_col_2->is_common ||

View File

@@ -121,8 +121,8 @@ extern "C" void free_sequence_last(SEQUENCE_LAST_VALUE *entry)
bool Key_part_spec::operator==(const Key_part_spec& other) const bool Key_part_spec::operator==(const Key_part_spec& other) const
{ {
return length == other.length && return length == other.length &&
!my_strcasecmp(system_charset_info, field_name.str, !lex_string_cmp(system_charset_info, &field_name,
other.field_name.str); &other.field_name);
} }
/** /**
@@ -249,9 +249,9 @@ bool Foreign_key::validate(List<Create_field> &table_fields)
{ {
it.rewind(); it.rewind();
while ((sql_field= it++) && while ((sql_field= it++) &&
my_strcasecmp(system_charset_info, lex_string_cmp(system_charset_info,
column->field_name.str, &column->field_name,
sql_field->field_name.str)) {} &sql_field->field_name)) {}
if (!sql_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->field_name.str);

View File

@@ -6118,6 +6118,25 @@ public:
} }
}; };
/* Functions to compare if two lex strings are equal */
inline bool lex_string_cmp(CHARSET_INFO *charset,
const LEX_CSTRING *a,
const LEX_CSTRING *b)
{
return my_strcasecmp(charset, a->str, b->str);
}
/*
Compare if two LEX_CSTRING are equal. Assumption is that
character set is ASCII (like for plugin names)
*/
inline bool lex_string_eq(const LEX_CSTRING *a,
const LEX_CSTRING *b)
{
if (a->length != b->length)
return 1; /* Different */
return strcasecmp(a->str, b->str) != 0;
}
#endif /* MYSQL_SERVER */ #endif /* MYSQL_SERVER */

View File

@@ -129,8 +129,8 @@ bool With_clause::check_dependencies()
elem != with_elem; elem != with_elem;
elem= elem->next) elem= elem->next)
{ {
if (my_strcasecmp(system_charset_info, with_elem->query_name->str, if (lex_string_cmp(system_charset_info, with_elem->query_name,
elem->query_name->str) == 0) elem->query_name) == 0)
{ {
my_error(ER_DUP_QUERY_NAME, MYF(0), with_elem->query_name->str); my_error(ER_DUP_QUERY_NAME, MYF(0), with_elem->query_name->str);
return true; return true;

View File

@@ -5793,8 +5793,8 @@ bool LEX::sp_block_finalize(THD *thd, const Lex_spblock_st spblock,
if (sp_block_finalize(thd, spblock, &splabel)) if (sp_block_finalize(thd, spblock, &splabel))
return true; return true;
if (end_label->str && if (end_label->str &&
my_strcasecmp(system_charset_info, lex_string_cmp(system_charset_info,
end_label->str, splabel->name.str) != 0) end_label, &splabel->name) != 0)
{ {
my_error(ER_SP_LABEL_MISMATCH, MYF(0), end_label->str); my_error(ER_SP_LABEL_MISMATCH, MYF(0), end_label->str);
return true; return true;
@@ -6201,8 +6201,8 @@ bool LEX::sp_pop_loop_label(THD *thd, const LEX_CSTRING *label_name)
sp_label *lab= spcont->pop_label(); sp_label *lab= spcont->pop_label();
sphead->backpatch(lab); sphead->backpatch(lab);
if (label_name->str && if (label_name->str &&
my_strcasecmp(system_charset_info, label_name->str, lex_string_cmp(system_charset_info, label_name,
lab->name.str) != 0) &lab->name) != 0)
{ {
my_error(ER_SP_LABEL_MISMATCH, MYF(0), label_name->str); my_error(ER_SP_LABEL_MISMATCH, MYF(0), label_name->str);
return true; return true;

View File

@@ -3055,30 +3055,25 @@ static void check_duplicate_key(THD *thd, Key *key, KEY *key_info,
*/ */
List_iterator_fast<Key_part_spec> k_column_iterator(k->columns); List_iterator_fast<Key_part_spec> k_column_iterator(k->columns);
uint i;
bool all_columns_are_identical= true;
key_column_iterator.rewind(); key_column_iterator.rewind();
for (uint i= 0; i < key->columns.elements; ++i) for (i= 0; i < key->columns.elements; ++i)
{ {
Key_part_spec *c1= key_column_iterator++; Key_part_spec *c1= key_column_iterator++;
Key_part_spec *c2= k_column_iterator++; Key_part_spec *c2= k_column_iterator++;
DBUG_ASSERT(c1 && c2); DBUG_ASSERT(c1 && c2);
if (my_strcasecmp(system_charset_info, if (lex_string_cmp(system_charset_info,
c1->field_name.str, c2->field_name.str) || &c1->field_name, &c2->field_name) ||
(c1->length != c2->length)) (c1->length != c2->length))
{
all_columns_are_identical= false;
break; break;
}
} }
// Report a warning if we have two identical keys. // Report a warning if we have two identical keys.
if (all_columns_are_identical) if (i == key->columns.elements)
{ {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_DUP_INDEX, ER_THD(thd, ER_DUP_INDEX), ER_DUP_INDEX, ER_THD(thd, ER_DUP_INDEX),
@@ -3343,9 +3338,9 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
/* Check if we have used the same field name before */ /* Check if we have used the same field name before */
for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++) for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
{ {
if (my_strcasecmp(system_charset_info, if (lex_string_cmp(system_charset_info,
sql_field->field_name.str, &sql_field->field_name,
dup_field->field_name.str) == 0) &dup_field->field_name) == 0)
{ {
/* /*
If this was a CREATE ... SELECT statement, accept a field If this was a CREATE ... SELECT statement, accept a field
@@ -3677,9 +3672,9 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
it.rewind(); it.rewind();
field=0; field=0;
while ((sql_field=it++) && while ((sql_field=it++) &&
my_strcasecmp(system_charset_info, lex_string_cmp(system_charset_info,
column->field_name.str, &column->field_name,
sql_field->field_name.str)) &sql_field->field_name))
field++; field++;
if (!sql_field) if (!sql_field)
{ {
@@ -3688,8 +3683,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
} }
while ((dup_column= cols2++) != column) while ((dup_column= cols2++) != column)
{ {
if (!my_strcasecmp(system_charset_info, if (!lex_string_cmp(system_charset_info,
column->field_name.str, dup_column->field_name.str)) &column->field_name, &dup_column->field_name))
{ {
my_error(ER_DUP_FIELDNAME, MYF(0), column->field_name.str); my_error(ER_DUP_FIELDNAME, MYF(0), column->field_name.str);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
@@ -4056,9 +4051,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
Virtual_column_info *dup_check; Virtual_column_info *dup_check;
while ((dup_check= dup_it++) && dup_check != check) while ((dup_check= dup_it++) && dup_check != check)
{ {
if (check->name.length == dup_check->name.length && if (!lex_string_cmp(system_charset_info,
my_strcasecmp(system_charset_info, &check->name, &dup_check->name))
check->name.str, dup_check->name.str) == 0)
{ {
my_error(ER_DUP_CONSTRAINT_NAME, MYF(0), "CHECK", check->name.str); my_error(ER_DUP_CONSTRAINT_NAME, MYF(0), "CHECK", check->name.str);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
@@ -5655,8 +5649,9 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
*/ */
for (f_ptr=table->field; *f_ptr; f_ptr++) for (f_ptr=table->field; *f_ptr; f_ptr++)
{ {
if (my_strcasecmp(system_charset_info, if (lex_string_cmp(system_charset_info,
sql_field->field_name.str, (*f_ptr)->field_name.str) == 0) &sql_field->field_name,
&(*f_ptr)->field_name) == 0)
goto drop_create_field; goto drop_create_field;
} }
{ {
@@ -5668,8 +5663,9 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
Create_field *chk_field; Create_field *chk_field;
while ((chk_field= chk_it++) && chk_field != sql_field) while ((chk_field= chk_it++) && chk_field != sql_field)
{ {
if (my_strcasecmp(system_charset_info, if (lex_string_cmp(system_charset_info,
sql_field->field_name.str, chk_field->field_name.str) == 0) &sql_field->field_name,
&chk_field->field_name) == 0)
goto drop_create_field; goto drop_create_field;
} }
} }
@@ -5704,8 +5700,9 @@ drop_create_field:
*/ */
for (f_ptr=table->field; *f_ptr; f_ptr++) for (f_ptr=table->field; *f_ptr; f_ptr++)
{ {
if (my_strcasecmp(system_charset_info, if (lex_string_cmp(system_charset_info,
sql_field->change.str, (*f_ptr)->field_name.str) == 0) &sql_field->change,
&(*f_ptr)->field_name) == 0)
{ {
break; break;
} }
@@ -6024,8 +6021,8 @@ remove_key:
{ {
Virtual_column_info *dup= table->check_constraints[c]; Virtual_column_info *dup= table->check_constraints[c];
if (dup->name.length == check->name.length && if (dup->name.length == check->name.length &&
my_strcasecmp(system_charset_info, lex_string_cmp(system_charset_info,
check->name.str, dup->name.str) == 0) &check->name, &dup->name) == 0)
{ {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_DUP_CONSTRAINT_NAME, ER_THD(thd, ER_DUP_CONSTRAINT_NAME), ER_DUP_CONSTRAINT_NAME, ER_THD(thd, ER_DUP_CONSTRAINT_NAME),
@@ -6332,8 +6329,8 @@ static bool fill_alter_inplace_info(THD *thd,
} }
/* Check if field was renamed */ /* Check if field was renamed */
if (my_strcasecmp(system_charset_info, field->field_name.str, if (lex_string_cmp(system_charset_info, &field->field_name,
new_field->field_name.str)) &new_field->field_name))
{ {
field->flags|= FIELD_IS_RENAMED; field->flags|= FIELD_IS_RENAMED;
ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_NAME; ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_NAME;
@@ -6464,7 +6461,8 @@ static bool fill_alter_inplace_info(THD *thd,
new_key < new_key_end; new_key < new_key_end;
new_key++) new_key++)
{ {
if (! strcmp(table_key->name.str, new_key->name.str)) if (!lex_string_cmp(system_charset_info, &table_key->name,
&new_key->name))
break; break;
} }
if (new_key >= new_key_end) if (new_key >= new_key_end)
@@ -6555,7 +6553,8 @@ static bool fill_alter_inplace_info(THD *thd,
/* Search an old key with the same name. */ /* Search an old key with the same name. */
for (table_key= table->key_info; table_key < table_key_end; table_key++) for (table_key= table->key_info; table_key < table_key_end; table_key++)
{ {
if (! strcmp(table_key->name.str, new_key->name.str)) if (!lex_string_cmp(system_charset_info, &table_key->name,
&new_key->name))
break; break;
} }
if (table_key >= table_key_end) if (table_key >= table_key_end)
@@ -6789,9 +6788,9 @@ bool mysql_compare_tables(TABLE *table,
create_info->table_options|= HA_OPTION_PACK_RECORD; create_info->table_options|= HA_OPTION_PACK_RECORD;
/* Check if field was renamed */ /* Check if field was renamed */
if (my_strcasecmp(system_charset_info, if (lex_string_cmp(system_charset_info,
field->field_name.str, &field->field_name,
tmp_new_field->field_name.str)) &tmp_new_field->field_name))
DBUG_RETURN(false); DBUG_RETURN(false);
/* Evaluate changes bitmap and send to check_if_incompatible_data() */ /* Evaluate changes bitmap and send to check_if_incompatible_data() */
@@ -6818,7 +6817,8 @@ bool mysql_compare_tables(TABLE *table,
/* Search a key with the same name. */ /* Search a key with the same name. */
for (new_key= key_info_buffer; new_key < new_key_end; new_key++) for (new_key= key_info_buffer; new_key < new_key_end; new_key++)
{ {
if (! strcmp(table_key->name.str, new_key->name.str)) if (!lex_string_cmp(system_charset_info, &table_key->name,
&new_key->name))
break; break;
} }
if (new_key >= new_key_end) if (new_key >= new_key_end)
@@ -6857,7 +6857,8 @@ bool mysql_compare_tables(TABLE *table,
/* Search a key with the same name. */ /* Search a key with the same name. */
for (table_key= table->key_info; table_key < table_key_end; table_key++) for (table_key= table->key_info; table_key < table_key_end; table_key++)
{ {
if (! strcmp(table_key->name.str, new_key->name.str)) if (!lex_string_cmp(system_charset_info, &table_key->name,
&new_key->name))
break; break;
} }
if (table_key >= table_key_end) if (table_key >= table_key_end)
@@ -7505,8 +7506,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
while ((def=def_it++)) while ((def=def_it++))
{ {
if (def->change.str && if (def->change.str &&
!my_strcasecmp(system_charset_info,field->field_name.str, !lex_string_cmp(system_charset_info, &field->field_name,
def->change.str)) &def->change))
break; break;
} }
if (def) if (def)
@@ -7623,8 +7624,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
find_it.rewind(); find_it.rewind();
while ((find=find_it++)) while ((find=find_it++))
{ {
if (!my_strcasecmp(system_charset_info, def->after.str, if (!lex_string_cmp(system_charset_info, &def->after,
find->field_name.str)) &find->field_name))
break; break;
} }
if (!find) if (!find)
@@ -7990,8 +7991,8 @@ fk_check_column_changes(THD *thd, Alter_info *alter_info,
{ {
Field *old_field= new_field->field; Field *old_field= new_field->field;
if (my_strcasecmp(system_charset_info, old_field->field_name.str, if (lex_string_cmp(system_charset_info, &old_field->field_name,
new_field->field_name.str)) &new_field->field_name))
{ {
/* /*
Copy algorithm doesn't support proper renaming of columns in Copy algorithm doesn't support proper renaming of columns in
@@ -8104,10 +8105,10 @@ static bool fk_prepare_copy_alter_table(THD *thd, TABLE *table,
if ((drop->type == Alter_drop::FOREIGN_KEY) && if ((drop->type == Alter_drop::FOREIGN_KEY) &&
(my_strcasecmp(system_charset_info, f_key->foreign_id->str, (my_strcasecmp(system_charset_info, f_key->foreign_id->str,
drop->name) == 0) && drop->name) == 0) &&
(my_strcasecmp(table_alias_charset, f_key->foreign_db->str, (lex_string_cmp(table_alias_charset, f_key->foreign_db,
table->s->db.str) == 0) && &table->s->db) == 0) &&
(my_strcasecmp(table_alias_charset, f_key->foreign_table->str, (lex_string_cmp(table_alias_charset, f_key->foreign_table,
table->s->table_name.str) == 0)) &table->s->table_name) == 0))
fk_parent_key_it.remove(); fk_parent_key_it.remove();
} }
} }

View File

@@ -750,8 +750,8 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
DBUG_RETURN(true); DBUG_RETURN(true);
/* Trigger must be in the same schema as target table. */ /* Trigger must be in the same schema as target table. */
if (my_strcasecmp(table_alias_charset, table->s->db.str, if (lex_string_cmp(table_alias_charset, &table->s->db,
lex->spname->m_db.str)) &lex->spname->m_db))
{ {
my_error(ER_TRG_IN_WRONG_SCHEMA, MYF(0)); my_error(ER_TRG_IN_WRONG_SCHEMA, MYF(0));
DBUG_RETURN(true); DBUG_RETURN(true);
@@ -1084,8 +1084,8 @@ Trigger *Table_triggers_list::find_trigger(const LEX_CSTRING *name,
(trigger= *parent); (trigger= *parent);
parent= &trigger->next) parent= &trigger->next)
{ {
if (my_strcasecmp(table_alias_charset, if (lex_string_cmp(table_alias_charset,
trigger->name.str, name->str) == 0) &trigger->name, name) == 0)
{ {
if (remove_from_list) if (remove_from_list)
{ {
@@ -1633,8 +1633,8 @@ void Table_triggers_list::add_trigger(trg_event_type event,
for ( ; *parent ; parent= &(*parent)->next, position++) for ( ; *parent ; parent= &(*parent)->next, position++)
{ {
if (ordering_clause != TRG_ORDER_NONE && if (ordering_clause != TRG_ORDER_NONE &&
!my_strcasecmp(table_alias_charset, anchor_trigger_name->str, !lex_string_cmp(table_alias_charset, anchor_trigger_name,
(*parent)->name.str)) &(*parent)->name))
{ {
if (ordering_clause == TRG_ORDER_FOLLOWS) if (ordering_clause == TRG_ORDER_FOLLOWS)
{ {

View File

@@ -151,18 +151,18 @@ fk_truncate_illegal_if_parent(THD *thd, TABLE *table)
/* Loop over the set of foreign keys for which this table is a parent. */ /* Loop over the set of foreign keys for which this table is a parent. */
while ((fk_info= it++)) while ((fk_info= it++))
{ {
DBUG_ASSERT(!my_strcasecmp(system_charset_info, DBUG_ASSERT(!lex_string_cmp(system_charset_info,
fk_info->referenced_db->str, fk_info->referenced_db,
table->s->db.str)); &table->s->db));
DBUG_ASSERT(!my_strcasecmp(system_charset_info, DBUG_ASSERT(!lex_string_cmp(system_charset_info,
fk_info->referenced_table->str, fk_info->referenced_table,
table->s->table_name.str)); &table->s->table_name));
if (my_strcasecmp(system_charset_info, fk_info->foreign_db->str, if (lex_string_cmp(system_charset_info, fk_info->foreign_db,
table->s->db.str) || &table->s->db) ||
my_strcasecmp(system_charset_info, fk_info->foreign_table->str, lex_string_cmp(system_charset_info, fk_info->foreign_table,
table->s->table_name.str)) &table->s->table_name))
break; break;
} }

View File

@@ -140,7 +140,7 @@ bool check_duplicate_names(THD *thd, List<Item> &item_list, bool gen_unique_view
itc.rewind(); itc.rewind();
while ((check= itc++) && check != item) while ((check= itc++) && check != item)
{ {
if (my_strcasecmp(system_charset_info, item->name.str, check->name.str) == 0) if (lex_string_cmp(system_charset_info, &item->name, &check->name) == 0)
{ {
if (!gen_unique_view_name) if (!gen_unique_view_name)
goto err; goto err;

View File

@@ -251,30 +251,18 @@ TABLE_CATEGORY get_table_category(const LEX_CSTRING *db,
if (is_infoschema_db(db->str, db->length)) if (is_infoschema_db(db->str, db->length))
return TABLE_CATEGORY_INFORMATION; return TABLE_CATEGORY_INFORMATION;
if ((db->length == PERFORMANCE_SCHEMA_DB_NAME.length) && if (lex_string_eq(&PERFORMANCE_SCHEMA_DB_NAME, db) == 0)
(my_strcasecmp(system_charset_info,
PERFORMANCE_SCHEMA_DB_NAME.str,
db->str) == 0))
return TABLE_CATEGORY_PERFORMANCE; return TABLE_CATEGORY_PERFORMANCE;
if ((db->length == MYSQL_SCHEMA_NAME.length) && if (lex_string_eq(&MYSQL_SCHEMA_NAME, db) == 0)
(my_strcasecmp(system_charset_info,
MYSQL_SCHEMA_NAME.str,
db->str) == 0))
{ {
if (is_system_table_name(name->str, name->length)) if (is_system_table_name(name->str, name->length))
return TABLE_CATEGORY_SYSTEM; return TABLE_CATEGORY_SYSTEM;
if ((name->length == GENERAL_LOG_NAME.length) && if (lex_string_eq(&GENERAL_LOG_NAME, name) == 0)
(my_strcasecmp(system_charset_info,
GENERAL_LOG_NAME.str,
name->str) == 0))
return TABLE_CATEGORY_LOG; return TABLE_CATEGORY_LOG;
if ((name->length == SLOW_LOG_NAME.length) && if (lex_string_eq(&SLOW_LOG_NAME, name) == 0)
(my_strcasecmp(system_charset_info,
SLOW_LOG_NAME.str,
name->str) == 0))
return TABLE_CATEGORY_LOG; return TABLE_CATEGORY_LOG;
} }
@@ -8299,7 +8287,7 @@ Field *TABLE::find_field_by_name(LEX_CSTRING *str) const
for (Field **tmp= field; *tmp; tmp++) for (Field **tmp= field; *tmp; tmp++)
{ {
if ((*tmp)->field_name.length == length && if ((*tmp)->field_name.length == length &&
!my_strcasecmp(system_charset_info, (*tmp)->field_name.str, str->str)) !lex_string_cmp(system_charset_info, &(*tmp)->field_name, str))
return *tmp; return *tmp;
} }
return NULL; return NULL;