| 8227 | */ |
| 8228 | |
| 8229 | static bool grant_load(THD *thd, |
| 8230 | const Tables_priv_table& tables_priv, |
| 8231 | const Columns_priv_table& columns_priv, |
| 8232 | const Procs_priv_table& procs_priv) |
| 8233 | { |
| 8234 | bool return_val= 1; |
| 8235 | TABLE *t_table, *c_table, *p_table; |
| 8236 | MEM_ROOT *save_mem_root= thd->mem_root; |
| 8237 | DBUG_ENTER("grant_load"); |
| 8238 | |
| 8239 | Sql_mode_instant_remove sms(thd, MODE_PAD_CHAR_TO_FULL_LENGTH); |
| 8240 | |
| 8241 | (void) my_hash_init(key_memory_acl_memex, &column_priv_hash, |
| 8242 | &my_charset_utf8mb3_bin, 0, 0, 0, get_grant_table, |
| 8243 | free_grant_table, 0); |
| 8244 | (void) my_hash_init(key_memory_acl_memex, &proc_priv_hash, |
| 8245 | &my_charset_utf8mb3_bin, 0, 0, 0, get_grant_table, 0, 0); |
| 8246 | (void) my_hash_init(key_memory_acl_memex, &func_priv_hash, |
| 8247 | &my_charset_utf8mb3_bin, 0, 0, 0, get_grant_table, 0, 0); |
| 8248 | (void) my_hash_init(key_memory_acl_memex, &package_spec_priv_hash, |
| 8249 | &my_charset_utf8mb3_bin, 0, 0, 0, get_grant_table, 0, 0); |
| 8250 | (void) my_hash_init(key_memory_acl_memex, &package_body_priv_hash, |
| 8251 | &my_charset_utf8mb3_bin, 0, 0, 0, get_grant_table, 0, 0); |
| 8252 | init_sql_alloc(key_memory_acl_mem, &grant_memroot, ACL_ALLOC_BLOCK_SIZE, 0, MYF(0)); |
| 8253 | |
| 8254 | t_table= tables_priv.table(); |
| 8255 | c_table= columns_priv.table(); |
| 8256 | p_table= procs_priv.table(); // this can be NULL |
| 8257 | |
| 8258 | if (t_table->file->ha_index_init(0, 1)) |
| 8259 | goto end_index_init; |
| 8260 | |
| 8261 | t_table->use_all_columns(); |
| 8262 | c_table->use_all_columns(); |
| 8263 | |
| 8264 | thd->mem_root= &grant_memroot; |
| 8265 | |
| 8266 | if (!t_table->file->ha_index_first(t_table->record[0])) |
| 8267 | { |
| 8268 | do |
| 8269 | { |
| 8270 | GRANT_TABLE *mem_check; |
| 8271 | /* TODO(cvicentiu) convert this to use tables_priv and columns_priv. */ |
| 8272 | if (!(mem_check= new (&grant_memroot) GRANT_TABLE(t_table, c_table))) |
| 8273 | { |
| 8274 | /* This could only happen if we are out memory */ |
| 8275 | goto end_unlock; |
| 8276 | } |
| 8277 | |
| 8278 | if (opt_skip_name_resolve) |
| 8279 | { |
| 8280 | if (hostname_requires_resolving(mem_check->host.hostname)) |
| 8281 | { |
| 8282 | sql_print_warning("'tables_priv' entry '%s %s@%s' " |
| 8283 | "ignored in --skip-name-resolve mode.", |
| 8284 | mem_check->tname, mem_check->user, |
| 8285 | safe_str(mem_check->host.hostname)); |
| 8286 | continue; |
no test coverage detected