Skip to content

REVOKE / GRANT visitInfo is incorrect on global grants #24142

@morgo

Description

@morgo

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

From manual inspection of the code, when GRANT is on . the visitInfo collected the dbName even if it is not applicable:

if dbName == "" {
dbName = sctx.GetSessionVars().CurrentDB
}
vi = appendVisitInfo(vi, mysql.GrantPriv, dbName, tableName, "", nil)
var allPrivs []mysql.PrivilegeType
for _, item := range stmt.Privs {
if item.Priv == mysql.AllPriv {
switch stmt.Level.Level {
case ast.GrantLevelGlobal:
allPrivs = mysql.AllGlobalPrivs
case ast.GrantLevelDB:
allPrivs = mysql.AllDBPrivs
case ast.GrantLevelTable:
allPrivs = mysql.AllTablePrivs
}
break
}
vi = appendVisitInfo(vi, item.Priv, dbName, tableName, "", nil)
}
for _, priv := range allPrivs {
vi = appendVisitInfo(vi, priv, dbName, tableName, "", nil)
}

2. What did you expect to see? (Required)

It should be if dbName == "" && stmt.Level.Level != ast.GrantLevelGlobal {. There are also no tests on visitInfo for GrantLevelGlobal.

3. What did you see instead (Required)

if dbName == "" {
	dbName = sctx.GetSessionVars().CurrentDB
}

4. What is your TiDB version? (Required)

master

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions