Skip to content

Commit

Permalink
Merge branch 'master' into fix_38654
Browse files Browse the repository at this point in the history
  • Loading branch information
AilinKid authored Oct 28, 2022
2 parents 90c4072 + 95d177a commit 234b73c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
6 changes: 4 additions & 2 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7710,9 +7710,11 @@ func TestNullConditionForPrefixIndex(t *testing.T) {
KEY idx2 (c1,c2(5))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin`)
tk.MustExec("create table t2(a int, b varchar(10), index idx(b(5)))")
tk.MustExec("create table t3(a int, b varchar(10), c int, primary key (a, b(5)) clustered)")
tk.MustExec("set tidb_opt_prefix_index_single_scan = 1")
tk.MustExec("insert into t1 values ('a', '0xfff', '111111'), ('b', '0xfff', '222222'), ('c', '0xfff', ''), ('d', '0xfff', null)")
tk.MustExec("insert into t2 values (1, 'aaaaaa'), (2, 'bbb'), (3, ''), (4, null)")
tk.MustExec("insert into t1 values ('a', '0xfff', '111111'), ('b', '0xfff', '22 '), ('c', '0xfff', ''), ('d', '0xfff', null)")
tk.MustExec("insert into t2 values (1, 'aaaaaa'), (2, 'bb '), (3, ''), (4, null)")
tk.MustExec("insert into t3 values (1, 'aaaaaa', 2), (1, 'bb ', 3), (1, '', 4)")

var input []string
var output []struct {
Expand Down
6 changes: 5 additions & 1 deletion planner/core/testdata/integration_suite_in.json
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,12 @@
"select c2 from t1 use index(idx2) where c1 = '0xfff' and c2 is null",
"select c2 from t1 use index(idx2) where c1 >= '0xfff' and c2 is not null",
"select c2 from t1 use index(idx2) where c1 >= '0xfff' and c2 is null",
"select count(1) from t2 use index(idx) where b is not null",
"select count(1) from t2 use index(idx) where b is null",
"select b from t2 use index(idx) where b is not null",
"select b from t2 use index(idx) where b is null"
"select b from t2 use index(idx) where b is null",
"select b from t3 where a = 1 and b is not null",
"select b from t3 where a = 1 and b is null"
]
}
]
50 changes: 47 additions & 3 deletions planner/core/testdata/integration_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -7652,7 +7652,7 @@
"Result": [
"",
"111111",
"222222"
"22 "
]
},
{
Expand All @@ -7679,7 +7679,7 @@
"Result": [
"",
"111111",
"222222"
"22 "
]
},
{
Expand All @@ -7695,6 +7695,30 @@
"<nil>"
]
},
{
"SQL": "select count(1) from t2 use index(idx) where b is not null",
"Plan": [
"StreamAgg 1.00 root funcs:count(Column#6)->Column#4",
"└─IndexReader 1.00 root index:StreamAgg",
" └─StreamAgg 1.00 cop[tikv] funcs:count(1)->Column#6",
" └─IndexFullScan 9990.00 cop[tikv] table:t2, index:idx(b) keep order:false, stats:pseudo"
],
"Result": [
"3"
]
},
{
"SQL": "select count(1) from t2 use index(idx) where b is null",
"Plan": [
"StreamAgg 1.00 root funcs:count(Column#6)->Column#4",
"└─IndexReader 1.00 root index:StreamAgg",
" └─StreamAgg 1.00 cop[tikv] funcs:count(1)->Column#6",
" └─IndexRangeScan 10.00 cop[tikv] table:t2, index:idx(b) range:[NULL,NULL], keep order:false, stats:pseudo"
],
"Result": [
"1"
]
},
{
"SQL": "select b from t2 use index(idx) where b is not null",
"Plan": [
Expand All @@ -7705,7 +7729,7 @@
"Result": [
"",
"aaaaaa",
"bbb"
"bb "
]
},
{
Expand All @@ -7718,6 +7742,26 @@
"Result": [
"<nil>"
]
},
{
"SQL": "select b from t3 where a = 1 and b is not null",
"Plan": [
"Projection 10.00 root test.t3.b",
"└─TableReader 10.00 root data:TableRangeScan",
" └─TableRangeScan 10.00 cop[tikv] table:t3 range:[1,1], keep order:false, stats:pseudo"
],
"Result": [
"",
"aaaaaa",
"bb "
]
},
{
"SQL": "select b from t3 where a = 1 and b is null",
"Plan": [
"TableDual 0.00 root rows:0"
],
"Result": null
}
]
}
Expand Down

0 comments on commit 234b73c

Please sign in to comment.