diff --git a/executor/distsql.go b/executor/distsql.go index 01c89a176d42a..b7e17b93d09ca 100644 --- a/executor/distsql.go +++ b/executor/distsql.go @@ -557,6 +557,7 @@ func (e *IndexLookUpExecutor) Close() error { e.finished = nil e.workerStarted = false e.memTracker = nil + e.resultCurr = nil return nil } diff --git a/executor/executor_test.go b/executor/executor_test.go index 58f95f08b3e1c..00f6fc523d94a 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -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")) +}