Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: check unequal handles when buildTableReader4INLJoin #15675

Merged
merged 3 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2603,8 +2603,19 @@ func (builder *dataReaderBuilder) buildTableReaderForIndexJoin(ctx context.Conte
return nil, err
}
handles := make([]int64, 0, len(lookUpContents))
var isValidHandle bool
for _, content := range lookUpContents {
handles = append(handles, content.keys[0].GetInt64())
handle := content.keys[0].GetInt64()
isValidHandle = true
for _, key := range content.keys {
if handle != key.GetInt64() {
qw4990 marked this conversation as resolved.
Show resolved Hide resolved
isValidHandle = false
break
}
}
if isValidHandle {
handles = append(handles, handle)
}
}
return builder.buildTableReaderFromHandles(ctx, e, handles)
}
Expand Down
10 changes: 10 additions & 0 deletions executor/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,16 @@ func (s *testSuiteJoin1) TestIndexLookupJoin(c *C) {
tk.MustQuery("select /*+ INL_HASH_JOIN(s) */ count(*) from t join s use index(idx) on s.a = t.a and s.b < t.b").Check(testkit.Rows("64"))
tk.MustExec("set @@tidb_index_lookup_join_concurrency=1;")
tk.MustQuery("select /*+ INL_HASH_JOIN(s) */ count(*) from t join s use index(idx) on s.a = t.a and s.b < t.b").Check(testkit.Rows("64"))

// issue15658
tk.MustExec("drop table t1, t2")
tk.MustExec("create table t1(id int primary key)")
tk.MustExec("create table t2(a int, b int)")
tk.MustExec("insert into t1 values(1)")
tk.MustExec("insert into t2 values(1,1),(2,1)")
tk.MustQuery("select /*+ inl_join(t1)*/ * from t1 join t2 on t2.b=t1.id and t2.a=t1.id;").Check(testkit.Rows("1 1 1"))
tk.MustQuery("select /*+ inl_hash_join(t1)*/ * from t1 join t2 on t2.b=t1.id and t2.a=t1.id;").Check(testkit.Rows("1 1 1"))
tk.MustQuery("select /*+ inl_merge_join(t1)*/ * from t1 join t2 on t2.b=t1.id and t2.a=t1.id;").Check(testkit.Rows("1 1 1"))
}

func (s *testSuiteJoin1) TestIndexNestedLoopHashJoin(c *C) {
Expand Down