MXS-2759: Optimize user loading query
The SQL for the second recursive CTE table can be optimized by adding a where condition on the recursive part that rules out users that are not roles. The functionality remains the same as only roles can be granted to users.
This commit is contained in:
@ -77,7 +77,7 @@ const char* mariadb_102_users_query =
|
|||||||
"), users AS ("
|
"), users AS ("
|
||||||
// Select the root row, the actual user
|
// Select the root row, the actual user
|
||||||
" SELECT t.user, t.host, t.db, t.select_priv, t.password, t.default_role AS role FROM t"
|
" SELECT t.user, t.host, t.db, t.select_priv, t.password, t.default_role AS role FROM t"
|
||||||
" WHERE t.is_role <> 'Y'"
|
" WHERE t.is_role = 'N'"
|
||||||
" UNION"
|
" UNION"
|
||||||
// Recursively select all roles for the users
|
// Recursively select all roles for the users
|
||||||
" SELECT u.user, u.host, t.db, t.select_priv, u.password, r.role FROM t"
|
" SELECT u.user, u.host, t.db, t.select_priv, u.password, r.role FROM t"
|
||||||
@ -85,6 +85,7 @@ const char* mariadb_102_users_query =
|
|||||||
" ON (t.user = u.role)"
|
" ON (t.user = u.role)"
|
||||||
" LEFT JOIN mysql.roles_mapping AS r"
|
" LEFT JOIN mysql.roles_mapping AS r"
|
||||||
" ON (t.user = r.user)"
|
" ON (t.user = r.user)"
|
||||||
|
" WHERE t.is_role = 'Y'"
|
||||||
")"
|
")"
|
||||||
"SELECT DISTINCT t.user, t.host, t.db, t.select_priv, t.password FROM users AS t %s";
|
"SELECT DISTINCT t.user, t.host, t.db, t.select_priv, t.password FROM users AS t %s";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user