Skip to content

Commit

Permalink
stmtctx: remove the empty values in StatementContext.Tables (#39086)
Browse files Browse the repository at this point in the history
close #38493
  • Loading branch information
lcwangchao committed Nov 11, 2022
1 parent 80c8fea commit 483d2bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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

0 comments on commit 483d2bc

Please sign in to comment.