summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2017-06-18 14:00:28 +0300
committerSergei Golubchik <serg@mariadb.org>2017-08-24 01:05:53 +0200
commit25c06f5282513e15c25c54364ef886310126e870 (patch)
tree4a695cd4d445e7af0739dc4485e8fb14b3d6451f
parentcc77f9882dcaa4e02196bb3847cd66f2943eb4c6 (diff)
downloadmariadb-git-25c06f5282513e15c25c54364ef886310126e870.tar.gz
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
-rw-r--r--sql/item.cc19
-rw-r--r--sql/sp_head.cc4
-rw-r--r--sql/sp_pcontext.cc8
-rw-r--r--sql/sql_acl.cc21
-rw-r--r--sql/sql_base.cc28
-rw-r--r--sql/sql_class.cc10
-rw-r--r--sql/sql_class.h19
-rw-r--r--sql/sql_cte.cc4
-rw-r--r--sql/sql_lex.cc8
-rw-r--r--sql/sql_table.cc97
-rw-r--r--sql/sql_trigger.cc12
-rw-r--r--sql/sql_truncate.cc24
-rw-r--r--sql/sql_view.cc2
-rw-r--r--sql/table.cc22
14 files changed, 139 insertions, 139 deletions
diff --git a/sql/item.cc b/sql/item.cc
index e4fcaa42c6f..5840e4a4081 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1184,8 +1184,7 @@ bool Item::eq(const Item *item, bool binary_cmp) const
type() can be only among basic constant types.
*/
return type() == item->type() && name.str && item->name.str &&
- name.length == item->name.length &&
- !my_strcasecmp(system_charset_info, name.str, item->name.str);
+ !lex_string_cmp(system_charset_info, &name, &item->name);
}
@@ -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
ER_NON_UNIQ_ERROR).
*/
- return (!my_strcasecmp(system_charset_info, item_field->name.str,
- field_name.str) &&
+ return (!lex_string_cmp(system_charset_info, &item_field->name,
+ &field_name) &&
(!item_field->table_name || !table_name ||
(!my_strcasecmp(table_alias_charset, item_field->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 */
if ((*(cur_group->item))->name.str &&
!(*(cur_group->item))->is_autogenerated_name &&
- !my_strcasecmp(system_charset_info,
- (*(cur_group->item))->name.str, field_name->str))
+ !lex_string_cmp(system_charset_info,
+ &(*(cur_group->item))->name, field_name))
{
++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);
- if (!my_strcasecmp(system_charset_info,
- l_field_name->str, field_name->str))
+ if (!lex_string_cmp(system_charset_info,
+ l_field_name, field_name))
++cur_match_degree;
else
continue;
@@ -9116,8 +9115,8 @@ bool Item_trigger_field::eq(const Item *item, bool binary_cmp) const
{
return item->type() == TRIGGER_FIELD_ITEM &&
row_version == ((Item_trigger_field *)item)->row_version &&
- !my_strcasecmp(system_charset_info, field_name.str,
- ((Item_trigger_field *)item)->field_name.str);
+ !lex_string_cmp(system_charset_info, &field_name,
+ &((Item_trigger_field *)item)->field_name);
}
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index c1a194ab9b9..ebd8dd5b8d2 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -2303,9 +2303,7 @@ sp_head::backpatch_goto(THD *thd, sp_label *lab,sp_label *lab_begin_block)
*/
continue;
}
- if (my_strcasecmp(system_charset_info,
- bp->lab->name.str,
- lab->name.str) == 0)
+ if (lex_string_cmp(system_charset_info, &bp->lab->name, &lab->name) == 0)
{
if (bp->instr_type == GOTO)
{
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
index 87dfed2a8d3..1e2081e3479 100644
--- a/sql/sp_pcontext.cc
+++ b/sql/sp_pcontext.cc
@@ -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)
{
- return (my_strcasecmp(system_charset_info, a->name.str, b->name.str) == 0
- && a->type == b->type);
+ return (lex_string_cmp(system_charset_info, &a->name, &b->name) == 0 &&
+ a->type == b->type);
}
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++))
{
- 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;
}
@@ -341,7 +341,7 @@ sp_label *sp_pcontext::find_label(const LEX_CSTRING *name)
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;
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 81859d2fed6..193a51efbc1 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1594,12 +1594,10 @@ static const char *fix_plugin_ptr(const char *name)
*/
static bool fix_user_plugin_ptr(ACL_USER *user)
{
- if (my_strcasecmp(system_charset_info, user->plugin.str,
- native_password_plugin_name.str) == 0)
+ if (lex_string_eq(&user->plugin, &native_password_plugin_name) == 0)
user->plugin= native_password_plugin_name;
else
- if (my_strcasecmp(system_charset_info, user->plugin.str,
- old_password_plugin_name.str) == 0)
+ if (lex_string_eq(&user->plugin, &old_password_plugin_name) == 0)
user->plugin= old_password_plugin_name;
else
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->pwtext.length || user->pwhash.length)));
- if (my_strcasecmp(system_charset_info, user->plugin.str,
- native_password_plugin_name.str) == 0)
+ if (lex_string_eq(&user->plugin, &native_password_plugin_name) == 0)
check_length= SCRAMBLED_PASSWORD_CHAR_LENGTH;
else
- if (my_strcasecmp(system_charset_info, user->plugin.str,
- old_password_plugin_name.str) == 0)
+ if (lex_string_eq(&user->plugin, &old_password_plugin_name) == 0)
check_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323;
else
if (user->plugin.length)
@@ -11200,7 +11196,7 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr)
if (!is_role)
{
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);
else
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
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,
- plugin_name(mpvio->plugin)->str) != 0)
+ if (lex_string_eq(&mpvio->acl_user->plugin,
+ plugin_name(mpvio->plugin)) != 0)
{
mpvio->cached_client_reply.pkt= passwd;
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(command == COM_CHANGE_USER ||
- my_strcasecmp(system_charset_info, auth_plugin_name->str,
- mpvio.acl_user->plugin.str));
+ lex_string_eq(auth_plugin_name, &mpvio.acl_user->plugin));
auth_plugin_name= &mpvio.acl_user->plugin;
res= do_auth_once(thd, auth_plugin_name, &mpvio);
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 9d295f713ce..f3710c48192 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1136,10 +1136,10 @@ void update_non_unique_table_error(TABLE_LIST *update,
update->view == duplicate->view ||
update->view_name.length != duplicate->view_name.length ||
update->view_db.length != duplicate->view_db.length ||
- my_strcasecmp(table_alias_charset,
- update->view_name.str, duplicate->view_name.str) != 0 ||
- my_strcasecmp(table_alias_charset,
- update->view_db.str, duplicate->view_db.str) != 0)
+ lex_string_cmp(table_alias_charset,
+ &update->view_name, &duplicate->view_name) != 0 ||
+ lex_string_cmp(table_alias_charset,
+ &update->view_db, &duplicate->view_db) != 0)
{
/*
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.
*/
if (item_field->field_name.str && item_field->table_name &&
- !my_strcasecmp(system_charset_info, item_field->field_name.str,
- field_name->str) &&
+ !lex_string_cmp(system_charset_info, &item_field->field_name,
+ field_name) &&
!my_strcasecmp(table_alias_charset, item_field->table_name,
table_name) &&
(!db_name || (item_field->db_name &&
@@ -6137,11 +6137,11 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter,
}
else
{
- int fname_cmp= my_strcasecmp(system_charset_info,
- item_field->field_name.str,
- field_name->str);
- if (!my_strcasecmp(system_charset_info,
- item_field->name.str,field_name->str))
+ bool fname_cmp= lex_string_cmp(system_charset_info,
+ &item_field->field_name,
+ field_name);
+ if (!lex_string_cmp(system_charset_info,
+ &item_field->name, field_name))
{
/*
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 &&
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();
*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
by name (e.g. in SELECT list).
*/
- if (!my_strcasecmp(system_charset_info, field_name_1->str,
- cur_field_name_2->str))
+ if (!lex_string_cmp(system_charset_info, field_name_1,
+ cur_field_name_2))
{
DBUG_PRINT ("info", ("match c1.is_common=%d", nj_col_1->is_common));
if (cur_nj_col_2->is_common ||
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 1e18326ec20..21aa24e0d15 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -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
{
return length == other.length &&
- !my_strcasecmp(system_charset_info, field_name.str,
- other.field_name.str);
+ !lex_string_cmp(system_charset_info, &field_name,
+ &other.field_name);
}
/**
@@ -249,9 +249,9 @@ bool Foreign_key::validate(List<Create_field> &table_fields)
{
it.rewind();
while ((sql_field= it++) &&
- my_strcasecmp(system_charset_info,
- column->field_name.str,
- sql_field->field_name.str)) {}
+ lex_string_cmp(system_charset_info,
+ &column->field_name,
+ &sql_field->field_name)) {}
if (!sql_field)
{
my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), column->field_name.str);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 46bd2f6a2b7..74857a94471 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -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 */
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index 8045eb7eb63..2047c7c8762 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -129,8 +129,8 @@ bool With_clause::check_dependencies()
elem != with_elem;
elem= elem->next)
{
- if (my_strcasecmp(system_charset_info, with_elem->query_name->str,
- elem->query_name->str) == 0)
+ if (lex_string_cmp(system_charset_info, with_elem->query_name,
+ elem->query_name) == 0)
{
my_error(ER_DUP_QUERY_NAME, MYF(0), with_elem->query_name->str);
return true;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index c71c1e6f378..e06a35003bd 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -5793,8 +5793,8 @@ bool LEX::sp_block_finalize(THD *thd, const Lex_spblock_st spblock,
if (sp_block_finalize(thd, spblock, &splabel))
return true;
if (end_label->str &&
- my_strcasecmp(system_charset_info,
- end_label->str, splabel->name.str) != 0)
+ lex_string_cmp(system_charset_info,
+ end_label, &splabel->name) != 0)
{
my_error(ER_SP_LABEL_MISMATCH, MYF(0), end_label->str);
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();
sphead->backpatch(lab);
if (label_name->str &&
- my_strcasecmp(system_charset_info, label_name->str,
- lab->name.str) != 0)
+ lex_string_cmp(system_charset_info, label_name,
+ &lab->name) != 0)
{
my_error(ER_SP_LABEL_MISMATCH, MYF(0), label_name->str);
return true;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 7ed4d5d3fa4..dd04fdafa74 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -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);
-
- bool all_columns_are_identical= true;
-
+ uint i;
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 *c2= k_column_iterator++;
DBUG_ASSERT(c1 && c2);
- if (my_strcasecmp(system_charset_info,
- c1->field_name.str, c2->field_name.str) ||
+ if (lex_string_cmp(system_charset_info,
+ &c1->field_name, &c2->field_name) ||
(c1->length != c2->length))
- {
- all_columns_are_identical= false;
break;
- }
}
// 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,
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 */
for (dup_no=0; (dup_field=it2++) != sql_field; dup_no++)
{
- if (my_strcasecmp(system_charset_info,
- sql_field->field_name.str,
- dup_field->field_name.str) == 0)
+ if (lex_string_cmp(system_charset_info,
+ &sql_field->field_name,
+ &dup_field->field_name) == 0)
{
/*
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();
field=0;
while ((sql_field=it++) &&
- my_strcasecmp(system_charset_info,
- column->field_name.str,
- sql_field->field_name.str))
+ lex_string_cmp(system_charset_info,
+ &column->field_name,
+ &sql_field->field_name))
field++;
if (!sql_field)
{
@@ -3688,8 +3683,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
}
while ((dup_column= cols2++) != column)
{
- if (!my_strcasecmp(system_charset_info,
- column->field_name.str, dup_column->field_name.str))
+ if (!lex_string_cmp(system_charset_info,
+ &column->field_name, &dup_column->field_name))
{
my_error(ER_DUP_FIELDNAME, MYF(0), column->field_name.str);
DBUG_RETURN(TRUE);
@@ -4056,9 +4051,8 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
Virtual_column_info *dup_check;
while ((dup_check= dup_it++) && dup_check != check)
{
- if (check->name.length == dup_check->name.length &&
- my_strcasecmp(system_charset_info,
- check->name.str, dup_check->name.str) == 0)
+ if (!lex_string_cmp(system_charset_info,
+ &check->name, &dup_check->name))
{
my_error(ER_DUP_CONSTRAINT_NAME, MYF(0), "CHECK", check->name.str);
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++)
{
- if (my_strcasecmp(system_charset_info,
- sql_field->field_name.str, (*f_ptr)->field_name.str) == 0)
+ if (lex_string_cmp(system_charset_info,
+ &sql_field->field_name,
+ &(*f_ptr)->field_name) == 0)
goto drop_create_field;
}
{
@@ -5668,8 +5663,9 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
Create_field *chk_field;
while ((chk_field= chk_it++) && chk_field != sql_field)
{
- if (my_strcasecmp(system_charset_info,
- sql_field->field_name.str, chk_field->field_name.str) == 0)
+ if (lex_string_cmp(system_charset_info,
+ &sql_field->field_name,
+ &chk_field->field_name) == 0)
goto drop_create_field;
}
}
@@ -5704,8 +5700,9 @@ drop_create_field:
*/
for (f_ptr=table->field; *f_ptr; f_ptr++)
{
- if (my_strcasecmp(system_charset_info,
- sql_field->change.str, (*f_ptr)->field_name.str) == 0)
+ if (lex_string_cmp(system_charset_info,
+ &sql_field->change,
+ &(*f_ptr)->field_name) == 0)
{
break;
}
@@ -6024,8 +6021,8 @@ remove_key:
{
Virtual_column_info *dup= table->check_constraints[c];
if (dup->name.length == check->name.length &&
- my_strcasecmp(system_charset_info,
- check->name.str, dup->name.str) == 0)
+ lex_string_cmp(system_charset_info,
+ &check->name, &dup->name) == 0)
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
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 */
- if (my_strcasecmp(system_charset_info, field->field_name.str,
- new_field->field_name.str))
+ if (lex_string_cmp(system_charset_info, &field->field_name,
+ &new_field->field_name))
{
field->flags|= FIELD_IS_RENAMED;
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++)
{
- if (! strcmp(table_key->name.str, new_key->name.str))
+ if (!lex_string_cmp(system_charset_info, &table_key->name,
+ &new_key->name))
break;
}
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. */
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;
}
if (table_key >= table_key_end)
@@ -6789,9 +6788,9 @@ bool mysql_compare_tables(TABLE *table,
create_info->table_options|= HA_OPTION_PACK_RECORD;
/* Check if field was renamed */
- if (my_strcasecmp(system_charset_info,
- field->field_name.str,
- tmp_new_field->field_name.str))
+ if (lex_string_cmp(system_charset_info,
+ &field->field_name,
+ &tmp_new_field->field_name))
DBUG_RETURN(false);
/* 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. */
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;
}
if (new_key >= new_key_end)
@@ -6857,7 +6857,8 @@ 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.str, new_key->name.str))
+ if (!lex_string_cmp(system_charset_info, &table_key->name,
+ &new_key->name))
break;
}
if (table_key >= table_key_end)
@@ -7505,8 +7506,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
while ((def=def_it++))
{
if (def->change.str &&
- !my_strcasecmp(system_charset_info,field->field_name.str,
- def->change.str))
+ !lex_string_cmp(system_charset_info, &field->field_name,
+ &def->change))
break;
}
if (def)
@@ -7623,8 +7624,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
find_it.rewind();
while ((find=find_it++))
{
- if (!my_strcasecmp(system_charset_info, def->after.str,
- find->field_name.str))
+ if (!lex_string_cmp(system_charset_info, &def->after,
+ &find->field_name))
break;
}
if (!find)
@@ -7990,8 +7991,8 @@ fk_check_column_changes(THD *thd, Alter_info *alter_info,
{
Field *old_field= new_field->field;
- if (my_strcasecmp(system_charset_info, old_field->field_name.str,
- new_field->field_name.str))
+ if (lex_string_cmp(system_charset_info, &old_field->field_name,
+ &new_field->field_name))
{
/*
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) &&
(my_strcasecmp(system_charset_info, f_key->foreign_id->str,
drop->name) == 0) &&
- (my_strcasecmp(table_alias_charset, f_key->foreign_db->str,
- table->s->db.str) == 0) &&
- (my_strcasecmp(table_alias_charset, f_key->foreign_table->str,
- table->s->table_name.str) == 0))
+ (lex_string_cmp(table_alias_charset, f_key->foreign_db,
+ &table->s->db) == 0) &&
+ (lex_string_cmp(table_alias_charset, f_key->foreign_table,
+ &table->s->table_name) == 0))
fk_parent_key_it.remove();
}
}
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 7e3f047ef91..dcce8ae3724 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -750,8 +750,8 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables,
DBUG_RETURN(true);
/* Trigger must be in the same schema as target table. */
- if (my_strcasecmp(table_alias_charset, table->s->db.str,
- lex->spname->m_db.str))
+ if (lex_string_cmp(table_alias_charset, &table->s->db,
+ &lex->spname->m_db))
{
my_error(ER_TRG_IN_WRONG_SCHEMA, MYF(0));
DBUG_RETURN(true);
@@ -1084,8 +1084,8 @@ Trigger *Table_triggers_list::find_trigger(const LEX_CSTRING *name,
(trigger= *parent);
parent= &trigger->next)
{
- if (my_strcasecmp(table_alias_charset,
- trigger->name.str, name->str) == 0)
+ if (lex_string_cmp(table_alias_charset,
+ &trigger->name, name) == 0)
{
if (remove_from_list)
{
@@ -1633,8 +1633,8 @@ void Table_triggers_list::add_trigger(trg_event_type event,
for ( ; *parent ; parent= &(*parent)->next, position++)
{
if (ordering_clause != TRG_ORDER_NONE &&
- !my_strcasecmp(table_alias_charset, anchor_trigger_name->str,
- (*parent)->name.str))
+ !lex_string_cmp(table_alias_charset, anchor_trigger_name,
+ &(*parent)->name))
{
if (ordering_clause == TRG_ORDER_FOLLOWS)
{
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc
index 13b553f8b71..1d6edbc5fc9 100644
--- a/sql/sql_truncate.cc
+++ b/sql/sql_truncate.cc
@@ -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. */
while ((fk_info= it++))
{
- DBUG_ASSERT(!my_strcasecmp(system_charset_info,
- fk_info->referenced_db->str,
- table->s->db.str));
-
- DBUG_ASSERT(!my_strcasecmp(system_charset_info,
- fk_info->referenced_table->str,
- table->s->table_name.str));
-
- if (my_strcasecmp(system_charset_info, fk_info->foreign_db->str,
- table->s->db.str) ||
- my_strcasecmp(system_charset_info, fk_info->foreign_table->str,
- table->s->table_name.str))
+ DBUG_ASSERT(!lex_string_cmp(system_charset_info,
+ fk_info->referenced_db,
+ &table->s->db));
+
+ DBUG_ASSERT(!lex_string_cmp(system_charset_info,
+ fk_info->referenced_table,
+ &table->s->table_name));
+
+ if (lex_string_cmp(system_charset_info, fk_info->foreign_db,
+ &table->s->db) ||
+ lex_string_cmp(system_charset_info, fk_info->foreign_table,
+ &table->s->table_name))
break;
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 0547a3cb343..26941e9d6e7 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -140,7 +140,7 @@ bool check_duplicate_names(THD *thd, List<Item> &item_list, bool gen_unique_view
itc.rewind();
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)
goto err;
diff --git a/sql/table.cc b/sql/table.cc
index 5182bbbb1d6..142d0a76997 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -251,30 +251,18 @@ TABLE_CATEGORY get_table_category(const LEX_CSTRING *db,
if (is_infoschema_db(db->str, db->length))
return TABLE_CATEGORY_INFORMATION;
- if ((db->length == PERFORMANCE_SCHEMA_DB_NAME.length) &&
- (my_strcasecmp(system_charset_info,
- PERFORMANCE_SCHEMA_DB_NAME.str,
- db->str) == 0))
+ if (lex_string_eq(&PERFORMANCE_SCHEMA_DB_NAME, db) == 0)
return TABLE_CATEGORY_PERFORMANCE;
- if ((db->length == MYSQL_SCHEMA_NAME.length) &&
- (my_strcasecmp(system_charset_info,
- MYSQL_SCHEMA_NAME.str,
- db->str) == 0))
+ if (lex_string_eq(&MYSQL_SCHEMA_NAME, db) == 0)
{
if (is_system_table_name(name->str, name->length))
return TABLE_CATEGORY_SYSTEM;
- if ((name->length == GENERAL_LOG_NAME.length) &&
- (my_strcasecmp(system_charset_info,
- GENERAL_LOG_NAME.str,
- name->str) == 0))
+ if (lex_string_eq(&GENERAL_LOG_NAME, name) == 0)
return TABLE_CATEGORY_LOG;
- if ((name->length == SLOW_LOG_NAME.length) &&
- (my_strcasecmp(system_charset_info,
- SLOW_LOG_NAME.str,
- name->str) == 0))
+ if (lex_string_eq(&SLOW_LOG_NAME, name) == 0)
return TABLE_CATEGORY_LOG;
}
@@ -8299,7 +8287,7 @@ Field *TABLE::find_field_by_name(LEX_CSTRING *str) const
for (Field **tmp= field; *tmp; tmp++)
{
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 NULL;