Skip to content

Commit

Permalink
executor: fix wrong index hash join when hash col is enum (#28032) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Sep 16, 2021
1 parent 6c314a2 commit f005851
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,7 @@ func (b *executorBuilder) buildIndexLookUpJoin(v *plannercore.PhysicalIndexJoin)
for i, col := range v.OuterHashKeys {
outerTypes[col.Index] = outerTypes[col.Index].Clone()
outerTypes[col.Index].Collate = innerTypes[v.InnerHashKeys[i].Index].Collate
outerTypes[col.Index].Flag = col.RetType.Flag
}

var (
Expand Down
13 changes: 13 additions & 0 deletions executor/index_lookup_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,19 @@ func (s *testSuite5) TestIssue24547(c *C) {
tk.MustExec("delete a from a inner join b on a.k1 = b.k1 and a.k2 = b.k2 where b.k2 <> '333'")
}

func (s *testSuite5) TestIssue27893(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("drop table if exists t2")
tk.MustExec("create table t1 (a enum('x','y'))")
tk.MustExec("create table t2 (a int, key(a))")
tk.MustExec("insert into t1 values('x')")
tk.MustExec("insert into t2 values(1)")
tk.MustQuery("select /*+ inl_join(t2) */ count(*) from t1 join t2 on t1.a = t2.a").Check(testkit.Rows("1"))
tk.MustQuery("select /*+ inl_hash_join(t2) */ count(*) from t1 join t2 on t1.a = t2.a").Check(testkit.Rows("1"))
}

func (s *testSuite5) TestPartitionTableIndexJoinAndIndexReader(c *C) {
if israce.RaceEnabled {
c.Skip("exhaustive types test, skip race test")
Expand Down

0 comments on commit f005851

Please sign in to comment.