MCPcopy Create free account
hub / github.com/MariaDB/server / acl_set_default_role

Function acl_set_default_role

sql/sql_acl.cc:4408–4545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4406}
4407
4408int acl_set_default_role(THD *thd,
4409 const LEX_CSTRING &host,
4410 const LEX_CSTRING &user,
4411 const LEX_CSTRING &rolename)
4412{
4413 Grant_tables tables;
4414 char user_key[MAX_KEY_LENGTH];
4415 int result= 1;
4416 int error;
4417 ulong query_length= 0;
4418 bool clear_role= FALSE;
4419 char buff[512];
4420 enum_binlog_format save_binlog_format= thd->get_current_stmt_binlog_format();
4421 const CSET_STRING query_save __attribute__((unused)) = thd->query_string;
4422
4423 DBUG_ENTER("acl_set_default_role");
4424 DBUG_PRINT("enter",("host: '%s' user: '%s' rolename: '%s'",
4425 user.str, safe_str(host.str), safe_str(rolename.str)));
4426
4427 if (!strcasecmp(rolename.str, none.str))
4428 clear_role= TRUE;
4429
4430 if (mysql_bin_log.is_open() ||
4431 (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0)))
4432 {
4433 query_length=
4434 snprintf(buff, sizeof(buff),
4435 "SET DEFAULT ROLE '%-.120s' FOR '%-.120s'@'%-.120s'",
4436 safe_str(rolename.str), user.str, safe_str(host.str));
4437 }
4438
4439 /*
4440 This statement will be replicated as a statement, even when using
4441 row-based replication. The flag will be reset at the end of the
4442 statement.
4443 This has to be handled here as it's called by set_var.cc, which is
4444 not automaticly handled by sql_parse.cc
4445 */
4446 save_binlog_format= thd->set_current_stmt_binlog_format_stmt();
4447
4448 if (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0))
4449 {
4450 thd->set_query(buff, query_length, system_charset_info);
4451 // Attention!!! here is implicit goto error;
4452 WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
4453 }
4454
4455 /*
4456 Extra block due to WSREP_TO_ISOLATION_BEGIN using goto.
4457 TODO(cvicentiu) Should move this block out in a new function.
4458 */
4459 {
4460 if ((result= tables.open_and_lock(thd, Table_user, TL_WRITE)))
4461 DBUG_RETURN(result != 1);
4462
4463 const User_table& user_table= tables.user_table();
4464 TABLE *table= user_table.table();
4465

Callers 1

updateMethod · 0.85

Calls 15

safe_strFunction · 0.85
find_user_exactFunction · 0.85
my_messageFunction · 0.85
safe_strdup_rootFunction · 0.85
key_copyFunction · 0.85
close_mysql_tablesFunction · 0.85
wsrep_to_isolation_endFunction · 0.85
open_and_lockMethod · 0.80
use_all_columnsMethod · 0.80
ha_index_read_idx_mapMethod · 0.80

Tested by

no test coverage detected