Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: handle ErrTruncated when dividing decimals in non-data-change stmts #14438

Merged
merged 9 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4400,6 +4400,11 @@ func (s *testIntegrationSuite) TestDecimalMul(c *C) {
res.Check(testkit.Rows("0.55125221922461136"))
}

func (s *testIntegrationSuite) TestDecimalDiv(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustQuery("select cast(1 as decimal(60,30)) / cast(1 as decimal(60,30)) / cast(1 as decimal(60, 30))").Check(testkit.Rows("1.000000000000000000000000000000"))
}

func (s *testIntegrationSuite) TestUnknowHintIgnore(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("USE test")
Expand Down
5 changes: 5 additions & 0 deletions types/mydecimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,11 @@ func doDivMod(from1, from2, to, mod *MyDecimal, fracIncr int) error {
to.digitsInt = int8(wordsIntTo * digitsPerWord)
to.digitsFrac = int8(wordsFracTo * digitsPerWord)
}

if to.digitsFrac > notFixedDec {
to.digitsFrac = notFixedDec
}

idxTo := 0
stopTo := wordsIntTo + wordsFracTo
if mod == nil {
Expand Down