Skip to content

Commit

Permalink
executor: fix concurrent use of testkit in tests and add nil check (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
time-and-fate authored Jan 16, 2023
1 parent dbce2cb commit aa51b46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5556,6 +5556,8 @@ func TestAdmin(t *testing.T) {
}))
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk2 := testkit.NewTestKit(t, store)
tk2.MustExec("use test")
tk.MustExec("drop table if exists admin_test")
tk.MustExec("create table admin_test (c1 int, c2 int, c3 int default 1, index (c1))")
tk.MustExec("insert admin_test (c1) values (1),(2),(NULL)")
Expand Down Expand Up @@ -5680,7 +5682,7 @@ func TestAdmin(t *testing.T) {
// check that the result set has no duplication
defer wg.Done()
for i := 0; i < 10; i++ {
result := tk.MustQuery(`admin show ddl job queries 20`)
result := tk2.MustQuery(`admin show ddl job queries 20`)
rows := result.Rows()
rowIDs := make(map[string]struct{})
for _, row := range rows {
Expand Down Expand Up @@ -5711,7 +5713,7 @@ func TestAdmin(t *testing.T) {
// check that the result set has no duplication
defer wg2.Done()
for i := 0; i < 10; i++ {
result := tk.MustQuery(`admin show ddl job queries limit 3 offset 2`)
result := tk2.MustQuery(`admin show ddl job queries limit 3 offset 2`)
rows := result.Rows()
rowIDs := make(map[string]struct{})
for _, row := range rows {
Expand Down
3 changes: 3 additions & 0 deletions planner/core/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ type planDigester struct {

// NormalizeFlatPlan normalizes a FlatPhysicalPlan and generates plan digest.
func NormalizeFlatPlan(flat *FlatPhysicalPlan) (normalized string, digest *parser.Digest) {
if flat == nil {
return "", parser.NewDigest(nil)
}
selectPlan, selectPlanOffset := flat.Main.GetSelectPlan()
if len(selectPlan) == 0 || !selectPlan[0].IsPhysicalPlan {
return "", parser.NewDigest(nil)
Expand Down

0 comments on commit aa51b46

Please sign in to comment.