summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <cvicentiu@gmail.com>2015-02-09 17:16:55 +0200
committerVicențiu Ciorbaru <cvicentiu@gmail.com>2015-02-09 17:16:55 +0200
commit4c69a6fff267f4c80ef1b360985b831932353c10 (patch)
tree14eff80432081255233bf086a9492215bab24156
parentbceb0b0be10bfbcd49981fa48981ca9b491b868e (diff)
downloadmariadb-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.
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_is.result2
-rw-r--r--mysql-test/suite/funcs_1/r/is_columns_is_embedded.result46
-rw-r--r--mysql-test/suite/funcs_1/r/is_tables_is_embedded.result184
-rw-r--r--mysql-test/suite/roles/admin.result28
-rw-r--r--mysql-test/suite/roles/drop_current_user-5176.result2
-rw-r--r--mysql-test/suite/roles/i_s_applicable_roles_is_default.result80
-rw-r--r--mysql-test/suite/roles/i_s_applicable_roles_is_default.test62
-rw-r--r--mysql-test/suite/roles/recursive.result24
-rw-r--r--mysql-test/suite/roles/recursive_dbug.result24
-rw-r--r--mysql-test/suite/roles/show_grants.result16
-rw-r--r--sql/sql_acl.cc13
-rw-r--r--sql/sql_show.cc1
12 files changed, 434 insertions, 48 deletions
diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result
index dc4b08763b9..b89854c0e88 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_is.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_is.result
@@ -17,6 +17,7 @@ def information_schema ALL_PLUGINS PLUGIN_TYPE 4 NO varchar 80 240 NULL NULL NU
def information_schema ALL_PLUGINS PLUGIN_TYPE_VERSION 5 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20) select
def information_schema ALL_PLUGINS PLUGIN_VERSION 2 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20) select
def information_schema APPLICABLE_ROLES GRANTEE 1 NO varchar 190 570 NULL NULL NULL utf8 utf8_general_ci varchar(190) select
+def information_schema APPLICABLE_ROLES IS_DEFAULT 4 NULL YES varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
def information_schema APPLICABLE_ROLES IS_GRANTABLE 3 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select
def information_schema APPLICABLE_ROLES ROLE_NAME 2 NO varchar 128 384 NULL NULL NULL utf8 utf8_general_ci varchar(128) select
def information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
@@ -543,6 +544,7 @@ COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH C
3.0000 information_schema APPLICABLE_ROLES GRANTEE varchar 190 570 utf8 utf8_general_ci varchar(190)
3.0000 information_schema APPLICABLE_ROLES ROLE_NAME varchar 128 384 utf8 utf8_general_ci varchar(128)
3.0000 information_schema APPLICABLE_ROLES IS_GRANTABLE varchar 3 9 utf8 utf8_general_ci varchar(3)
+3.0000 information_schema APPLICABLE_ROLES IS_DEFAULT varchar 3 9 utf8 utf8_general_ci varchar(3)
3.0000 information_schema CHARACTER_SETS CHARACTER_SET_NAME varchar 32 96 utf8 utf8_general_ci varchar(32)
3.0000 information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME varchar 32 96 utf8 utf8_general_ci varchar(32)
3.0000 information_schema CHARACTER_SETS DESCRIPTION varchar 60 180 utf8 utf8_general_ci varchar(60)
diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
index c480b241752..b1177cadd19 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
@@ -17,6 +17,7 @@ def information_schema ALL_PLUGINS PLUGIN_TYPE 4 NO varchar 80 240 NULL NULL NU
def information_schema ALL_PLUGINS PLUGIN_TYPE_VERSION 5 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20)
def information_schema ALL_PLUGINS PLUGIN_VERSION 2 NO varchar 20 60 NULL NULL NULL utf8 utf8_general_ci varchar(20)
def information_schema APPLICABLE_ROLES GRANTEE 1 NO varchar 190 570 NULL NULL NULL utf8 utf8_general_ci varchar(190)
+def information_schema APPLICABLE_ROLES IS_DEFAULT 4 NULL YES varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
def information_schema APPLICABLE_ROLES IS_GRANTABLE 3 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3)
def information_schema APPLICABLE_ROLES ROLE_NAME 2 NO varchar 128 384 NULL NULL NULL utf8 utf8_general_ci varchar(128)
def information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
@@ -197,6 +198,20 @@ def information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA 10 NULL YES varc
def information_schema KEY_COLUMN_USAGE TABLE_CATALOG 4 NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
def information_schema KEY_COLUMN_USAGE TABLE_NAME 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
def information_schema KEY_COLUMN_USAGE TABLE_SCHEMA 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+def information_schema LOCALES DECIMAL_POINT 6 NO varchar 2 6 NULL NULL NULL utf8 utf8_general_ci varchar(2)
+def information_schema LOCALES DESCRIPTION 3 NO varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255)
+def information_schema LOCALES ERROR_MESSAGE_LANGUAGE 8 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+def information_schema LOCALES ID 1 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+def information_schema LOCALES MAX_DAY_NAME_LENGTH 5 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+def information_schema LOCALES MAX_MONTH_NAME_LENGTH 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(4)
+def information_schema LOCALES NAME 2 NO varchar 255 765 NULL NULL NULL utf8 utf8_general_ci varchar(255)
+def information_schema LOCALES THOUSAND_SEP 7 NO varchar 2 6 NULL NULL NULL utf8 utf8_general_ci varchar(2)
+def information_schema METADATA_LOCK_INFO LOCK_DURATION 3 NULL YES varchar 30 90 NULL NULL NULL utf8 utf8_general_ci varchar(30)
+def information_schema METADATA_LOCK_INFO LOCK_MODE 2 NULL YES varchar 24 72 NULL NULL NULL utf8 utf8_general_ci varchar(24)
+def information_schema METADATA_LOCK_INFO LOCK_TYPE 4 NULL YES varchar 30 90 NULL NULL NULL utf8 utf8_general_ci varchar(30)
+def information_schema METADATA_LOCK_INFO TABLE_NAME 6 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+def information_schema METADATA_LOCK_INFO TABLE_SCHEMA 5 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
+def information_schema METADATA_LOCK_INFO THREAD_ID 1 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned
def information_schema PARAMETERS CHARACTER_MAXIMUM_LENGTH 8 NULL YES int NULL NULL 10 0 NULL NULL NULL int(21)
def information_schema PARAMETERS CHARACTER_OCTET_LENGTH 9 NULL YES int NULL NULL 10 0 NULL NULL NULL int(21)
def information_schema PARAMETERS CHARACTER_SET_NAME 13 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
@@ -266,6 +281,14 @@ def information_schema PROCESSLIST STATE 7 NULL YES varchar 64 192 NULL NULL NUL
def information_schema PROCESSLIST TIME 6 0 NO int NULL NULL 10 0 NULL NULL NULL int(7)
def information_schema PROCESSLIST TIME_MS 9 0.000 NO decimal NULL NULL 22 3 NULL NULL NULL decimal(22,3)
def information_schema PROCESSLIST USER 2 NO varchar 128 384 NULL NULL NULL utf8 utf8_general_ci varchar(128)
+def information_schema QUERY_CACHE_INFO RESULT_BLOCKS_COUNT 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(11)
+def information_schema QUERY_CACHE_INFO RESULT_BLOCKS_SIZE 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(11)
+def information_schema QUERY_CACHE_INFO RESULT_BLOCKS_SIZE_USED 5 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(11)
+def information_schema QUERY_CACHE_INFO STATEMENT_SCHEMA 1 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192)
+def information_schema QUERY_CACHE_INFO STATEMENT_TEXT 2 NULL NO longtext 4294967295 4294967295 NULL NULL NULL utf8 utf8_general_ci longtext
+def information_schema QUERY_RESPONSE_TIME COUNT 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned
+def information_schema QUERY_RESPONSE_TIME TIME 1 NO varchar 14 42 NULL NULL NULL utf8 utf8_general_ci varchar(14)
+def information_schema QUERY_RESPONSE_TIME TOTAL 3 NO varchar 14 42 NULL NULL NULL utf8 utf8_general_ci varchar(14)
def information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG 1 NO varchar 512 1536 NULL NULL NULL utf8 utf8_general_ci varchar(512)
def information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME 3 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
def information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA 2 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64)
@@ -543,6 +566,7 @@ COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH C
3.0000 information_schema APPLICABLE_ROLES GRANTEE varchar 190 570 utf8 utf8_general_ci varchar(190)
3.0000 information_schema APPLICABLE_ROLES ROLE_NAME varchar 128 384 utf8 utf8_general_ci varchar(128)
3.0000 information_schema APPLICABLE_ROLES IS_GRANTABLE varchar 3 9 utf8 utf8_general_ci varchar(3)
+3.0000 information_schema APPLICABLE_ROLES IS_DEFAULT varchar 3 9 utf8 utf8_general_ci varchar(3)
3.0000 information_schema CHARACTER_SETS CHARACTER_SET_NAME varchar 32 96 utf8 utf8_general_ci varchar(32)
3.0000 information_schema CHARACTER_SETS DEFAULT_COLLATE_NAME varchar 32 96 utf8 utf8_general_ci varchar(32)
3.0000 information_schema CHARACTER_SETS DESCRIPTION varchar 60 180 utf8 utf8_general_ci varchar(60)
@@ -721,6 +745,20 @@ NULL information_schema KEY_COLUMN_USAGE POSITION_IN_UNIQUE_CONSTRAINT bigint NU
3.0000 information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema KEY_COLUMN_USAGE REFERENCED_TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema KEY_COLUMN_USAGE REFERENCED_COLUMN_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
+NULL information_schema LOCALES ID bigint NULL NULL NULL NULL bigint(4)
+3.0000 information_schema LOCALES NAME varchar 255 765 utf8 utf8_general_ci varchar(255)
+3.0000 information_schema LOCALES DESCRIPTION varchar 255 765 utf8 utf8_general_ci varchar(255)
+NULL information_schema LOCALES MAX_MONTH_NAME_LENGTH bigint NULL NULL NULL NULL bigint(4)
+NULL information_schema LOCALES MAX_DAY_NAME_LENGTH bigint NULL NULL NULL NULL bigint(4)
+3.0000 information_schema LOCALES DECIMAL_POINT varchar 2 6 utf8 utf8_general_ci varchar(2)
+3.0000 information_schema LOCALES THOUSAND_SEP varchar 2 6 utf8 utf8_general_ci varchar(2)
+3.0000 information_schema LOCALES ERROR_MESSAGE_LANGUAGE varchar 64 192 utf8 utf8_general_ci varchar(64)
+NULL information_schema METADATA_LOCK_INFO THREAD_ID bigint NULL NULL NULL NULL bigint(20) unsigned
+3.0000 information_schema METADATA_LOCK_INFO LOCK_MODE varchar 24 72 utf8 utf8_general_ci varchar(24)
+3.0000 information_schema METADATA_LOCK_INFO LOCK_DURATION varchar 30 90 utf8 utf8_general_ci varchar(30)
+3.0000 information_schema METADATA_LOCK_INFO LOCK_TYPE varchar 30 90 utf8 utf8_general_ci varchar(30)
+3.0000 information_schema METADATA_LOCK_INFO TABLE_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64)
+3.0000 information_schema METADATA_LOCK_INFO TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema PARAMETERS SPECIFIC_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
3.0000 information_schema PARAMETERS SPECIFIC_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema PARAMETERS SPECIFIC_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
@@ -790,6 +828,14 @@ NULL information_schema PROCESSLIST PROGRESS decimal NULL NULL NULL NULL decimal
NULL information_schema PROCESSLIST MEMORY_USED int NULL NULL NULL NULL int(7)
NULL information_schema PROCESSLIST EXAMINED_ROWS int NULL NULL NULL NULL int(7)
NULL information_schema PROCESSLIST QUERY_ID bigint NULL NULL NULL NULL bigint(4)
+3.0000 information_schema QUERY_CACHE_INFO STATEMENT_SCHEMA varchar 192 576 utf8 utf8_general_ci varchar(192)
+1.0000 information_schema QUERY_CACHE_INFO STATEMENT_TEXT longtext 4294967295 4294967295 utf8 utf8_general_ci longtext
+NULL information_schema QUERY_CACHE_INFO RESULT_BLOCKS_COUNT int NULL NULL NULL NULL int(11)
+NULL information_schema QUERY_CACHE_INFO RESULT_BLOCKS_SIZE bigint NULL NULL NULL NULL bigint(11)
+NULL information_schema QUERY_CACHE_INFO RESULT_BLOCKS_SIZE_USED bigint NULL NULL NULL NULL bigint(11)
+3.0000 information_schema QUERY_RESPONSE_TIME TIME varchar 14 42 utf8 utf8_general_ci varchar(14)
+NULL information_schema QUERY_RESPONSE_TIME COUNT int NULL NULL NULL NULL int(11) unsigned
+3.0000 information_schema QUERY_RESPONSE_TIME TOTAL varchar 14 42 utf8 utf8_general_ci varchar(14)
3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema REFERENTIAL_CONSTRAINTS CONSTRAINT_NAME varchar 64 192 utf8 utf8_general_ci varchar(64)
diff --git a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result
index daa3ce83ba2..2e6c955081f 100644
--- a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result
@@ -428,6 +428,52 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME LOCALES
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 10
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
+TABLE_NAME METADATA_LOCK_INFO
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 10
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME PARAMETERS
TABLE_TYPE SYSTEM VIEW
ENGINE MYISAM_OR_MARIA
@@ -520,6 +566,52 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME QUERY_CACHE_INFO
+TABLE_TYPE SYSTEM VIEW
+ENGINE MYISAM_OR_MARIA
+VERSION 10
+ROW_FORMAT DYNAMIC_OR_PAGE
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
+TABLE_NAME QUERY_RESPONSE_TIME
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 10
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME REFERENTIAL_CONSTRAINTS
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
@@ -1364,6 +1456,52 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME LOCALES
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 10
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
+TABLE_NAME METADATA_LOCK_INFO
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 10
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME PARAMETERS
TABLE_TYPE SYSTEM VIEW
ENGINE MYISAM_OR_MARIA
@@ -1456,6 +1594,52 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
+TABLE_NAME QUERY_CACHE_INFO
+TABLE_TYPE SYSTEM VIEW
+ENGINE MYISAM_OR_MARIA
+VERSION 10
+ROW_FORMAT DYNAMIC_OR_PAGE
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
+TABLE_NAME QUERY_RESPONSE_TIME
+TABLE_TYPE SYSTEM VIEW
+ENGINE MEMORY
+VERSION 10
+ROW_FORMAT Fixed
+TABLE_ROWS #TBLR#
+AVG_ROW_LENGTH #ARL#
+DATA_LENGTH #DL#
+MAX_DATA_LENGTH #MDL#
+INDEX_LENGTH #IL#
+DATA_FREE #DF#
+AUTO_INCREMENT NULL
+CREATE_TIME #CRT#
+UPDATE_TIME #UT#
+CHECK_TIME #CT#
+TABLE_COLLATION utf8_general_ci
+CHECKSUM NULL
+CREATE_OPTIONS #CO#
+TABLE_COMMENT #TC#
+user_comment
+Separator -----------------------------------------------------
+TABLE_CATALOG def
+TABLE_SCHEMA information_schema
TABLE_NAME REFERENTIAL_CONSTRAINTS
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
diff --git a/mysql-test/suite/roles/admin.result b/mysql-test/suite/roles/admin.result
index ad3d4125252..44bf010b8ea 100644
--- a/mysql-test/suite/roles/admin.result
+++ b/mysql-test/suite/roles/admin.result
@@ -72,13 +72,13 @@ show grants for role4;
Grants for role4
GRANT USAGE ON *.* TO 'role4'
select * from information_schema.applicable_roles;
-GRANTEE ROLE_NAME IS_GRANTABLE
-role1 role2 NO
-role1 role3 YES
-role3 role4 YES
-root@localhost role1 YES
-root@localhost role2 YES
-root@localhost role4 YES
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+role1 role2 NO NULL
+role1 role3 YES NULL
+role3 role4 YES NULL
+root@localhost role1 YES NO
+root@localhost role2 YES NO
+root@localhost role4 YES NO
grant role2 to role1 with admin option;
revoke role1 from foo@localhost;
revoke admin option for role4 from role3;
@@ -131,13 +131,13 @@ show grants for role4;
Grants for role4
GRANT USAGE ON *.* TO 'role4'
select * from information_schema.applicable_roles;
-GRANTEE ROLE_NAME IS_GRANTABLE
-role1 role2 YES
-role1 role3 YES
-role3 role4 NO
-root@localhost role1 NO
-root@localhost role2 YES
-root@localhost role4 YES
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+role1 role2 YES NULL
+role1 role3 YES NULL
+role3 role4 NO NULL
+root@localhost role1 NO NO
+root@localhost role2 YES NO
+root@localhost role4 YES NO
grant role1 to role4;
ERROR 28000: Access denied for user 'root'@'localhost'
grant role1 to role4 with admin option;
diff --git a/mysql-test/suite/roles/drop_current_user-5176.result b/mysql-test/suite/roles/drop_current_user-5176.result
index 8e01bb10bd5..42fb4ba36b7 100644
--- a/mysql-test/suite/roles/drop_current_user-5176.result
+++ b/mysql-test/suite/roles/drop_current_user-5176.result
@@ -1,7 +1,7 @@
grant create user on *.* to foo@localhost;
drop user foo@localhost;
select * from information_schema.applicable_roles;
-GRANTEE ROLE_NAME IS_GRANTABLE
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
show grants;
ERROR 42000: There is no such grant defined for user 'foo' on host 'localhost'
select current_user();
diff --git a/mysql-test/suite/roles/i_s_applicable_roles_is_default.result b/mysql-test/suite/roles/i_s_applicable_roles_is_default.result
new file mode 100644
index 00000000000..63127f8b176
--- /dev/null
+++ b/mysql-test/suite/roles/i_s_applicable_roles_is_default.result
@@ -0,0 +1,80 @@
+create user foo;
+create role role1;
+create role role2;
+create role role3;
+grant role1 to foo;
+grant role2 to role1;
+grant role3 to foo;
+connect foo, localhost, foo;
+select * from information_schema.applicable_roles;
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+foo@% role1 NO NO
+foo@% role3 NO NO
+role1 role2 NO NULL
+set default role role3;
+select * from information_schema.applicable_roles;
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+foo@% role1 NO NO
+foo@% role3 NO YES
+role1 role2 NO NULL
+set default role role1;
+select * from information_schema.applicable_roles;
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+foo@% role1 NO YES
+foo@% role3 NO NO
+role1 role2 NO NULL
+disconnect foo;
+connection default;
+select * from information_schema.applicable_roles;
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+role1 role2 NO NULL
+root@localhost role1 YES NO
+root@localhost role2 YES NO
+root@localhost role3 YES NO
+set default role none for foo;
+connect foo, localhost, foo;
+select * from information_schema.applicable_roles;
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+foo@% role1 NO NO
+foo@% role3 NO NO
+role1 role2 NO NULL
+disconnect foo;
+connection default;
+select * from information_schema.applicable_roles;
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+role1 role2 NO NULL
+root@localhost role1 YES NO
+root@localhost role2 YES NO
+root@localhost role3 YES NO
+set default role role1;
+select * from information_schema.applicable_roles;
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+role1 role2 NO NULL
+root@localhost role1 YES YES
+root@localhost role2 YES NO
+root@localhost role3 YES NO
+set default role role2;
+select * from information_schema.applicable_roles;
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+role1 role2 NO NULL
+root@localhost role1 YES NO
+root@localhost role2 YES YES
+root@localhost role3 YES NO
+set default role role3;
+select * from information_schema.applicable_roles;
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+role1 role2 NO NULL
+root@localhost role1 YES NO
+root@localhost role2 YES NO
+root@localhost role3 YES YES
+set default role none;
+select * from information_schema.applicable_roles;
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+role1 role2 NO NULL
+root@localhost role1 YES NO
+root@localhost role2 YES NO
+root@localhost role3 YES NO
+drop role role3;
+drop role role2;
+drop role role1;
+drop user foo;
diff --git a/mysql-test/suite/roles/i_s_applicable_roles_is_default.test b/mysql-test/suite/roles/i_s_applicable_roles_is_default.test
new file mode 100644
index 00000000000..5ca8738695a
--- /dev/null
+++ b/mysql-test/suite/roles/i_s_applicable_roles_is_default.test
@@ -0,0 +1,62 @@
+--enable_connect_log
+create user foo;
+create role role1;
+create role role2;
+create role role3;
+
+grant role1 to foo;
+grant role2 to role1;
+grant role3 to foo;
+
+
+connect (foo, localhost, foo);
+--sorted_result
+select * from information_schema.applicable_roles;
+
+set default role role3;
+--sorted_result
+select * from information_schema.applicable_roles;
+
+set default role role1;
+--sorted_result
+select * from information_schema.applicable_roles;
+
+
+disconnect foo;
+connection default;
+
+--sorted_result
+select * from information_schema.applicable_roles;
+
+set default role none for foo;
+connect (foo, localhost, foo);
+--sorted_result
+select * from information_schema.applicable_roles;
+
+disconnect foo;
+connection default;
+
+--sorted_result
+select * from information_schema.applicable_roles;
+
+set default role role1;
+--sorted_result
+select * from information_schema.applicable_roles;
+
+set default role role2;
+--sorted_result
+select * from information_schema.applicable_roles;
+
+set default role role3;
+--sorted_result
+select * from information_schema.applicable_roles;
+
+
+set default role none;
+--sorted_result
+select * from information_schema.applicable_roles;
+
+drop role role3;
+drop role role2;
+drop role role1;
+drop user foo;
diff --git a/mysql-test/suite/roles/recursive.result b/mysql-test/suite/roles/recursive.result
index ef40c97865f..7abbd01240e 100644
--- a/mysql-test/suite/roles/recursive.result
+++ b/mysql-test/suite/roles/recursive.result
@@ -28,18 +28,18 @@ Grants for foo@localhost
GRANT USAGE ON *.* TO 'foo'@'localhost'
GRANT role10 TO 'foo'@'localhost'
select * from information_schema.applicable_roles;
-GRANTEE ROLE_NAME IS_GRANTABLE
-foo@localhost role10 NO
-role10 role9 NO
-role2 role1 NO
-role4 role2 NO
-role5 role2 NO
-role5 role3 NO
-role6 role4 NO
-role6 role5 NO
-role7 role5 NO
-role9 role6 NO
-role9 role7 NO
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+foo@localhost role10 NO NO
+role10 role9 NO NULL
+role2 role1 NO NULL
+role4 role2 NO NULL
+role5 role2 NO NULL
+role5 role3 NO NULL
+role6 role4 NO NULL
+role6 role5 NO NULL
+role7 role5 NO NULL
+role9 role6 NO NULL
+role9 role7 NO NULL
show status like 'debug%';
Variable_name Value
grant select on *.* to role1;
diff --git a/mysql-test/suite/roles/recursive_dbug.result b/mysql-test/suite/roles/recursive_dbug.result
index 1d857a5c888..ea65a842eb0 100644
--- a/mysql-test/suite/roles/recursive_dbug.result
+++ b/mysql-test/suite/roles/recursive_dbug.result
@@ -32,18 +32,18 @@ Grants for foo@localhost
GRANT USAGE ON *.* TO 'foo'@'localhost'
GRANT role10 TO 'foo'@'localhost'
select * from information_schema.applicable_roles;
-GRANTEE ROLE_NAME IS_GRANTABLE
-foo@localhost role10 NO
-role10 role9 NO
-role2 role1 NO
-role4 role2 NO
-role5 role2 NO
-role5 role3 NO
-role6 role4 NO
-role6 role5 NO
-role7 role5 NO
-role9 role6 NO
-role9 role7 NO
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+foo@localhost role10 NO NO
+role10 role9 NO NULL
+role2 role1 NO NULL
+role4 role2 NO NULL
+role5 role2 NO NULL
+role5 role3 NO NULL
+role6 role4 NO NULL
+role6 role5 NO NULL
+role7 role5 NO NULL
+role9 role6 NO NULL
+role9 role7 NO NULL
show status like 'debug%';
Variable_name Value
Debug_role_merges_global 11
diff --git a/mysql-test/suite/roles/show_grants.result b/mysql-test/suite/roles/show_grants.result
index e7b7860c74f..5d46b038cf8 100644
--- a/mysql-test/suite/roles/show_grants.result
+++ b/mysql-test/suite/roles/show_grants.result
@@ -23,15 +23,15 @@ user host
grant select on mysql.* to test_role2;
flush privileges;
select * from information_schema.applicable_roles;
-GRANTEE ROLE_NAME IS_GRANTABLE
-root@localhost test_role1 YES
-root@localhost test_role2 YES
-test_role1 test_role2 NO
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+root@localhost test_role1 YES NO
+root@localhost test_role2 YES NO
+test_role1 test_role2 NO NULL
select * from information_schema.applicable_roles;
-GRANTEE ROLE_NAME IS_GRANTABLE
-test_role1 test_role2 NO
-test_user@localhost test_role1 NO
-test_user@localhost test_role2 NO
+GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT
+test_role1 test_role2 NO NULL
+test_user@localhost test_role1 NO NO
+test_user@localhost test_role2 NO NO
show grants;
Grants for test_user@localhost
GRANT USAGE ON *.* TO 'test_user'@'localhost'
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}
};