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: use deep copy for maxMin4JSON (#15242) #15289

Merged
merged 5 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion executor/aggfuncs/func_max_min.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ func (e *maxMin4JSON) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup [
}
cmp := json.CompareBinary(input, p.val)
if e.isMax && cmp > 0 || !e.isMax && cmp < 0 {
p.val = input
p.val = input.Copy()
}
}
return nil
Expand Down
14 changes: 14 additions & 0 deletions executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,3 +752,17 @@ func (s *testSuite1) TestIssue10608(c *C) {
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-"))

}

func (s *testSuiteAgg) TestPR15242ShallowCopy(c *C) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix this issue:"executor/aggregate_test.go:756:10: undefined: testSuiteAgg"

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, tks.

tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec(`drop table if exists t;`)
tk.MustExec(`create table t(a json);`)
tk.MustExec(`insert into t values ('{"id": 1,"score":23}');`)
tk.MustExec(`insert into t values ('{"id": 2,"score":23}');`)
tk.MustExec(`insert into t values ('{"id": 1,"score":233}');`)
tk.MustExec(`insert into t values ('{"id": 2,"score":233}');`)
tk.MustExec(`insert into t values ('{"id": 3,"score":233}');`)
tk.Se.GetSessionVars().MaxChunkSize = 2
tk.MustQuery(`select max(JSON_EXTRACT(a, '$.score')) as max_score,JSON_EXTRACT(a,'$.id') as id from t group by id order by id;`).Check(testkit.Rows("233 1", "233 2", "233 3"))

}