| 5256 | } |
| 5257 | |
| 5258 | bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, |
| 5259 | ulong rights, bool revoke_grant, bool is_proxy) |
| 5260 | { |
| 5261 | List_iterator <LEX_USER> str_list (list); |
| 5262 | LEX_USER *Str, *tmp_Str, *proxied_user= NULL; |
| 5263 | char tmp_db[NAME_LEN+1]; |
| 5264 | bool create_new_users=0; |
| 5265 | TABLE_LIST tables[2]; |
| 5266 | bool save_binlog_row_based; |
| 5267 | bool transactional_tables; |
| 5268 | DBUG_ENTER("mysql_grant"); |
| 5269 | if (!initialized) |
| 5270 | { |
| 5271 | my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), |
| 5272 | "--skip-grant-tables"); /* purecov: tested */ |
| 5273 | DBUG_RETURN(TRUE); /* purecov: tested */ |
| 5274 | } |
| 5275 | |
| 5276 | if (lower_case_table_names && db) |
| 5277 | { |
| 5278 | strnmov(tmp_db,db,NAME_LEN); |
| 5279 | tmp_db[NAME_LEN]= '\0'; |
| 5280 | my_casedn_str(files_charset_info, tmp_db); |
| 5281 | db=tmp_db; |
| 5282 | } |
| 5283 | |
| 5284 | if (is_proxy) |
| 5285 | { |
| 5286 | DBUG_ASSERT(!db); |
| 5287 | proxied_user= str_list++; |
| 5288 | } |
| 5289 | |
| 5290 | /* open the mysql.user and mysql.db or mysql.proxies_priv tables */ |
| 5291 | tables[0].init_one_table(C_STRING_WITH_LEN("mysql"), |
| 5292 | C_STRING_WITH_LEN("user"), "user", TL_WRITE); |
| 5293 | if (is_proxy) |
| 5294 | |
| 5295 | tables[1].init_one_table(C_STRING_WITH_LEN("mysql"), |
| 5296 | C_STRING_WITH_LEN("proxies_priv"), |
| 5297 | "proxies_priv", |
| 5298 | TL_WRITE); |
| 5299 | else |
| 5300 | tables[1].init_one_table(C_STRING_WITH_LEN("mysql"), |
| 5301 | C_STRING_WITH_LEN("db"), |
| 5302 | "db", |
| 5303 | TL_WRITE); |
| 5304 | tables[0].next_local= tables[0].next_global= tables+1; |
| 5305 | |
| 5306 | /* |
| 5307 | This statement will be replicated as a statement, even when using |
| 5308 | row-based replication. The flag will be reset at the end of the |
| 5309 | statement. |
| 5310 | */ |
| 5311 | if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row())) |
| 5312 | thd->clear_current_stmt_binlog_format_row(); |
| 5313 | |
| 5314 | #ifdef HAVE_REPLICATION |
| 5315 | /* |
nothing calls this directly
no test coverage detected