Skip to content

Commit ee555f8

Browse files
committed
MDEV-19948 SHOW GRANTS return privileges individually update in 10.2
1 parent 8fb39b2 commit ee555f8

File tree

1 file changed

+50
-36
lines changed

1 file changed

+50
-36
lines changed

sql/sql_acl.cc

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,56 @@ class User_table: public Grant_table_base
997997
return get_YN_as_bool(is_role());
998998
}
999999

1000+
ulong get_access() const
1001+
{
1002+
ulong access= Grant_table_base::get_access();
1003+
if ((num_fields() <= 13) && (access & CREATE_ACL))
1004+
access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL;
1005+
1006+
if (num_fields() <= 18)
1007+
{
1008+
access|= LOCK_TABLES_ACL | CREATE_TMP_ACL | SHOW_DB_ACL;
1009+
if (access & FILE_ACL)
1010+
access|= REPL_CLIENT_ACL | REPL_SLAVE_ACL;
1011+
if (access & PROCESS_ACL)
1012+
access|= SUPER_ACL | EXECUTE_ACL;
1013+
}
1014+
/*
1015+
If it is pre 5.0.1 privilege table then map CREATE privilege on
1016+
CREATE VIEW & SHOW VIEW privileges.
1017+
*/
1018+
if (num_fields() <= 31 && (access & CREATE_ACL))
1019+
access|= (CREATE_VIEW_ACL | SHOW_VIEW_ACL);
1020+
/*
1021+
If it is pre 5.0.2 privilege table then map CREATE/ALTER privilege on
1022+
CREATE PROCEDURE & ALTER PROCEDURE privileges.
1023+
*/
1024+
if (num_fields() <= 33)
1025+
{
1026+
if (access & CREATE_ACL)
1027+
access|= CREATE_PROC_ACL;
1028+
if (access & ALTER_ACL)
1029+
access|= ALTER_PROC_ACL;
1030+
}
1031+
/*
1032+
Pre 5.0.3 did not have CREATE_USER_ACL.
1033+
*/
1034+
if (num_fields() <= 36 && (access & GRANT_ACL))
1035+
access|= CREATE_USER_ACL;
1036+
/*
1037+
If it is pre 5.1.6 privilege table then map CREATE privilege on
1038+
CREATE|ALTER|DROP|EXECUTE EVENT.
1039+
*/
1040+
if (num_fields() <= 37 && (access & SUPER_ACL))
1041+
access|= EVENT_ACL;
1042+
/*
1043+
If it is pre 5.1.6 privilege then map TRIGGER privilege on CREATE.
1044+
*/
1045+
if (num_fields() <= 38 && (access & SUPER_ACL))
1046+
access|= TRIGGER_ACL;
1047+
1048+
return access & GLOBAL_ACLS;
1049+
}
10001050

10011051
private:
10021052
friend class Grant_tables;
@@ -1974,42 +2024,6 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
19742024

19752025
{
19762026
user.access= user_table.get_access() & GLOBAL_ACLS;
1977-
/*
1978-
if it is pre 5.0.1 privilege table then map CREATE privilege on
1979-
CREATE VIEW & SHOW VIEW privileges
1980-
*/
1981-
if (user_table.num_fields() <= 31 && (user.access & CREATE_ACL))
1982-
user.access|= (CREATE_VIEW_ACL | SHOW_VIEW_ACL);
1983-
1984-
/*
1985-
if it is pre 5.0.2 privilege table then map CREATE/ALTER privilege on
1986-
CREATE PROCEDURE & ALTER PROCEDURE privileges
1987-
*/
1988-
if (user_table.num_fields() <= 33 && (user.access & CREATE_ACL))
1989-
user.access|= CREATE_PROC_ACL;
1990-
if (user_table.num_fields() <= 33 && (user.access & ALTER_ACL))
1991-
user.access|= ALTER_PROC_ACL;
1992-
1993-
/*
1994-
pre 5.0.3 did not have CREATE_USER_ACL
1995-
*/
1996-
if (user_table.num_fields() <= 36 && (user.access & GRANT_ACL))
1997-
user.access|= CREATE_USER_ACL;
1998-
1999-
2000-
/*
2001-
if it is pre 5.1.6 privilege table then map CREATE privilege on
2002-
CREATE|ALTER|DROP|EXECUTE EVENT
2003-
*/
2004-
if (user_table.num_fields() <= 37 && (user.access & SUPER_ACL))
2005-
user.access|= EVENT_ACL;
2006-
2007-
/*
2008-
if it is pre 5.1.6 privilege then map TRIGGER privilege on CREATE.
2009-
*/
2010-
if (user_table.num_fields() <= 38 && (user.access & SUPER_ACL))
2011-
user.access|= TRIGGER_ACL;
2012-
20132027
user.sort= get_sort(2, user.host.hostname, user.user.str);
20142028
user.hostname_length= safe_strlen(user.host.hostname);
20152029
user.user_resource.user_conn= 0;

0 commit comments

Comments
 (0)