Skip to content

Commit

Permalink
expression: fix incorrect implementation in builtinRealIsFalseSig (#…
Browse files Browse the repository at this point in the history
…19658)

* fixup

* fixup
  • Loading branch information
qw4990 authored Sep 1, 2020
1 parent e24d145 commit 7690e29
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions expression/builtin_op_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,14 @@ func (b *builtinRealIsFalseSig) vecEvalInt(input *chunk.Chunk, result *chunk.Col

result.ResizeInt64(numRows, false)
i64s := result.Int64s()
bufI64s := buf.Int64s()
bufF64s := buf.Float64s()
for i := 0; i < numRows; i++ {
isNull := buf.IsNull(i)
if b.keepNull && isNull {
result.SetNull(i, true)
continue
}
if isNull || bufI64s[i] != 0 {
if isNull || bufF64s[i] != 0 {
i64s[i] = 0
} else {
i64s[i] = 1
Expand Down
14 changes: 14 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7098,6 +7098,20 @@ func (s *testIntegrationSerialSuite) TestIssue19116(c *C) {
tk.MustQuery("select coercibility(1=1);").Check(testkit.Rows("5"))
}

func (s *testIntegrationSerialSuite) TestIssue18674(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustQuery("select -1.0 % -1.0").Check(testkit.Rows("0.0"))
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1(`pk` int primary key,`col_float_key_signed` float ,key (`col_float_key_signed`))")
tk.MustExec("insert into t1 values (0, null), (1, 0), (2, -0), (3, 1), (-1,-1)")
tk.MustQuery("select * from t1 where ( `col_float_key_signed` % `col_float_key_signed`) IS FALSE").Sort().Check(testkit.Rows("-1 -1", "3 1"))
tk.MustQuery("select `col_float_key_signed` , `col_float_key_signed` % `col_float_key_signed` from t1").Sort().Check(testkit.Rows(
"-1 -0", "0 <nil>", "0 <nil>", "1 0", "<nil> <nil>"))
tk.MustQuery("select `col_float_key_signed` , (`col_float_key_signed` % `col_float_key_signed`) IS FALSE from t1").Sort().Check(testkit.Rows(
"-1 1", "0 0", "0 0", "1 1", "<nil> 0"))
}

func (s *testIntegrationSerialSuite) TestIssue17063(c *C) {
collate.SetNewCollationEnabledForTest(true)
defer collate.SetNewCollationEnabledForTest(false)
Expand Down
4 changes: 4 additions & 0 deletions types/mydecimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2281,6 +2281,10 @@ func doDivMod(from1, from2, to, mod *MyDecimal, fracIncr int) error {
if idxTo != 0 {
copy(to.wordBuf[:], to.wordBuf[idxTo:])
}

if to.IsZero() {
to.negative = false
}
return err
}

Expand Down

0 comments on commit 7690e29

Please sign in to comment.