Skip to content

Commit

Permalink
executor: fix query empty table with IN clause reports 'invalid year' (
Browse files Browse the repository at this point in the history
  • Loading branch information
sylzd authored Jul 5, 2021
1 parent cb06e11 commit 83d318a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions executor/index_lookup_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ func (iw *innerWorker) constructDatumLookupKey(task *lookUpJoinTask, chkIdx, row
innerColType := iw.rowTypes[iw.hashCols[i]]
innerValue, err := outerValue.ConvertTo(sc, innerColType)
if err != nil && !(terror.ErrorEqual(err, types.ErrTruncated) && (innerColType.Tp == mysql.TypeSet || innerColType.Tp == mysql.TypeEnum)) {
// If the converted outerValue overflows, we don't need to lookup it.
if terror.ErrorEqual(err, types.ErrOverflow) {
// If the converted outerValue overflows or invalid to innerValue, we don't need to lookup it.
if terror.ErrorEqual(err, types.ErrOverflow) || terror.ErrorEqual(err, types.ErrInvalidYear) {
return nil, nil, nil
}
return nil, nil, err
Expand Down
13 changes: 13 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9799,3 +9799,16 @@ func (s *testIntegrationSuite2) TestIssue25591(c *C) {
rows = tk.MustQuery("select t1.col1, t2.col1, t2.col2 from t1_1 t1 inner join t2_1 t2 on t1.col1 not in (1,t2.col1,t2.col2) order by 1,2,3;")
rows.Check(testkit.Rows())
}

func (s *testIntegrationSuite2) TestIssue25526(c *C) {
tk := testkit.NewTestKit(c, s.store)

tk.MustExec("use test;")
tk.MustExec("drop table if exists tbl_6, tbl_17;")
tk.MustExec("create table tbl_6 (col_31 year, index(col_31));")
tk.MustExec("create table tbl_17 (col_102 int, col_105 int);")
tk.MustExec("replace into tbl_17 (col_102, col_105) values (9999, 0);")

rows := tk.MustQuery("select tbl_6.col_31 from tbl_6 where col_31 in (select col_102 from tbl_17 where tbl_17.col_102 = 9999 and tbl_17.col_105 = 0);")
rows.Check(testkit.Rows())
}

0 comments on commit 83d318a

Please sign in to comment.