diff options
author | Kristofer Pettersson <kristofer.pettersson@sun.com> | 2009-10-20 09:00:01 +0200 |
---|---|---|
committer | Kristofer Pettersson <kristofer.pettersson@sun.com> | 2009-10-20 09:00:01 +0200 |
commit | e942adb23dfca74fa8db76dbe40d72f0ceff4818 (patch) | |
tree | 18ffe8f677cc4ee9ebd5c16a4bd35c8cb8a7ff66 /sql | |
parent | c310a5c9e19679c241a8b6678ab4fe31c87adc18 (diff) | |
parent | f6048130c369b8db48184ae0cd4e41669fc43ddc (diff) | |
download | mariadb-git-e942adb23dfca74fa8db76dbe40d72f0ceff4818.tar.gz |
Automerge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_acl.cc | 46 |
1 files changed, 34 insertions, 12 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; } } |