diff options
author | Vicențiu Ciorbaru <cvicentiu@gmail.com> | 2015-02-09 17:16:55 +0200 |
---|---|---|
committer | Vicențiu Ciorbaru <cvicentiu@gmail.com> | 2015-02-09 17:16:55 +0200 |
commit | 4c69a6fff267f4c80ef1b360985b831932353c10 (patch) | |
tree | 14eff80432081255233bf086a9492215bab24156 /sql | |
parent | bceb0b0be10bfbcd49981fa48981ca9b491b868e (diff) | |
download | mariadb-git-4c69a6fff267f4c80ef1b360985b831932353c10.tar.gz |
MDEV-6918 Create a way to see a user's default role.
Added an extra column to i_s_applicable_roles, named IS_DEFAULT.
The column displays which role is the default role for the user
querying the table.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_acl.cc | 13 | ||||
-rw-r--r-- | sql/sql_show.cc | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 96fff6d6763..2c3257d0ada 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -10322,7 +10322,7 @@ struct APPLICABLE_ROLES_DATA TABLE *table; const LEX_STRING host; const LEX_STRING user_and_host; - ACL_USER_BASE *user; + ACL_USER *user; }; static int @@ -10349,6 +10349,17 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr) else table->field[2]->store(STRING_WITH_LEN("NO"), cs); + /* Default role is only valid when looking at a role granted to a user. */ + if (!is_role) + { + if (data->user->default_rolename.length && + !strcmp(data->user->default_rolename.str, role->user.str)) + table->field[3]->store(STRING_WITH_LEN("YES"), cs); + else + table->field[3]->store(STRING_WITH_LEN("NO"), cs); + table->field[3]->set_notnull(); + } + if (schema_table_store_record(table->in_use, table)) return -1; return 0; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1efd5c15c4d..20c40472d57 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -8220,6 +8220,7 @@ ST_FIELD_INFO applicable_roles_fields_info[]= {"GRANTEE", USERNAME_WITH_HOST_CHAR_LENGTH, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, {"ROLE_NAME", USERNAME_CHAR_LENGTH, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, {"IS_GRANTABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, + {"IS_DEFAULT", 3, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, SKIP_OPEN_TABLE}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; |