Skip to content

Commit a2e194e

Browse files
alivxxxzz-jason
authored andcommittedApr 29, 2019
executor: ignore overflow error when construct inner key (#10244) (#10306)
1 parent 0f6621d commit a2e194e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎executor/index_lookup_join.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,11 @@ func (iw *innerWorker) constructDatumLookupKey(task *lookUpJoinTask, rowIdx int)
493493
innerColType := iw.rowTypes[iw.keyCols[i]]
494494
innerValue, err := outerValue.ConvertTo(sc, innerColType)
495495
if err != nil {
496-
return nil, errors.Trace(err)
496+
// If the converted outerValue overflows, we don't need to lookup it.
497+
if terror.ErrorEqual(err, types.ErrOverflow) {
498+
return nil, nil
499+
}
500+
return nil, err
497501
}
498502
cmp, err := outerValue.CompareDatum(sc, &innerValue)
499503
if err != nil {

‎executor/index_lookup_join_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,12 @@ func (s *testSuite) TestInapplicableIndexJoinHint(c *C) {
5656
tk.MustQuery(`select /*+ TIDB_INLJ(t2) */ * from t1 right join t2 on t1.a=t2.a;`).Check(testkit.Rows())
5757
tk.MustQuery(`show warnings;`).Check(testkit.Rows(`Warning 1815 Optimizer Hint /*+ TIDB_INLJ(t2) */ is inapplicable`))
5858
}
59+
60+
func (s *testSuite) TestIndexJoinOverflow(c *C) {
61+
tk := testkit.NewTestKitWithInit(c, s.store)
62+
tk.MustExec(`drop table if exists t1, t2`)
63+
tk.MustExec(`create table t1(a int)`)
64+
tk.MustExec(`insert into t1 values (-1)`)
65+
tk.MustExec(`create table t2(a int unsigned, index idx(a));`)
66+
tk.MustQuery(`select /*+ TIDB_INLJ(t2) */ * from t1 join t2 on t1.a = t2.a;`).Check(testkit.Rows())
67+
}

0 commit comments

Comments
 (0)