From babf93f66510890d1da9c2c0fae8697c55db9a6c Mon Sep 17 00:00:00 2001 From: HuaiyuXu <391585975@qq.com> Date: Fri, 31 May 2019 21:55:12 +0800 Subject: [PATCH] executor: reset groupChecker for StreamAggExec when Close (#10615) (#10670) --- executor/aggregate.go | 6 ++++++ executor/aggregate_test.go | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/executor/aggregate.go b/executor/aggregate.go index 27bda76e3a9fc..b0d9ad10897f9 100644 --- a/executor/aggregate.go +++ b/executor/aggregate.go @@ -774,6 +774,12 @@ func (e *StreamAggExec) Open(ctx context.Context) error { // Close implements the Executor Close interface. func (e *StreamAggExec) Close() error { e.childResult = nil + if e.curGroupKey != nil { + e.curGroupKey = e.curGroupKey[:0] + } + if e.tmpGroupKey != nil { + e.tmpGroupKey = e.tmpGroupKey[:0] + } return errors.Trace(e.baseExecutor.Close()) } diff --git a/executor/aggregate_test.go b/executor/aggregate_test.go index f3a61e79888e2..30586fc16935c 100644 --- a/executor/aggregate_test.go +++ b/executor/aggregate_test.go @@ -708,3 +708,13 @@ func (s *testSuite) TestIssue10098(c *C) { tk.MustExec("insert into t values('1', '222'), ('12', '22')") tk.MustQuery("select group_concat(distinct a, b) from t").Check(testkit.Rows("1222,1222")) } + +func (s *testSuite) TestIssue10608(c *C) { + tk := testkit.NewTestKitWithInit(c, s.store) + tk.MustExec(`drop table if exists t, s;`) + tk.MustExec("CREATE TABLE t (id int(11) NOT NULL,PRIMARY KEY (id)) ;") + tk.MustExec("CREATE TABLE s (id int(11) NOT NULL,b int(11) NOT NULL,PRIMARY KEY (id)) ") + tk.MustExec("INSERT INTO t VALUES (508931),(508932); ") + tk.MustExec("INSERT INTO s VALUES (100292, 508931),(120002, 508932);") + tk.MustQuery("select (select group_concat(concat(123,'-')) from t where t.id = b group by t.id) from s;").Check(testkit.Rows("123-", "123-")) +}