Skip to content

Commit 0537ce4

Browse files
committed
remove LEX_USER->is_public
it's now redundant
1 parent 5dc804c commit 0537ce4

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

sql/sql_acl.cc

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ LEX_CSTRING current_user_and_current_role=
108108
LEX_CSTRING none= {STRING_WITH_LEN("NONE") };
109109
LEX_CSTRING public_name= {STRING_WITH_LEN("PUBLIC") };
110110

111+
static inline bool is_public(const char *l) { return l == public_name.str; }
112+
static inline bool is_public(const LEX_CSTRING *l) { return is_public(l->str); }
113+
static inline bool is_public(const LEX_USER *l) { return is_public(&l->user); }
111114

112115
static plugin_ref old_password_plugin;
113116
static plugin_ref native_password_plugin;
@@ -2199,7 +2202,7 @@ ACL_ROLE::ACL_ROLE(const char *rolename, privilege_t privileges, MEM_ROOT *root)
21992202
: initial_role_access(privileges), counter(0)
22002203
{
22012204
this->access= initial_role_access;
2202-
if (rolename == public_name.str)
2205+
if (is_public(rolename))
22032206
this->user= public_name;
22042207
else
22052208
{
@@ -3597,8 +3600,8 @@ static void acl_insert_role(const char *rolename, privilege_t privileges)
35973600
sizeof(ACL_ROLE *), 0, 8, MYF(0));
35983601

35993602
my_hash_insert(&acl_roles, (uchar *)entry);
3600-
DBUG_ASSERT(strcasecmp(rolename, public_name.str) || rolename == public_name.str);
3601-
if (rolename == public_name.str)
3603+
DBUG_ASSERT(strcasecmp(rolename, public_name.str) || is_public(rolename));
3604+
if (is_public(rolename))
36023605
acl_public= entry;
36033606

36043607
DBUG_VOID_RETURN;
@@ -7275,7 +7278,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
72757278
error= copy_and_check_auth(Str, Str, thd) ||
72767279
replace_user_table(thd, tables.user_table(), Str,
72777280
NO_ACL, revoke_grant, create_new_users,
7278-
MY_TEST(!Str->is_public &&
7281+
MY_TEST(!is_public(Str) &&
72797282
(thd->variables.sql_mode &
72807283
MODE_NO_AUTO_CREATE_USER)));
72817284
if (unlikely(error))
@@ -7461,7 +7464,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list,
74617464
if (copy_and_check_auth(Str, tmp_Str, thd) ||
74627465
replace_user_table(thd, tables.user_table(), Str,
74637466
NO_ACL, revoke_grant, create_new_users,
7464-
!Str->is_public && (thd->variables.sql_mode &
7467+
!is_public(Str) && (thd->variables.sql_mode &
74657468
MODE_NO_AUTO_CREATE_USER)))
74667469
{
74677470
result= TRUE;
@@ -7707,7 +7710,6 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
77077710
continue;
77087711
case ROLE_NAME_PUBLIC:
77097712
user->host= hostname= empty_clex_str;
7710-
user->is_public= true;
77117713
role_as_user= acl_public;
77127714
break;
77137715
case ROLE_NAME_OK:
@@ -7726,7 +7728,7 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
77267728

77277729
if (has_auth(user, thd->lex))
77287730
DBUG_ASSERT(!grantee);
7729-
else if (!grantee && !user->is_public)
7731+
else if (!grantee && !is_public(user))
77307732
grantee= find_user_exact(hostname.str, username.str);
77317733

77327734
if (!grantee && !revoke)
@@ -7738,13 +7740,13 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
77387740
if (copy_and_check_auth(&user_combo, &user_combo, thd) ||
77397741
replace_user_table(thd, tables.user_table(), &user_combo, NO_ACL,
77407742
false, create_new_user,
7741-
(!user_combo.is_public && no_auto_create_user)))
7743+
(!is_public(&user_combo) && no_auto_create_user)))
77427744
{
77437745
append_user(thd, &wrong_users, &username, &hostname);
77447746
result= 1;
77457747
continue;
77467748
}
7747-
if (!user_combo.is_public)
7749+
if (!is_public(&user_combo))
77487750
grantee= find_user_exact(hostname.str, username.str);
77497751
else
77507752
grantee= role_as_user= acl_public;
@@ -7913,7 +7915,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
79137915
replace_user_table(thd, tables.user_table(), Str,
79147916
(!db ? rights : NO_ACL),
79157917
revoke_grant, create_new_users,
7916-
MY_TEST(!Str->is_public &&
7918+
MY_TEST(!is_public(Str) &&
79177919
(thd->variables.sql_mode &
79187920
MODE_NO_AUTO_CREATE_USER))))
79197921
result= true;
@@ -9464,7 +9466,7 @@ bool get_show_user(THD *thd, LEX_USER *lex_user, const char **username,
94649466
if (lex_user->is_role())
94659467
{
94669468
*rolename= lex_user->user.str;
9467-
do_check_access= !lex_user->is_public && strcmp(*rolename, sctx->priv_role);
9469+
do_check_access= !is_public(lex_user) && strcmp(*rolename, sctx->priv_role);
94689470
}
94699471
else
94709472
{
@@ -9772,7 +9774,7 @@ static void add_to_user(THD *thd, String *result, const char *user,
97729774
bool is_user, const char *host)
97739775
{
97749776
result->append(STRING_WITH_LEN(" TO "));
9775-
if (user == public_name.str)
9777+
if (is_public(user))
97769778
result->append(public_name);
97779779
else
97789780
append_identifier(thd, result, user, strlen(user));
@@ -11217,7 +11219,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list, bool handle_as_role)
1121711219
{
1121811220
int rc;
1121911221
user_name= get_current_user(thd, tmp_user_name, false);
11220-
if (!user_name || (handle_as_role && user_name->is_public))
11222+
if (!user_name || (handle_as_role && is_public(user_name)))
1122111223
{
1122211224
thd->clear_error();
1122311225
if (!user_name)
@@ -11909,7 +11911,6 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
1190911911
thd->make_lex_string(&combo->host, combo->host.str, strlen(combo->host.str));
1191011912

1191111913
combo->auth= NULL;
11912-
combo->is_public= false;
1191311914

1191411915
if (user_list.push_back(combo, thd->mem_root))
1191511916
DBUG_RETURN(TRUE);
@@ -13006,8 +13007,6 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock)
1300613007
if (!dup)
1300713008
return 0;
1300813009

13009-
dup->is_public= false;
13010-
1301113010
#ifndef NO_EMBEDDED_ACCESS_CHECKS
1301213011
if (has_auth(user, thd->lex))
1301313012
{
@@ -13020,7 +13019,6 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock)
1302013019
return 0;
1302113020
if (result == ROLE_NAME_PUBLIC)
1302213021
{
13023-
dup->is_public= true;
1302413022
dup->host= empty_clex_str;
1302513023
return dup;
1302613024
}

sql/sql_class.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6029,7 +6029,6 @@ void THD::get_definer(LEX_USER *definer, bool role)
60296029
definer->user= invoker.user;
60306030
definer->host= invoker.host;
60316031
definer->auth= NULL;
6032-
definer->is_public= false;
60336032
}
60346033
else
60356034
#endif

sql/sql_parse.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,7 +2801,7 @@ bool sp_process_definer(THD *thd)
28012801
LEX_USER *d= get_current_user(thd, lex->definer);
28022802
if (!d)
28032803
DBUG_RETURN(TRUE);
2804-
if (d->is_public)
2804+
if (d->user.str == public_name.str)
28052805
{
28062806
my_error(ER_INVALID_ROLE, MYF(0), lex->definer->user.str);
28072807
DBUG_RETURN(TRUE);
@@ -10064,7 +10064,6 @@ void get_default_definer(THD *thd, LEX_USER *definer, bool role)
1006410064
}
1006510065
definer->user.length= strlen(definer->user.str);
1006610066
definer->auth= NULL;
10067-
definer->is_public= false;
1006810067
}
1006910068

1007010069

sql/sql_yacc.yy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17155,10 +17155,7 @@ role_name: ident_or_text
1715517155
if (lex_string_eq(&$1, &none))
1715617156
$$->user= none;
1715717157
else if (lex_string_eq(&$1, &public_name))
17158-
{
1715917158
$$->user= public_name;
17160-
$$->is_public= true;
17161-
}
1716217159
else if (check_string_char_length(&($$->user= $1), ER_USERNAME,
1716317160
username_char_length, cs, 0))
1716417161
MYSQL_YYABORT;

sql/structs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ struct AUTHID
254254
struct LEX_USER: public AUTHID
255255
{
256256
USER_AUTH *auth;
257-
bool is_public;
258257
bool has_auth()
259258
{
260259
return auth && (auth->plugin.length || auth->auth_str.length || auth->pwtext.length);

0 commit comments

Comments
 (0)