Skip to content

Commit

Permalink
expression: fix type infer for decimal property in count agg (#17368) (
Browse files Browse the repository at this point in the history
…#17702)

Signed-off-by: sre-bot <sre-bot@pingcap.com>

Co-authored-by: lysu <sulifx@gmail.com>
  • Loading branch information
sre-bot and lysu authored Jun 7, 2020
1 parent 9b915a7 commit 5f52591
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions expression/aggregation/base_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,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)
}

Expand Down
1 change: 1 addition & 0 deletions expression/typeinfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,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},
}
}

Expand Down

0 comments on commit 5f52591

Please sign in to comment.