diff --git a/mysql/mydecimal.go b/mysql/mydecimal.go index 65747809fb752..cadfbfdd1f248 100644 --- a/mysql/mydecimal.go +++ b/mysql/mydecimal.go @@ -1512,7 +1512,7 @@ func doAdd(from1, from2, to *MyDecimal) error { var x int32 if wordsInt1 > wordsInt2 { x = from1.wordBuf[0] - } else if wordsInt2 < wordsInt1 { + } else if wordsInt2 > wordsInt1 { x = from2.wordBuf[0] } else { x = from1.wordBuf[0] + from2.wordBuf[0] diff --git a/mysql/mydecimal_test.go b/mysql/mydecimal_test.go index 8fb1e9632ce19..b0a5a621aa736 100644 --- a/mysql/mydecimal_test.go +++ b/mysql/mydecimal_test.go @@ -14,8 +14,9 @@ package mysql import ( - . "github.com/pingcap/check" "strings" + + . "github.com/pingcap/check" ) var _ = Suite(&testMyDecimalSuite{}) @@ -474,6 +475,7 @@ func (s *testMyDecimalSuite) TestAdd(c *C) { {"123.45", "-12345", "-12221.55", nil}, {"-123.45", "12345", "12221.55", nil}, {"5", "-6.0", "-1.0", nil}, + {"2" + strings.Repeat("1", 71), strings.Repeat("8", 81), "8888888890" + strings.Repeat("9", 71), nil}, } for _, ca := range cases { a := NewDecFromStringForTest(ca.a)