diff options
author | Georgi Kodinov <Georgi.Kodinov@Oracle.com> | 2010-11-19 16:35:04 +0200 |
---|---|---|
committer | Georgi Kodinov <Georgi.Kodinov@Oracle.com> | 2010-11-19 16:35:04 +0200 |
commit | bb642a5cc0b0d3cc7728eeb482a61dc87fe5b407 (patch) | |
tree | 34ee83260ea7cc0534cfc1a9ad802b0703ee14bb /sql/sql_acl.cc | |
parent | 41a03ab9cd900d22bc180287bd021fede7d54cfd (diff) | |
download | mariadb-git-bb642a5cc0b0d3cc7728eeb482a61dc87fe5b407.tar.gz |
Bug #57551: Live upgrade fails between 5.1.52 -> 5.5.7-rc
Updated the server to treat a missing mysql.proxies_priv table
as empty.
Added some grants to make sure tables are correctly opened
when they must be opened.
Fixed a mysql_upgrade omission not adding rights to root to
execute GRANT PROXY on other users.
Removed a redundant CREATE TABLE from
mysql_system_tables_fix.sql since it's always executed after
mysql_system_tables.sql and the first file has CREATE TABLE
in it.
Added a test case for the above.
Fixed error handling code to close the cursor
Diffstat (limited to 'sql/sql_acl.cc')
-rw-r--r-- | sql/sql_acl.cc | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index abd8f50cb9f..f21f204ef3f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1029,24 +1029,35 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) end_read_record(&read_record_info); freeze_size(&acl_dbs); - init_read_record(&read_record_info, thd, table= tables[3].table, NULL, 1, - 0, FALSE); - table->use_all_columns(); (void) my_init_dynamic_array(&acl_proxy_users, sizeof(ACL_PROXY_USER), 50, 100); - while (!(read_record_info.read_record(&read_record_info))) + if (tables[3].table) { - ACL_PROXY_USER proxy; - proxy.init(table, &mem); - if (proxy.check_validity(check_no_resolve)) - continue; - if (push_dynamic(&acl_proxy_users, (uchar*) &proxy)) - return TRUE; + init_read_record(&read_record_info, thd, table= tables[3].table, NULL, 1, + 0, FALSE); + table->use_all_columns(); + while (!(read_record_info.read_record(&read_record_info))) + { + ACL_PROXY_USER proxy; + proxy.init(table, &mem); + if (proxy.check_validity(check_no_resolve)) + continue; + if (push_dynamic(&acl_proxy_users, (uchar*) &proxy)) + { + end_read_record(&read_record_info); + goto end; + } + } + my_qsort((uchar*) dynamic_element(&acl_proxy_users, 0, ACL_PROXY_USER*), + acl_proxy_users.elements, + sizeof(ACL_PROXY_USER), (qsort_cmp) acl_compare); + end_read_record(&read_record_info); + } + else + { + sql_print_error("Missing system table mysql.proxies_priv; " + "please run mysql_upgrade to create it"); } - my_qsort((uchar*) dynamic_element(&acl_proxy_users, 0, ACL_PROXY_USER*), - acl_proxy_users.elements, - sizeof(ACL_PROXY_USER), (qsort_cmp) acl_compare); - end_read_record(&read_record_info); freeze_size(&acl_proxy_users); init_check_host(); @@ -1127,6 +1138,7 @@ my_bool acl_reload(THD *thd) tables[2].next_local= tables[2].next_global= tables + 3; tables[0].open_type= tables[1].open_type= tables[2].open_type= tables[3].open_type= OT_BASE_ONLY; + tables[3].open_strategy= TABLE_LIST::OPEN_IF_EXISTS; if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) { @@ -5703,6 +5715,8 @@ int open_grant_tables(THD *thd, TABLE_LIST *tables) (tables+5)->init_one_table(C_STRING_WITH_LEN("mysql"), C_STRING_WITH_LEN("proxies_priv"), "proxies_priv", TL_WRITE); + tables[5].open_strategy= TABLE_LIST::OPEN_IF_EXISTS; + tables->next_local= tables->next_global= tables + 1; (tables+1)->next_local= (tables+1)->next_global= tables + 2; (tables+2)->next_local= (tables+2)->next_global= tables + 3; @@ -6295,17 +6309,20 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle proxies_priv table. */ - if ((found= handle_grant_table(tables, 5, drop, user_from, user_to)) < 0) - { - /* Handle of table failed, don't touch the in-memory array. */ - result= -1; - } - else + if (tables[5].table) { - /* Handle proxies_priv array. */ - if ((handle_grant_struct(5, drop, user_from, user_to) && !result) || - found) - result= 1; /* At least one record/element found. */ + if ((found= handle_grant_table(tables, 5, drop, user_from, user_to)) < 0) + { + /* Handle of table failed, don't touch the in-memory array. */ + result= -1; + } + else + { + /* Handle proxies_priv array. */ + if ((handle_grant_struct(5, drop, user_from, user_to) && !result) || + found) + result= 1; /* At least one record/element found. */ + } } end: DBUG_RETURN(result); |