Skip to content

Commit

Permalink
tests: move IT in executor to tests/integrationtest (PART 11) (#48325)
Browse files Browse the repository at this point in the history
close #47076
  • Loading branch information
Defined2014 authored Nov 7, 2023
1 parent 286e852 commit 662528d
Show file tree
Hide file tree
Showing 17 changed files with 3,814 additions and 2,125 deletions.
1,241 changes: 0 additions & 1,241 deletions pkg/executor/test/executor/executor_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/executor/test/indexmergereadtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ go_test(
],
flaky = True,
race = "on",
shard_count = 37,
shard_count = 20,
deps = [
"//pkg/config",
"//pkg/executor",
Expand Down
484 changes: 32 additions & 452 deletions pkg/executor/test/indexmergereadtest/index_merge_reader_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/executor/test/passwordtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_test(
"password_management_test.go",
],
flaky = True,
shard_count = 16,
shard_count = 8,
deps = [
"//pkg/domain",
"//pkg/errno",
Expand Down
390 changes: 0 additions & 390 deletions pkg/executor/test/passwordtest/password_management_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/executor/test/seqtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ go_test(
],
flaky = True,
race = "on",
shard_count = 33,
shard_count = 31,
deps = [
"//pkg/config",
"//pkg/ddl/testutil",
Expand Down
39 changes: 0 additions & 39 deletions pkg/executor/test/seqtest/prepared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,42 +656,3 @@ func TestPreparedIssue17419(t *testing.T) {
// _, ok := tk1.Session().ShowProcess().Plan.(*plannercore.Execute)
// require.True(t, ok)
}

func TestLimitUnsupportedCase(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, key(a))")
tk.MustExec("prepare stmt from 'select * from t limit ?'")

tk.MustExec("set @a = 1.2")
tk.MustGetErrMsg("execute stmt using @a", "[planner:1210]Incorrect arguments to LIMIT")
tk.MustExec("set @a = 1.")
tk.MustGetErrMsg("execute stmt using @a", "[planner:1210]Incorrect arguments to LIMIT")
tk.MustExec("set @a = '0'")
tk.MustGetErrMsg("execute stmt using @a", "[planner:1210]Incorrect arguments to LIMIT")
tk.MustExec("set @a = '1'")
tk.MustGetErrMsg("execute stmt using @a", "[planner:1210]Incorrect arguments to LIMIT")
tk.MustExec("set @a = 1_2")
tk.MustGetErrMsg("execute stmt using @a", "[planner:1210]Incorrect arguments to LIMIT")
}

func TestIssue38323(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(id int, k int);")

tk.MustExec("prepare stmt from 'explain select * from t where id = ? and k = ? group by id, k';")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 skip prepared plan-cache: not a SELECT/UPDATE/INSERT/DELETE/SET statement"))
tk.MustExec("set @a = 1;")
tk.MustExec("execute stmt using @a, @a")
tk.MustQuery("execute stmt using @a, @a").Check(tk.MustQuery("explain select * from t where id = 1 and k = 1 group by id, k").Rows())

tk.MustExec("prepare stmt from 'explain select * from t where ? = id and ? = k group by id, k';")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 skip prepared plan-cache: not a SELECT/UPDATE/INSERT/DELETE/SET statement"))
tk.MustExec("set @a = 1;")
tk.MustQuery("execute stmt using @a, @a").Check(tk.MustQuery("explain select * from t where 1 = id and 1 = k group by id, k").Rows())
}
103 changes: 103 additions & 0 deletions tests/integrationtest/r/black_list.result
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,106 @@ TableReader 3323.33 root data:Selection
delete from mysql.expr_pushdown_blacklist;
admin reload expr_pushdown_blacklist;

drop table if exists t;
create table t(a enum('a','b','c'), b enum('a','b','c'), c int, index idx(b,a));
insert into t values(1,1,1),(2,2,2),(3,3,3);
insert into mysql.expr_pushdown_blacklist(name) values('enum');
admin reload expr_pushdown_blacklist;

desc format='brief' select /*+ HASH_AGG() */ max(a) from t;
id estRows task access object operator info
HashAgg 1.00 root funcs:max(black_list.t.a)->Column#5
└─IndexReader 10000.00 root index:IndexFullScan
└─IndexFullScan 10000.00 cop[tikv] table:t, index:idx(b, a) keep order:false, stats:pseudo
desc format='brief' select /*+ STREAM_AGG() */ max(a) from t;
id estRows task access object operator info
StreamAgg 1.00 root funcs:max(black_list.t.a)->Column#5
└─IndexReader 10000.00 root index:IndexFullScan
└─IndexFullScan 10000.00 cop[tikv] table:t, index:idx(b, a) keep order:false, stats:pseudo
delete from mysql.expr_pushdown_blacklist;
admin reload expr_pushdown_blacklist;

desc format='brief' select /*+ HASH_AGG() */ max(a) from t;
id estRows task access object operator info
HashAgg 1.00 root funcs:max(Column#7)->Column#5
└─IndexReader 1.00 root index:HashAgg
└─HashAgg 1.00 cop[tikv] funcs:max(black_list.t.a)->Column#7
└─IndexFullScan 10000.00 cop[tikv] table:t, index:idx(b, a) keep order:false, stats:pseudo
desc format='brief' select /*+ STREAM_AGG() */ max(a) from t;
id estRows task access object operator info
StreamAgg 1.00 root funcs:max(Column#7)->Column#5
└─IndexReader 1.00 root index:StreamAgg
└─StreamAgg 1.00 cop[tikv] funcs:max(black_list.t.a)->Column#7
└─IndexFullScan 10000.00 cop[tikv] table:t, index:idx(b, a) keep order:false, stats:pseudo
insert into mysql.expr_pushdown_blacklist(name) values('enum');
admin reload expr_pushdown_blacklist;

desc format='brief' select * from t where a + b;
id estRows task access object operator info
Selection 8000.00 root plus(cast(black_list.t.a, double BINARY), cast(black_list.t.b, double BINARY))
└─TableReader 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
desc format='brief' select * from t where a + b;
id estRows task access object operator info
Selection 8000.00 root plus(cast(black_list.t.a, double BINARY), cast(black_list.t.b, double BINARY))
└─TableReader 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
delete from mysql.expr_pushdown_blacklist;
admin reload expr_pushdown_blacklist;

desc format='brief' select * from t where a + b;
id estRows task access object operator info
TableReader 8000.00 root data:Selection
└─Selection 8000.00 cop[tikv] plus(cast(black_list.t.a, double BINARY), cast(black_list.t.b, double BINARY))
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
desc format='brief' select * from t where a + b;
id estRows task access object operator info
TableReader 8000.00 root data:Selection
└─Selection 8000.00 cop[tikv] plus(cast(black_list.t.a, double BINARY), cast(black_list.t.b, double BINARY))
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
insert into mysql.expr_pushdown_blacklist(name) values('enum');
admin reload expr_pushdown_blacklist;

desc format='brief' select * from t where b = 1;
id estRows task access object operator info
Selection 8000.00 root eq(black_list.t.b, 1)
└─TableReader 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
desc format='brief' select * from t where b = 'a';
id estRows task access object operator info
Selection 8000.00 root eq(black_list.t.b, "a")
└─TableReader 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
desc format='brief' select * from t where b > 1;
id estRows task access object operator info
Selection 8000.00 root gt(black_list.t.b, 1)
└─TableReader 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
desc format='brief' select * from t where b > 'a';
id estRows task access object operator info
Selection 8000.00 root gt(black_list.t.b, "a")
└─TableReader 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
delete from mysql.expr_pushdown_blacklist;
admin reload expr_pushdown_blacklist;

desc format='brief' select * from t where b = 1 and a = 1;
id estRows task access object operator info
IndexLookUp 0.10 root
├─IndexRangeScan(Build) 0.10 cop[tikv] table:t, index:idx(b, a) range:["a" "a","a" "a"], keep order:false, stats:pseudo
└─TableRowIDScan(Probe) 0.10 cop[tikv] table:t keep order:false, stats:pseudo
desc format='brief' select * from t where b = 'a' and a = 'a';
id estRows task access object operator info
IndexLookUp 0.10 root
├─IndexRangeScan(Build) 0.10 cop[tikv] table:t, index:idx(b, a) range:["a" "a","a" "a"], keep order:false, stats:pseudo
└─TableRowIDScan(Probe) 0.10 cop[tikv] table:t keep order:false, stats:pseudo
desc format='brief' select * from t where b = 1 and a > 1;
id estRows task access object operator info
IndexLookUp 33.33 root
├─IndexRangeScan(Build) 33.33 cop[tikv] table:t, index:idx(b, a) range:("a" "a","a" +inf], keep order:false, stats:pseudo
└─TableRowIDScan(Probe) 33.33 cop[tikv] table:t keep order:false, stats:pseudo
desc format='brief' select * from t where b = 1 and a > 'a';
id estRows task access object operator info
IndexLookUp 0.20 root
├─IndexRangeScan(Build) 0.20 cop[tikv] table:t, index:idx(b, a) range:["a" "b","a" "b"], ["a" "c","a" "c"], keep order:false, stats:pseudo
└─TableRowIDScan(Probe) 0.20 cop[tikv] table:t keep order:false, stats:pseudo
Loading

0 comments on commit 662528d

Please sign in to comment.