summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-01-23 16:08:24 +0100
committerSergei Golubchik <serg@mariadb.org>2016-01-25 17:04:14 +0100
commit1fea7e785f2de734fb3e278c9c0df2776f565c06 (patch)
tree0c0d377c94a2c518ebf503bafd62e8fc888e40b2 /sql
parentb01e2ff1cd5885eddbfcb2792222ed39548dbdd0 (diff)
downloadmariadb-git-1fea7e785f2de734fb3e278c9c0df2776f565c06.tar.gz
cleanup: create LEX_USER::reset_auth()
as this is used quite often
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_acl.cc6
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_parse.cc6
-rw-r--r--sql/sql_yacc.yy16
-rw-r--r--sql/structs.h6
5 files changed, 15 insertions, 23 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index cdfd731ffcb..71dedd30aaf 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -984,7 +984,7 @@ static bool fix_user_plugin_ptr(ACL_USER *user)
- if user->plugin is specified, user->auth is the plugin auth data.
- if user->plugin is mysql_native_password or mysql_old_password,
- user->auth if the password hash, and LEX_USER is transformed
+ user->auth is the password hash, and LEX_USER is transformed
to match the next case (that is, user->plugin is cleared).
- if user->plugin is NOT specified, built-in auth is assumed, that is
mysql_native_password or mysql_old_password. In that case,
@@ -10156,9 +10156,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
thd->make_lex_string(&combo->user, combo->user.str, strlen(combo->user.str));
thd->make_lex_string(&combo->host, combo->host.str, strlen(combo->host.str));
- combo->password= null_lex_str;
- combo->plugin= empty_lex_str;
- combo->auth= empty_lex_str;
+ combo->reset_auth();
if(au)
{
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 729b23cf993..421ad627190 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -5160,9 +5160,7 @@ void THD::get_definer(LEX_USER *definer, bool role)
{
definer->user = invoker_user;
definer->host= invoker_host;
- definer->password= null_lex_str;
- definer->plugin= empty_lex_str;
- definer->auth= empty_lex_str;
+ definer->reset_auth();
}
else
#endif
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index ba9dc7eb854..663864a95bd 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -8949,9 +8949,7 @@ void get_default_definer(THD *thd, LEX_USER *definer, bool role)
}
definer->user.length= strlen(definer->user.str);
- definer->password= null_lex_str;
- definer->plugin= empty_lex_str;
- definer->auth= empty_lex_str;
+ definer->reset_auth();
}
@@ -9009,7 +9007,7 @@ LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name)
definer->user= *user_name;
definer->host= *host_name;
- definer->password= null_lex_str;
+ definer->reset_auth();
return definer;
}
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 302c2fda7f0..241016672d8 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -14139,9 +14139,7 @@ user_maybe_role:
MYSQL_YYABORT;
$$->user = $1;
$$->host= null_lex_str; // User or Role, see get_current_user()
- $$->password= null_lex_str;
- $$->plugin= empty_lex_str;
- $$->auth= empty_lex_str;
+ $$->reset_auth();
if (check_string_char_length(&$$->user, ER_USERNAME,
username_char_length,
@@ -14153,9 +14151,7 @@ user_maybe_role:
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
MYSQL_YYABORT;
$$->user = $1; $$->host=$3;
- $$->password= null_lex_str;
- $$->plugin= empty_lex_str;
- $$->auth= empty_lex_str;
+ $$->reset_auth();
if (check_string_char_length(&$$->user, ER_USERNAME,
username_char_length,
@@ -15417,9 +15413,7 @@ current_role:
if (!($$=(LEX_USER*) thd->calloc(sizeof(LEX_USER))))
MYSQL_YYABORT;
$$->user= current_role;
- $$->password= null_lex_str;
- $$->plugin= empty_lex_str;
- $$->auth= empty_lex_str;
+ $$->reset_auth();
}
;
@@ -15438,9 +15432,7 @@ grant_role:
MYSQL_YYABORT;
$$->user = $1;
$$->host= empty_lex_str;
- $$->password= null_lex_str;
- $$->plugin= empty_lex_str;
- $$->auth= empty_lex_str;
+ $$->reset_auth();
if (check_string_char_length(&$$->user, ER_USERNAME,
username_char_length,
diff --git a/sql/structs.h b/sql/structs.h
index 191463af344..986b0d64bb0 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -211,6 +211,12 @@ typedef struct st_lex_user {
else
l->length= strxmov(l->str= buf, user.str, "@", host.str, NullS) - buf;
}
+ void reset_auth()
+ {
+ password.length= plugin.length= auth.length= 0;
+ password.str= 0;
+ plugin.str= auth.str= const_cast<char*>("");
+ }
} LEX_USER;
/*