From 26637bcb28be0add60d0136ed7ffc2f4cfbf6f53 Mon Sep 17 00:00:00 2001 From: wshwsh12 <793703860@qq.com> Date: Mon, 8 Jan 2024 16:15:03 +0800 Subject: [PATCH] pick --- executor/aggregate.go | 4 ++-- executor/issuetest/executor_issue_test.go | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/executor/aggregate.go b/executor/aggregate.go index 561bd4dcd9502..d34d7be17731c 100644 --- a/executor/aggregate.go +++ b/executor/aggregate.go @@ -1509,12 +1509,12 @@ func (e *vecGroupChecker) splitIntoGroups(chk *chunk.Chunk) (isFirstGroupSameAsP return false, err } } - e.firstGroupKey, err = codec.EncodeValue(e.ctx.GetSessionVars().StmtCtx, e.firstGroupKey, e.firstRowDatums...) + e.firstGroupKey, err = codec.EncodeKey(e.ctx.GetSessionVars().StmtCtx, e.firstGroupKey, e.firstRowDatums...) if err != nil { return false, err } - e.lastGroupKey, err = codec.EncodeValue(e.ctx.GetSessionVars().StmtCtx, e.lastGroupKey, e.lastRowDatums...) + e.lastGroupKey, err = codec.EncodeKey(e.ctx.GetSessionVars().StmtCtx, e.lastGroupKey, e.lastRowDatums...) if err != nil { return false, err } diff --git a/executor/issuetest/executor_issue_test.go b/executor/issuetest/executor_issue_test.go index 91664bfcece4a..0a52238c4ef65 100644 --- a/executor/issuetest/executor_issue_test.go +++ b/executor/issuetest/executor_issue_test.go @@ -1477,3 +1477,20 @@ func TestIssue49369(t *testing.T) { tk.MustQuery("select * from issue49369").Check(testkit.Rows("999999999999999999000000000000")) tk.MustExec("set @@sql_mode = default") } + +func TestIssue49902(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") + tk.MustExec("set @@tidb_max_chunk_size = 32;") + tk.MustExec("drop table if exists t, s;") + tk.MustExec("CREATE TABLE `t` (`c` char(1)) COLLATE=utf8_general_ci ;") + tk.MustExec("insert into t values(\"V\"),(\"v\");") + tk.MustExec("insert into t values(\"V\"),(\"v\"),(\"v\");") + tk.MustExec("CREATE TABLE `s` (`col_61` int);") + tk.MustExec("insert into s values(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1);") + tk.MustExec("insert into s values(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1);") + tk.MustQuery("SELECT /*+ stream_agg()*/ count(`t`.`c`) FROM (`s`) JOIN `t` GROUP BY `t`.`c`;").Check(testkit.Rows("170")) + tk.MustQuery("SELECT count(`t`.`c`) FROM (`s`) JOIN `t` GROUP BY `t`.`c`;").Check(testkit.Rows("170")) + tk.MustExec("set @@tidb_max_chunk_size = default;") +}