diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-03-30 15:42:38 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-04-10 13:12:36 +0200 |
commit | 0dcb47cae93b8b25a1c1bd7ca31e0d2432df89f3 (patch) | |
tree | 66a8cc27516523dfe018550d8cdd8bf6c94bb1ce /sql | |
parent | 479bd5a6fe9966397ad40ab0a997b4d1901d8805 (diff) | |
download | mariadb-git-0dcb47cae93b8b25a1c1bd7ca31e0d2432df89f3.tar.gz |
change lex_string_eq to return what it says
the function xxx_eq(a,b) returns true if two elements
are equal and false if they are not.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/lex_string.h | 14 | ||||
-rw-r--r-- | sql/sql_acl.cc | 15 | ||||
-rw-r--r-- | sql/table.cc | 10 |
3 files changed, 18 insertions, 21 deletions
diff --git a/sql/lex_string.h b/sql/lex_string.h index 9df84f67b6a..64c90bd2ac9 100644 --- a/sql/lex_string.h +++ b/sql/lex_string.h @@ -21,9 +21,8 @@ typedef struct st_mysql_const_lex_string LEX_CSTRING; /* 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) +static inline bool lex_string_cmp(CHARSET_INFO *charset, const LEX_CSTRING *a, + const LEX_CSTRING *b) { return my_strcasecmp(charset, a->str, b->str); } @@ -31,7 +30,7 @@ inline bool lex_string_cmp(CHARSET_INFO *charset, /* Compare to LEX_CSTRING's and return 0 if equal */ -inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b) +static inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b) { return (a->length != b->length || memcmp(a->str, b->str, a->length)); @@ -41,12 +40,11 @@ inline bool cmp(const LEX_CSTRING *a, const LEX_CSTRING *b) 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) +static 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; + return 0; /* Different */ + return strcasecmp(a->str, b->str) == 0; } #endif /* LEX_STRING_INCLUDED */ diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 951471bca29..ec195f82069 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1482,10 +1482,10 @@ static const char *fix_plugin_ptr(const char *name) */ static bool fix_user_plugin_ptr(ACL_USER *user) { - if (lex_string_eq(&user->plugin, &native_password_plugin_name) == 0) + if (lex_string_eq(&user->plugin, &native_password_plugin_name)) user->plugin= native_password_plugin_name; else - if (lex_string_eq(&user->plugin, &old_password_plugin_name) == 0) + if (lex_string_eq(&user->plugin, &old_password_plugin_name)) user->plugin= old_password_plugin_name; else return true; @@ -1525,10 +1525,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 (lex_string_eq(&user->plugin, &native_password_plugin_name) == 0) + if (lex_string_eq(&user->plugin, &native_password_plugin_name)) check_length= SCRAMBLED_PASSWORD_CHAR_LENGTH; else - if (lex_string_eq(&user->plugin, &old_password_plugin_name) == 0) + if (lex_string_eq(&user->plugin, &old_password_plugin_name)) check_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; else if (user->plugin.length) @@ -11213,7 +11213,7 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr) if (!is_role) { if (data->user->default_rolename.length && - !lex_string_eq(&data->user->default_rolename, &role->user)) + 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); @@ -12825,8 +12825,7 @@ 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 (lex_string_eq(&mpvio->acl_user->plugin, - plugin_name(mpvio->plugin)) != 0) + if (!lex_string_eq(&mpvio->acl_user->plugin, plugin_name(mpvio->plugin))) { mpvio->cached_client_reply.pkt= passwd; mpvio->cached_client_reply.pkt_len= (uint)passwd_len; @@ -13256,7 +13255,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len) { DBUG_ASSERT(mpvio.acl_user); DBUG_ASSERT(command == COM_CHANGE_USER || - lex_string_eq(auth_plugin_name, &mpvio.acl_user->plugin)); + !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/table.cc b/sql/table.cc index 7eeeb09681a..1e585392caf 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -252,21 +252,21 @@ TABLE_CATEGORY get_table_category(const LEX_CSTRING *db, if (is_infoschema_db(db)) return TABLE_CATEGORY_INFORMATION; - if (lex_string_eq(&PERFORMANCE_SCHEMA_DB_NAME, db) == 0) + if (lex_string_eq(&PERFORMANCE_SCHEMA_DB_NAME, db)) return TABLE_CATEGORY_PERFORMANCE; - if (lex_string_eq(&MYSQL_SCHEMA_NAME, db) == 0) + if (lex_string_eq(&MYSQL_SCHEMA_NAME, db)) { if (is_system_table_name(name->str, name->length)) return TABLE_CATEGORY_SYSTEM; - if (lex_string_eq(&GENERAL_LOG_NAME, name) == 0) + if (lex_string_eq(&GENERAL_LOG_NAME, name)) return TABLE_CATEGORY_LOG; - if (lex_string_eq(&SLOW_LOG_NAME, name) == 0) + if (lex_string_eq(&SLOW_LOG_NAME, name)) return TABLE_CATEGORY_LOG; - if (lex_string_eq(&TRANSACTION_REG_NAME, name) == 0) + if (lex_string_eq(&TRANSACTION_REG_NAME, name)) return TABLE_CATEGORY_LOG; } |