Skip to content

Commit

Permalink
expression: use maximum length for integer display (#56463) (#56926)
Browse files Browse the repository at this point in the history
close #41719, close #45338, close #56462
  • Loading branch information
ti-chi-bot authored Nov 11, 2024
1 parent 1e0d6e3 commit 8003f50
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions expression/builtin_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,25 @@ func setFlenFromArgs(evalType types.EvalType, resultFieldType *types.FieldType,
} else if evalType == types.ETString {
maxLen := 0
for i := range argTps {
argFlen := argTps[i].GetFlen()
if argFlen == types.UnspecifiedLength {
resultFieldType.SetFlen(types.UnspecifiedLength)
return
switch argTps[i].GetType() {
case mysql.TypeTiny:
maxLen = maxlen(4, maxLen)
case mysql.TypeShort:
maxLen = maxlen(6, maxLen)
case mysql.TypeInt24:
maxLen = maxlen(9, maxLen)
case mysql.TypeLong:
maxLen = maxlen(11, maxLen)
case mysql.TypeLonglong:
maxLen = maxlen(20, maxLen)
default:
argFlen := argTps[i].GetFlen()
if argFlen == types.UnspecifiedLength {
resultFieldType.SetFlen(types.UnspecifiedLength)
return
}
maxLen = maxlen(argFlen, maxLen)
}
maxLen = maxlen(argFlen, maxLen)
}
resultFieldType.SetFlen(maxLen)
} else {
Expand Down

0 comments on commit 8003f50

Please sign in to comment.