Skip to content

Commit

Permalink
executor: fix incorrect results when there is an IndexLookUp under th…
Browse files Browse the repository at this point in the history
…e inner side of an Apply (pingcap#19496) (pingcap#19508)

* cherry pick pingcap#19496 to release-4.0

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* fix CI

Co-authored-by: Yuanjia Zhang <zhangyuanjia@pingcap.com>
  • Loading branch information
ti-srebot and qw4990 committed Aug 27, 2020
1 parent 7fe8264 commit a578272
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions executor/distsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ func (e *IndexLookUpExecutor) Close() error {
e.finished = nil
e.workerStarted = false
e.memTracker = nil
e.resultCurr = nil
return nil
}

Expand Down
11 changes: 11 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5940,3 +5940,14 @@ func (s *testSplitTable) TestKillTableReader(c *C) {
atomic.StoreUint32(&tk.Se.GetSessionVars().Killed, 1)
wg.Wait()
}

func (s *testSuite) TestIssue19372(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test;")
tk.MustExec("drop table if exists t1, t2;")
tk.MustExec("create table t1 (c_int int, c_str varchar(40), key(c_str));")
tk.MustExec("create table t2 like t1;")
tk.MustExec("insert into t1 values (1, 'a'), (2, 'b'), (3, 'c');")
tk.MustExec("insert into t2 select * from t1;")
tk.MustQuery("select (select t2.c_str from t2 where t2.c_str <= t1.c_str and t2.c_int in (1, 2) order by t2.c_str limit 1) x from t1 order by c_int;").Check(testkit.Rows("a", "a", "a"))
}

0 comments on commit a578272

Please sign in to comment.