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

stmtctx: remove the empty values in StatementContext.Tables #39086

Merged
merged 3 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 15 additions & 0 deletions extension/event_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,21 @@ func TestExtensionStmtEvents(t *testing.T) {
{DB: "test", Table: "t2"},
},
},
{
sql: "create database db1",
redactText: "create database `db1`",
tables: []stmtctx.TableEntry{
{DB: "db1", Table: ""},
},
},
{
sql: "kill query 1",
redactText: "kill query ?",
},
{
sql: "create placement policy p1 followers=1",
redactText: "create placement policy `p1` followers = ?",
},
}

for i, c := range cases {
Expand Down
6 changes: 6 additions & 0 deletions planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,12 @@ func GetDBTableInfo(visitInfo []visitInfo) []stmtctx.TableEntry {
return false
}
for _, v := range visitInfo {
if v.db == "" && v.table == "" {
// when v.db == "" and v.table == "", it means this visitInfo is for dynamic privilege,
// so it is not related to any database or table.
continue
}

tbl := &stmtctx.TableEntry{DB: v.db, Table: v.table}
if !existsFunc(tables, tbl) {
tables = append(tables, *tbl)
Expand Down