Skip to content
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

privilege: fix compatibility of DBIsVisible #14862

Merged
merged 4 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion privilege/privileges/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
tablePrivMask = computePrivMask(mysql.AllTablePrivs)
)

const globalDBVisible = mysql.CreatePriv | mysql.SelectPriv | mysql.InsertPriv | mysql.UpdatePriv | mysql.DeletePriv | mysql.ShowDBPriv | mysql.DropPriv | mysql.AlterPriv | mysql.IndexPriv | mysql.CreateViewPriv | mysql.ShowViewPriv | mysql.GrantPriv
const globalDBVisible = mysql.CreatePriv | mysql.SelectPriv | mysql.InsertPriv | mysql.UpdatePriv | mysql.DeletePriv | mysql.ShowDBPriv | mysql.DropPriv | mysql.AlterPriv | mysql.IndexPriv | mysql.CreateViewPriv | mysql.ShowViewPriv | mysql.GrantPriv | mysql.TriggerPriv | mysql.ReferencesPriv | mysql.ExecutePriv

func computePrivMask(privs []mysql.PrivilegeType) mysql.PrivilegeType {
var mask mysql.PrivilegeType
Expand Down
21 changes: 21 additions & 0 deletions privilege/privileges/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,4 +553,25 @@ func (s *testCacheSuite) TestDBIsVisible(c *C) {
isVisible = p.DBIsVisible("testvisdb6", "%", "visdb")
c.Assert(isVisible, IsTrue)
mustExec(c, se, "TRUNCATE TABLE mysql.user")

mustExec(c, se, `INSERT INTO mysql.user (Host, User, Trigger_priv) VALUES ("%", "testvisdb7", "Y")`)
err = p.LoadUserTable(se)
c.Assert(err, IsNil)
isVisible = p.DBIsVisible("testvisdb7", "%", "visdb")
c.Assert(isVisible, IsTrue)
mustExec(c, se, "TRUNCATE TABLE mysql.user")

mustExec(c, se, `INSERT INTO mysql.user (Host, User, References_priv) VALUES ("%", "testvisdb8", "Y")`)
err = p.LoadUserTable(se)
c.Assert(err, IsNil)
isVisible = p.DBIsVisible("testvisdb8", "%", "visdb")
c.Assert(isVisible, IsTrue)
mustExec(c, se, "TRUNCATE TABLE mysql.user")

mustExec(c, se, `INSERT INTO mysql.user (Host, User, Execute_priv) VALUES ("%", "testvisdb9", "Y")`)
err = p.LoadUserTable(se)
c.Assert(err, IsNil)
isVisible = p.DBIsVisible("testvisdb9", "%", "visdb")
c.Assert(isVisible, IsTrue)
mustExec(c, se, "TRUNCATE TABLE mysql.user")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added tests can pass in the master too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}