Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: reset groupChecker for StreamAggExec when Close #10615

Merged
merged 3 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions executor/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ func (e *StreamAggExec) Open(ctx context.Context) error {
// Close implements the Executor Close interface.
func (e *StreamAggExec) Close() error {
e.childResult = nil
e.groupChecker.reset()
return e.baseExecutor.Close()
}

Expand Down Expand Up @@ -954,3 +955,12 @@ func (e *groupChecker) meetNewGroup(row chunk.Row) (bool, error) {
}
return !firstGroup, nil
}

func (e *groupChecker) reset() {
if e.curGroupKey != nil {
e.curGroupKey = e.curGroupKey[:0]
}
if e.tmpGroupKey != nil {
e.tmpGroupKey = e.tmpGroupKey[:0]
}
}
11 changes: 11 additions & 0 deletions executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,3 +710,14 @@ func (s *testSuite1) 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 *testSuite1) TestIssue10608(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec(`drop table if exists t, s;`)
tk.MustExec("create table t(a int)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test case currently does not cover the bug since it can't reproduce the bug.

we should modify this line to create table t(a int primary key);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@XuHuaiyu XuHuaiyu Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by it can't reproduce the bug?
@cosven

Copy link
Contributor

@cosven cosven Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I expect
this test case should fail in previous commits(version), such as 3.0.0-beta
it should return error 1105 - subquery returns more than 1 row

what I saw instead
it passed.


What do you mean by it can't reproduce the bug?

this test case can't prove this PR fixes the bug described in issue #10608, because this unittest case will always pass.

tk.MustExec("create table s(a int, b int)")
tk.MustExec("insert into s values(100292, 508931), (120002, 508932)")
tk.MustExec("insert into t values(508931), (508932)")
tk.MustQuery("select (select group_concat(concat(123,'-')) from t where t.a = s.b group by t.a) as t from s;").Check(testkit.Rows("123-", "123-"))

}