Skip to content

Commit

Permalink
executor: use EncodeBytes in countOriginDistinct
Browse files Browse the repository at this point in the history
  • Loading branch information
XuHuaiyu committed Apr 11, 2019
1 parent f723f0b commit 78b1c7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion executor/aggfuncs/func_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/types/json"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/codec"
"github.com/pingcap/tidb/util/hack"
"github.com/pingcap/tidb/util/set"
)

Expand Down Expand Up @@ -329,7 +331,7 @@ func (e *countOriginalWithDistinct) evalAndEncode(
if err != nil || isNull {
break
}
encodedBytes = appendString(encodedBytes, buf, val)
encodedBytes = codec.EncodeBytes(encodedBytes, hack.Slice(val))
default:
return nil, false, errors.Errorf("unsupported column type for encode %d", tp)
}
Expand Down
8 changes: 8 additions & 0 deletions executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,3 +694,11 @@ func (s *testSuite1) TestAggJSON(c *C) {
`"hello"`,
))
}

func (s *testSuite1) TestIssue10099(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a char(10), b char(10))")
tk.MustExec("insert into t values('1', '222'), ('12', '22')")
tk.MustQuery("select count(distinct a, b) from t").Check(testkit.Rows("2"))
}

0 comments on commit 78b1c7b

Please sign in to comment.