diff --git a/expression/aggregation/base_func.go b/expression/aggregation/base_func.go index 352e1cc870a1b..17762632454c4 100644 --- a/expression/aggregation/base_func.go +++ b/expression/aggregation/base_func.go @@ -120,6 +120,7 @@ func (a *baseFuncDesc) typeInfer(ctx sessionctx.Context) error { func (a *baseFuncDesc) typeInfer4Count(ctx sessionctx.Context) { a.RetTp = types.NewFieldType(mysql.TypeLonglong) a.RetTp.Flen = 21 + a.RetTp.Decimal = 0 types.SetBinChsClnFlag(a.RetTp) } diff --git a/expression/typeinfer_test.go b/expression/typeinfer_test.go index e53b98311bf6d..911ca01de79d6 100644 --- a/expression/typeinfer_test.go +++ b/expression/typeinfer_test.go @@ -835,6 +835,7 @@ func (s *testInferTypeSuite) createTestCase4Aggregations() []typeInferTestCase { {"avg(1.2e2)", mysql.TypeDouble, charset.CharsetBin, mysql.BinaryFlag, mysql.MaxRealWidth, types.UnspecifiedLength}, {"avg(c_char)", mysql.TypeDouble, charset.CharsetBin, mysql.BinaryFlag, mysql.MaxRealWidth, types.UnspecifiedLength}, {"group_concat(c_int_d)", mysql.TypeVarString, charset.CharsetUTF8MB4, 0, mysql.MaxBlobWidth, 0}, + {"count(c_decimal)", mysql.TypeLonglong, charset.CharsetBin, mysql.BinaryFlag, 21, 0}, } }