diff options
author | Tatiana A. Nurnberg <azundris@mysql.com> | 2009-10-20 20:37:33 -0700 |
---|---|---|
committer | Tatiana A. Nurnberg <azundris@mysql.com> | 2009-10-20 20:37:33 -0700 |
commit | 495cde347b1dad1cd93b7b4e15c721da9576c496 (patch) | |
tree | e50fdd49dc3aa5921096f4a025ee44fbc8155dd9 /sql | |
parent | 3f0d0d0633b121b2d615fe547bcd41518f49e810 (diff) | |
parent | c12dad02d6014a497fec4a61f3c1df39fa9ca7f2 (diff) | |
download | mariadb-git-495cde347b1dad1cd93b7b4e15c721da9576c496.tar.gz |
auto-merge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_acl.cc | 46 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 61 |
2 files changed, 81 insertions, 26 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 6ebdae49bd4..35047ca7407 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2255,6 +2255,8 @@ public: GRANT_NAME (TABLE *form); virtual ~GRANT_NAME() {}; virtual bool ok() { return privs != 0; } + void set_user_details(const char *h, const char *d, + const char *u, const char *t); }; @@ -2272,27 +2274,36 @@ public: }; - -GRANT_NAME::GRANT_NAME(const char *h, const char *d,const char *u, - const char *t, ulong p) - :privs(p) +void GRANT_NAME::set_user_details(const char *h, const char *d, + const char *u, const char *t) { /* Host given by user */ update_hostname(&host, strdup_root(&memex, h)); - db = strdup_root(&memex,d); + if (db != d) + { + db= strdup_root(&memex, d); + if (lower_case_table_names) + my_casedn_str(files_charset_info, db); + } user = strdup_root(&memex,u); sort= get_sort(3,host.hostname,db,user); - tname= strdup_root(&memex,t); - if (lower_case_table_names) + if (tname != t) { - my_casedn_str(files_charset_info, db); - my_casedn_str(files_charset_info, tname); + tname= strdup_root(&memex, t); + if (lower_case_table_names) + my_casedn_str(files_charset_info, tname); } key_length= strlen(d) + strlen(u)+ strlen(t)+3; hash_key= (char*) alloc_root(&memex,key_length); strmov(strmov(strmov(hash_key,user)+1,db)+1,tname); } +GRANT_NAME::GRANT_NAME(const char *h, const char *d,const char *u, + const char *t, ulong p) + :db(0), tname(0), privs(p) +{ + set_user_details(h, d, u, t); +} GRANT_TABLE::GRANT_TABLE(const char *h, const char *d,const char *u, const char *t, ulong p, ulong c) @@ -5436,9 +5447,20 @@ static int handle_grant_struct(uint struct_no, bool drop, case 2: case 3: - grant_name->user= strdup_root(&mem, user_to->user.str); - update_hostname(&grant_name->host, - strdup_root(&mem, user_to->host.str)); + /* + Update the grant structure with the new user name and + host name + */ + grant_name->set_user_details(user_to->host.str, grant_name->db, + user_to->user.str, grant_name->tname); + + /* + Since username is part of the hash key, when the user name + is renamed, the hash key is changed. Update the hash to + ensure that the position matches the new hash key value + */ + hash_update(&column_priv_hash, (uchar*) grant_name, + (uchar*) grant_name->hash_key, grant_name->key_length); break; } } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 37c583ad572..a837a10325b 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -11783,8 +11783,17 @@ option_type: ; option_type2: - /* empty */ { $$= OPT_DEFAULT; } - | ONE_SHOT_SYM { Lex->one_shot_set= 1; $$= OPT_SESSION; } + /* empty */ + { + $$= OPT_DEFAULT; + Lex->option_type= OPT_DEFAULT; + } + | ONE_SHOT_SYM + { + Lex->one_shot_set= 1; + $$= OPT_SESSION; + Lex->option_type= OPT_SESSION; + } ; opt_var_type: @@ -11795,10 +11804,26 @@ opt_var_type: ; opt_var_ident_type: - /* empty */ { $$=OPT_DEFAULT; } - | GLOBAL_SYM '.' { $$=OPT_GLOBAL; } - | LOCAL_SYM '.' { $$=OPT_SESSION; } - | SESSION_SYM '.' { $$=OPT_SESSION; } + /* empty */ + { + $$=OPT_DEFAULT; + Lex->option_type= OPT_DEFAULT; + } + | GLOBAL_SYM '.' + { + $$=OPT_GLOBAL; + Lex->option_type= OPT_GLOBAL; + } + | LOCAL_SYM '.' + { + $$=OPT_SESSION; + Lex->option_type= OPT_SESSION; + } + | SESSION_SYM '.' + { + $$=OPT_SESSION; + Lex->option_type= OPT_SESSION; + } ; ext_option_value: @@ -12038,8 +12063,22 @@ internal_variable_name: sp_pcontext *spc= lex->spcont; sp_variable_t *spv; - /* We have to lookup here since local vars can shadow sysvars */ - if (!spc || !(spv = spc->find_variable(&$1))) + /* + We have to lookup here since local vars can shadow sysvars. + + We also have to inspect the option_type first since the variable + identifier might have been prefixed with @@session or @@global + prefixes. Without this check we would wrongly identify them + as SP local variables. + */ + if (lex->option_type == OPT_DEFAULT && spc && + (spv= spc->find_variable(&$1))) + { + /* An SP local variable */ + $$.var= NULL; + $$.base_name= $1; + } + else { /* Not an SP local variable */ sys_var *tmp=find_sys_var(thd, $1.str, $1.length); @@ -12056,12 +12095,6 @@ internal_variable_name: lex->sphead->m_flags|= sp_head::HAS_SET_AUTOCOMMIT_STMT; } } - else - { - /* An SP local variable */ - $$.var= NULL; - $$.base_name= $1; - } } | ident '.' ident { |