-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
executor: query user and role, hostname should be lowercase #28880
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -496,6 +496,25 @@ func (s *testSuite7) TestUser(c *C) { | |
tk.MustExec(renameUserSQL) | ||
querySQL = `select user,host from mysql.user where user = 'userD';` | ||
tk.MustQuery(querySQL).Check(testkit.Rows("userD demo.com")) | ||
|
||
tk.MustExec(`create user joan;`) | ||
tk.MustExec(`create user sally;`) | ||
tk.MustExec(`create role engineering;`) | ||
tk.MustExec(`create role consultants;`) | ||
tk.MustExec(`create role qa;`) | ||
tk.MustExec(`grant engineering to joan;`) | ||
tk.MustExec(`grant engineering to sally;`) | ||
tk.MustExec(`grant engineering, consultants to joan, sally;`) | ||
tk.MustExec(`grant qa to consultants;`) | ||
tk.MustExec("CREATE ROLE `engineering`@`US`;") | ||
tk.MustExec("create role `engineering`@`INDIA`;") | ||
Comment on lines
+509
to
+510
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also verify the persisted value in It should match the following: mysql [localhost:8024] {root} ((none)) > select user,host from mysql.user where user='engineering'\G
*************************** 1. row ***************************
user: engineering
host: %
*************************** 2. row ***************************
user: engineering
host: india
*************************** 3. row ***************************
user: engineering
host: us
3 rows in set (0.00 sec) Otherwise LGTM There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The case you mentioned should be ok, but after your reminder, I found such a case,I think we should fix it: In mysql> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| sqwe | % |
| test_user | % |
| tidb_security | % |
| tidb_system | % |
| u1 | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
9 rows in set (0.00 sec)
mysql> select host from mysql.user where host = 'LOCALHOST'\G
*************************** 1. row ***************************
host: localhost
*************************** 2. row ***************************
host: localhost
*************************** 3. row ***************************
host: localhost
*************************** 4. row ***************************
host: localhost
4 rows in set (0.00 sec) In mysql> select host from mysql.user;
+-------+
| host |
+-------+
| % |
| % |
| % |
| % |
| % |
| % |
| india |
| us |
+-------+
8 rows in set (0.00 sec)
mysql> select host from mysql.user where host = 'INDIA'\G
Empty set (0.00 sec)
mysql> select host from mysql.user where host = 'india'\G
*************************** 1. row ***************************
host: india
1 row in set (0.00 sec) |
||
_, err = tk.Exec("grant `engineering`@`US` TO `engineering`@`INDIA`;") | ||
c.Check(err, IsNil) | ||
|
||
tk.MustQuery("select user,host from mysql.user where user='engineering' and host = 'india'"). | ||
Check(testkit.Rows("engineering india")) | ||
tk.MustQuery("select user,host from mysql.user where user='engineering' and host = 'us'"). | ||
Check(testkit.Rows("engineering us")) | ||
} | ||
|
||
func (s *testSuite3) TestSetPwd(c *C) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that there is a similar function
userExistsInternal
. Should it be modified, too?Besides, I prefer to put
strings.ToLower
inuserExists
so the callers don't have to care about the cases.