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

execution: Fix issue 24439 Inconsistent error with MySQL for GRANT CREATE USER ON <specific db>.* #24485

Merged
merged 33 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9435573
add tcp4only for lvs
sylzd Dec 8, 2020
a19f66e
fix typo
sylzd Dec 8, 2020
66a261c
Merge branch 'master' into master
sylzd Dec 8, 2020
f620f14
Merge branch 'master' into master
sylzd Dec 8, 2020
ea27051
fix annotaion
sylzd Dec 8, 2020
7b4631b
fix
sylzd Dec 8, 2020
4187316
Merge branch 'master' into master
sylzd Dec 8, 2020
74b08ea
Merge branch 'master' into master
ti-srebot Dec 9, 2020
a4d0e75
Merge branch 'master' into master
XuHuaiyu Dec 9, 2020
aa3b66e
Merge branch 'master' into master
XuHuaiyu Dec 9, 2020
570c8f1
Merge branch 'master' into master
ti-srebot Dec 9, 2020
ebef90f
Merge branch 'master' into master
sylzd Dec 9, 2020
8c95fa1
Merge branch 'master' of https://github.com/pingcap/tidb into pingcap
sylzd Jan 21, 2021
ba5e45e
Merge branch 'master' of https://github.com/pingcap/tidb into pingcap
sylzd Jan 26, 2021
f011c3a
Merge branch 'master' of https://github.com/pingcap/tidb into pingcap
sylzd May 7, 2021
3563017
fix Inconsistent error with MySQL for GRANT CREATE USER ON <specific …
sylzd May 8, 2021
d17a634
fix import group
sylzd May 8, 2021
b8c0546
Merge branch 'master' into fix_24439
sylzd May 8, 2021
11718cc
fix order of dberror import
sylzd May 8, 2021
8190f63
Merge branch 'fix_24439' of github.com:sylzd/tidb into fix_24439
sylzd May 8, 2021
42a475a
more graceful
sylzd May 8, 2021
175c88f
add test case
sylzd May 8, 2021
348a995
fix
sylzd May 8, 2021
435c465
Merge branch 'master' into fix_24439
sylzd May 8, 2021
a190829
fix whitelist of privs
sylzd May 8, 2021
85e7191
Merge branch 'master' into fix_24439
sylzd May 8, 2021
fcacc76
sync to errors.toml
sylzd May 8, 2021
715a479
Merge branch 'fix_24439' of github.com:sylzd/tidb into fix_24439
sylzd May 8, 2021
0795b60
add configPriv
sylzd May 11, 2021
82c8999
move StaticGlobalOnlyPrivs to parser mode
sylzd May 13, 2021
052e2f9
Merge branch 'master' into fix_24439
sylzd May 13, 2021
c98786e
fix go.sum tidy
sylzd May 13, 2021
3a10e3c
Merge branch 'fix_24439' of github.com:sylzd/tidb into fix_24439
sylzd May 13, 2021
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
5 changes: 5 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ error = '''
Deadlock found when trying to get lock; try restarting transaction
'''

["executor:1221"]
error = '''
Incorrect usage of %s and %s
'''

["executor:1242"]
error = '''
Subquery returns more than 1 row
Expand Down
1 change: 1 addition & 0 deletions executor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (
ErrTableaccessDenied = dbterror.ClassExecutor.NewStd(mysql.ErrTableaccessDenied)
ErrBadDB = dbterror.ClassExecutor.NewStd(mysql.ErrBadDB)
ErrWrongObject = dbterror.ClassExecutor.NewStd(mysql.ErrWrongObject)
ErrWrongUsage = dbterror.ClassExecutor.NewStd(mysql.ErrWrongUsage)
ErrRoleNotGranted = dbterror.ClassPrivilege.NewStd(mysql.ErrRoleNotGranted)
ErrDeadlock = dbterror.ClassExecutor.NewStd(mysql.ErrLockDeadlock)
ErrQueryInterrupted = dbterror.ClassExecutor.NewStd(mysql.ErrQueryInterrupted)
Expand Down
6 changes: 6 additions & 0 deletions executor/grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,12 @@ func (e *GrantExec) grantDBLevel(priv *ast.PrivElem, user *ast.UserSpec, interna
if priv.Priv == mysql.UsagePriv {
return nil
}
for _, v := range mysql.StaticGlobalOnlyPrivs {
if v == priv.Priv {
return ErrWrongUsage.GenWithStackByArgs("DB GRANT", "GLOBAL PRIVILEGES")
}
}

dbName := e.Level.DBName
if len(dbName) == 0 {
dbName = e.ctx.GetSessionVars().CurrentDB
Expand Down
4 changes: 4 additions & 0 deletions executor/grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func (s *testSuite3) TestGrantDBScope(c *C) {
sql := fmt.Sprintf("SELECT %s FROM mysql.DB WHERE User=\"testDB1\" and host=\"localhost\" and db=\"test\";", mysql.Priv2UserCol[v])
tk.MustQuery(sql).Check(testkit.Rows("Y"))
}

// Grant in wrong scope.
_, err := tk.Exec(` grant create user on test.* to 'testDB1'@'localhost';`)
c.Assert(terror.ErrorEqual(err, executor.ErrWrongUsage.GenWithStackByArgs("DB GRANT", "GLOBAL PRIVILEGES")), IsTrue)
}

func (s *testSuite3) TestWithGrantOption(c *C) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require (
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989
github.com/pingcap/kvproto v0.0.0-20210429093846-65f54a202d7e
github.com/pingcap/log v0.0.0-20210317133921-96f4fcab92a4
github.com/pingcap/parser v0.0.0-20210508071014-cd9cd78e230c
github.com/pingcap/parser v0.0.0-20210513020953-ae2c4497c07b
github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible
github.com/pingcap/tipb v0.0.0-20210422074242-57dd881b81b1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ github.com/pingcap/log v0.0.0-20200511115504-543df19646ad/go.mod h1:4rbK1p9ILyIf
github.com/pingcap/log v0.0.0-20201112100606-8f1e84a3abc8/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
github.com/pingcap/log v0.0.0-20210317133921-96f4fcab92a4 h1:ERrF0fTuIOnwfGbt71Ji3DKbOEaP189tjym50u8gpC8=
github.com/pingcap/log v0.0.0-20210317133921-96f4fcab92a4/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
github.com/pingcap/parser v0.0.0-20210508071014-cd9cd78e230c h1:GLFd+wBN7EsV6ad/tVGFCD37taOyzIMVs3SdiWZF18I=
github.com/pingcap/parser v0.0.0-20210508071014-cd9cd78e230c/go.mod h1:xZC8I7bug4GJ5KtHhgAikjTfU4kBv1Sbo3Pf1MZ6lVw=
github.com/pingcap/parser v0.0.0-20210513020953-ae2c4497c07b h1:eLuDQ6eJCEKCbGwhGrkjzagwev1GJGU2Y2kFkAsBzV0=
github.com/pingcap/parser v0.0.0-20210513020953-ae2c4497c07b/go.mod h1:xZC8I7bug4GJ5KtHhgAikjTfU4kBv1Sbo3Pf1MZ6lVw=
github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI=
github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3 h1:A9KL9R+lWSVPH8IqUuH1QSTRJ5FGoY1bT2IcfPKsWD8=
github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3/go.mod h1:tckvA041UWP+NqYzrJ3fMgC/Hw9wnmQ/tUkp/JaHly8=
Expand Down