Skip to content

Commit

Permalink
executor: make unit test TestIssue21732 stable (#38278)
Browse files Browse the repository at this point in the history
close #38263
  • Loading branch information
tiancaiamao authored Sep 30, 2022
1 parent 5c4b328 commit 9657c9e
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions executor/partition_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3615,27 +3615,17 @@ func TestIssue21732(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
testkit.WithPruneMode(tk, variable.StaticOnly, func() {
tk.MustExec("create database TestIssue21732")
tk.MustExec("use TestIssue21732")
tk.MustExec("drop table if exists p")
tk.MustExec(`create table p (a int, b int GENERATED ALWAYS AS (3*a-2*a) VIRTUAL) partition by hash(b) partitions 2;`)
tk.MustExec("alter table p add unique index idx (a, b);")
tk.MustExec("insert into p (a) values (1),(2),(3);")
tk.MustExec("select * from p ignore index (idx);")
tk.MustQuery("select * from p use index (idx)").Check(testkit.Rows("2 2", "1 1", "3 3"))
tk.MustExec("drop database TestIssue21732")
})

testkit.WithPruneMode(tk, variable.DynamicOnly, func() {
tk.MustExec("create database TestIssue21732")
tk.MustExec("use TestIssue21732")
tk.MustExec("drop table if exists p")
tk.MustExec(`create table p (a int, b int GENERATED ALWAYS AS (3*a-2*a) VIRTUAL) partition by hash(b) partitions 2;`)
tk.MustExec("alter table p add unique index idx (a, b);")
tk.MustExec("insert into p (a) values (1),(2),(3);")
tk.MustExec("select * from p ignore index (idx);")
tk.MustQuery("select * from p use index (idx)").Sort().Check(testkit.Rows("1 1", "2 2", "3 3"))
tk.MustExec("drop database TestIssue21732")
})
for _, mode := range []variable.PartitionPruneMode{variable.StaticOnly, variable.DynamicOnly} {
testkit.WithPruneMode(tk, mode, func() {
tk.MustExec("create database TestIssue21732")
tk.MustExec("use TestIssue21732")
tk.MustExec("drop table if exists p")
tk.MustExec(`create table p (a int, b int GENERATED ALWAYS AS (3*a-2*a) VIRTUAL) partition by hash(b) partitions 2;`)
tk.MustExec("alter table p add unique index idx (a, b);")
tk.MustExec("insert into p (a) values (1),(2),(3);")
tk.MustExec("select * from p ignore index (idx);")
tk.MustQuery("select * from p use index (idx)").Sort().Check(testkit.Rows("1 1", "2 2", "3 3"))
tk.MustExec("drop database TestIssue21732")
})
}
}

0 comments on commit 9657c9e

Please sign in to comment.