From 0b519a40751e1830b9a23016f398cd70b4dcd175 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 24 Sep 2022 11:26:08 +0200 Subject: [PATCH] cleanup --- sql/sql_acl.cc | 28 +++++++++++----------------- sql/sql_class.cc | 6 +----- sql/sql_yacc.yy | 3 +-- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 487f4c5d3dc..b8bb8343eba 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -281,8 +281,8 @@ public: uint counter; DYNAMIC_ARRAY parent_grantee; // array of backlinks to elements granted - ACL_ROLE(ACL_USER * user, MEM_ROOT *mem); - ACL_ROLE(const char * rolename, privilege_t privileges, MEM_ROOT *mem); + ACL_ROLE(ACL_USER *user); + ACL_ROLE(const char *rolename, privilege_t privileges, MEM_ROOT *mem); }; @@ -2182,7 +2182,7 @@ enum enum_acl_lists ROLES_MAPPINGS_HASH }; -ACL_ROLE::ACL_ROLE(ACL_USER *user, MEM_ROOT *root) +ACL_ROLE::ACL_ROLE(ACL_USER *user) : /* set initial role access the same as the table row privileges */ initial_role_access(user->access), @@ -2194,9 +2194,8 @@ ACL_ROLE::ACL_ROLE(ACL_USER *user, MEM_ROOT *root) flags= IS_ROLE; } -ACL_ROLE::ACL_ROLE(const char * rolename, privilege_t privileges, - MEM_ROOT *root) : - initial_role_access(privileges), counter(0) +ACL_ROLE::ACL_ROLE(const char *rolename, privilege_t privileges, MEM_ROOT *root) + : initial_role_access(privileges), counter(0) { this->access= initial_role_access; this->user.str= safe_strdup_root(root, rolename); @@ -2666,7 +2665,7 @@ static bool acl_load(THD *thd, const Grant_tables& tables) continue; } - ACL_ROLE *entry= new (&acl_memroot) ACL_ROLE(&user, &acl_memroot); + ACL_ROLE *entry= new (&acl_memroot) ACL_ROLE(&user); entry->role_grants = user.role_grants; my_init_dynamic_array(key_memory_acl_mem, &entry->parent_grantee, sizeof(ACL_USER_BASE *), 0, 8, MYF(0)); @@ -8518,16 +8517,13 @@ void GRANT_INFO::read(const Security_context *sctx, grant_table_user= grant_table_role= grant_public= NULL; #else grant_table_user= - table_hash_search(sctx->host, sctx->ip, db, - sctx->priv_user, + table_hash_search(sctx->host, sctx->ip, db, sctx->priv_user, table, FALSE); /* purecov: inspected */ grant_table_role= - sctx->priv_role[0] ? table_hash_search("", NULL, db, - sctx->priv_role, + sctx->priv_role[0] ? table_hash_search("", NULL, db, sctx->priv_role, table, TRUE) : NULL; grant_public= - acl_public ? table_hash_search("", NULL, db, - public_name.str, + acl_public ? table_hash_search("", NULL, db, public_name.str, table, TRUE) : NULL; #endif version= grant_version; /* purecov: inspected */ @@ -11211,8 +11207,7 @@ bool mysql_drop_user(THD *thd, List &list, bool handle_as_role) int rc; user_name= get_current_user(thd, tmp_user_name, false); if (!user_name || (handle_as_role && - (strcasecmp(user_name->user.str, - public_name.str) == 0))) + (strcasecmp(user_name->user.str, public_name.str) == 0))) { thd->clear_error(); if (!user_name) @@ -13010,8 +13005,7 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock) return dup; } - role_name_check_result result= check_role_name(user->user.str, - user->host.length == 0); + role_name_check_result result= check_role_name(user->user.str, true); if (result == ROLE_NAME_INVALID) return 0; if (result == ROLE_NAME_PUBLIC) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 78c2e682af0..5d51ed00ebc 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6024,11 +6024,7 @@ void THD::get_definer(LEX_USER *definer, bool role) { binlog_invoker(role); #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) -#ifdef WITH_WSREP - if ((wsrep_applier || slave_thread) && has_invoker()) -#else - if (slave_thread && has_invoker()) -#endif + if ((IF_WSREP(wsrep_applier, 0) || slave_thread) && has_invoker()) { definer->user= invoker.user; definer->host= invoker.host; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 5d0a2455228..d064576e48a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -17156,8 +17156,7 @@ grant_role: $$->host= empty_clex_str; if (unlikely(check_string_char_length(&$$->user, ER_USERNAME, - username_char_length, - cs, 0))) + username_char_length, cs, 0))) MYSQL_YYABORT; } | current_role