Commit 4abc2020 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru Committed by Sergei Golubchik

Refactored yacc grammar to make use of named constants.

parent febd6445
...@@ -184,6 +184,17 @@ static LEX_STRING old_password_plugin_name= { ...@@ -184,6 +184,17 @@ static LEX_STRING old_password_plugin_name= {
/// @todo make it configurable /// @todo make it configurable
LEX_STRING *default_auth_plugin_name= &native_password_plugin_name; LEX_STRING *default_auth_plugin_name= &native_password_plugin_name;
/*
Constant used for differentiating specified user names and non specified
usernames. Example: userA -- userA@%
*/
const char *HOST_NOT_SPECIFIED= "%";
/*
Constant used in the SET ROLE NONE command
*/
const char *NONE_ROLE= "NONE";
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
static plugin_ref old_password_plugin; static plugin_ref old_password_plugin;
#endif #endif
......
...@@ -173,6 +173,9 @@ enum mysql_db_table_field ...@@ -173,6 +173,9 @@ enum mysql_db_table_field
extern const TABLE_FIELD_DEF mysql_db_table_def; extern const TABLE_FIELD_DEF mysql_db_table_def;
extern bool mysql_user_table_is_in_short_password_format; extern bool mysql_user_table_is_in_short_password_format;
extern const char *HOST_NOT_SPECIFIED;
extern const char *NONE_ROLE;
static inline int access_denied_error_code(int passwd_used) static inline int access_denied_error_code(int passwd_used)
{ {
......
...@@ -1570,7 +1570,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1570,7 +1570,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <symbol> keyword keyword_sp %type <symbol> keyword keyword_sp
%type <lex_user> user specified_user grant_user role %type <lex_user> user grant_user
%type <charset> %type <charset>
opt_collate opt_collate
...@@ -1624,7 +1624,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1624,7 +1624,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
opt_option opt_place opt_option opt_place
opt_attribute opt_attribute_list attribute column_list column_list_id opt_attribute opt_attribute_list attribute column_list column_list_id
opt_column_list grant_privileges grant_ident grant_list grant_option opt_column_list grant_privileges grant_ident grant_list grant_option
grant_list_with_roles
object_privilege object_privilege_list user_list rename_list object_privilege object_privilege_list user_list rename_list
clear_privileges flush_options flush_option clear_privileges flush_options flush_option
opt_with_read_lock flush_options_list opt_with_read_lock flush_options_list
...@@ -13163,8 +13162,24 @@ ident_or_text: ...@@ -13163,8 +13162,24 @@ ident_or_text:
| LEX_HOSTNAME { $$=$1;} | LEX_HOSTNAME { $$=$1;}
; ;
specified_user: user:
ident_or_text '@' ident_or_text ident_or_text
{
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
MYSQL_YYABORT;
$$->user = $1;
$$->host.str= (char *)HOST_NOT_SPECIFIED;
$$->host.length= 1;
$$->password= null_lex_str;
$$->plugin= empty_lex_str;
$$->auth= empty_lex_str;
if (check_string_char_length(&$$->user, ER(ER_USERNAME),
username_char_length,
system_charset_info, 0))
MYSQL_YYABORT;
}
| ident_or_text '@' ident_or_text
{ {
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user)))) if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
MYSQL_YYABORT; MYSQL_YYABORT;
...@@ -13198,46 +13213,6 @@ specified_user: ...@@ -13198,46 +13213,6 @@ specified_user:
} }
; ;
user:
ident_or_text
{
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
MYSQL_YYABORT;
$$->user = $1;
$$->host.str= (char *) "%";
$$->host.length= 1;
$$->password= null_lex_str;
$$->plugin= empty_lex_str;
$$->auth= empty_lex_str;
if (check_string_char_length(&$$->user, ER(ER_USERNAME),
username_char_length,
system_charset_info, 0))
MYSQL_YYABORT;
}
|
specified_user {$$ = $1;}
;
role:
ident_or_text
{
if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
MYSQL_YYABORT;
$$->user = $1;
$$->host.str= (char *) "";
$$->host.length= 0;
$$->password= null_lex_str;
$$->plugin= empty_lex_str;
$$->auth= empty_lex_str;
if (check_string_char_length(&$$->user, ER(ER_USERNAME),
username_char_length,
system_charset_info, 0))
MYSQL_YYABORT;
}
;
/* Keyword that we allow for identifiers (except SP labels) */ /* Keyword that we allow for identifiers (except SP labels) */
keyword: keyword:
keyword_sp {} keyword_sp {}
...@@ -14271,7 +14246,7 @@ revoke_command: ...@@ -14271,7 +14246,7 @@ revoke_command:
lex->sql_command= SQLCOM_REVOKE; lex->sql_command= SQLCOM_REVOKE;
lex->type= TYPE_ENUM_PROXY; lex->type= TYPE_ENUM_PROXY;
} }
| grant_role FROM grant_list_with_roles | grant_role FROM grant_list
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_REVOKE_ROLE; lex->sql_command= SQLCOM_REVOKE_ROLE;
...@@ -14325,7 +14300,7 @@ grant_command: ...@@ -14325,7 +14300,7 @@ grant_command:
lex->sql_command= SQLCOM_GRANT; lex->sql_command= SQLCOM_GRANT;
lex->type= TYPE_ENUM_PROXY; lex->type= TYPE_ENUM_PROXY;
} }
| grant_role TO_SYM grant_list_with_roles | grant_role TO_SYM grant_list
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_GRANT_ROLE; lex->sql_command= SQLCOM_GRANT_ROLE;
...@@ -14520,30 +14495,6 @@ user_list: ...@@ -14520,30 +14495,6 @@ user_list:
} }
; ;
grant_list_with_roles:
role
{
if (Lex->users_list.push_back($1))
MYSQL_YYABORT;
}
| specified_user
{
if (Lex->users_list.push_back($1))
MYSQL_YYABORT;
}
| grant_list_with_roles ',' role
{
if (Lex->users_list.push_back($3))
MYSQL_YYABORT;
}
| grant_list_with_roles ',' specified_user
{
if (Lex->users_list.push_back($3))
MYSQL_YYABORT;
}
;
grant_list: grant_list:
grant_user grant_user
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment