Skip to content

Commit

Permalink
executor: ignore overflow error when construct inner key (#10244) (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
alivxxx authored and zz-jason committed Apr 29, 2019
1 parent 0f6621d commit a2e194e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion executor/index_lookup_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,11 @@ func (iw *innerWorker) constructDatumLookupKey(task *lookUpJoinTask, rowIdx int)
innerColType := iw.rowTypes[iw.keyCols[i]]
innerValue, err := outerValue.ConvertTo(sc, innerColType)
if err != nil {
return nil, errors.Trace(err)
// If the converted outerValue overflows, we don't need to lookup it.
if terror.ErrorEqual(err, types.ErrOverflow) {
return nil, nil
}
return nil, err
}
cmp, err := outerValue.CompareDatum(sc, &innerValue)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions executor/index_lookup_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ func (s *testSuite) TestInapplicableIndexJoinHint(c *C) {
tk.MustQuery(`select /*+ TIDB_INLJ(t2) */ * from t1 right join t2 on t1.a=t2.a;`).Check(testkit.Rows())
tk.MustQuery(`show warnings;`).Check(testkit.Rows(`Warning 1815 Optimizer Hint /*+ TIDB_INLJ(t2) */ is inapplicable`))
}

func (s *testSuite) TestIndexJoinOverflow(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec(`drop table if exists t1, t2`)
tk.MustExec(`create table t1(a int)`)
tk.MustExec(`insert into t1 values (-1)`)
tk.MustExec(`create table t2(a int unsigned, index idx(a));`)
tk.MustQuery(`select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a;`).Check(testkit.Rows())
}

0 comments on commit a2e194e

Please sign in to comment.