From a2e194e0d85e9884716f5e21e2af64e3f35a5310 Mon Sep 17 00:00:00 2001 From: Haibin Xie Date: Tue, 30 Apr 2019 00:28:04 +0800 Subject: [PATCH] executor: ignore overflow error when construct inner key (#10244) (#10306) --- executor/index_lookup_join.go | 6 +++++- executor/index_lookup_join_test.go | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/executor/index_lookup_join.go b/executor/index_lookup_join.go index 4045ff6f0e0b0..4919a30117171 100644 --- a/executor/index_lookup_join.go +++ b/executor/index_lookup_join.go @@ -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 { diff --git a/executor/index_lookup_join_test.go b/executor/index_lookup_join_test.go index e6fbd8521a786..30cc7b490768f 100644 --- a/executor/index_lookup_join_test.go +++ b/executor/index_lookup_join_test.go @@ -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()) +}