Skip to content

Commit

Permalink
expression: keep xor result consistent with mysql 8 (#15934) (#16978)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored May 13, 2020
1 parent 6c7b4dc commit 7d051c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions expression/builtin_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ func (c *logicXorFunctionClass) getFunction(ctx sessionctx.Context, args []Expre
if err != nil {
return nil, err
}
args[0], err = wrapWithIsTrue(ctx, true, args[0], false)
if err != nil {
return nil, errors.Trace(err)
}
args[1], err = wrapWithIsTrue(ctx, true, args[1], false)
if err != nil {
return nil, errors.Trace(err)
}

bf, err := newBaseBuiltinFuncWithTp(ctx, c.funcName, args, types.ETInt, types.ETInt, types.ETInt)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions expression/builtin_op_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,13 +589,13 @@ func (s *testEvaluatorSuite) TestLogicXor(c *C) {
{[]interface{}{0, nil}, 0, true, false},
{[]interface{}{nil, 0}, 0, true, false},
{[]interface{}{nil, 1}, 0, true, false},
{[]interface{}{0.5000, 0.4999}, 1, false, false},
{[]interface{}{0.5000, 0.4999}, 0, false, false},
{[]interface{}{0.5000, 1.0}, 0, false, false},
{[]interface{}{0.4999, 1.0}, 1, false, false},
{[]interface{}{0.4999, 1.0}, 0, false, false},
{[]interface{}{nil, 0.000}, 0, true, false},
{[]interface{}{nil, 0.001}, 0, true, false},
{[]interface{}{types.NewDecFromStringForTest("0.000001"), 0.00001}, 0, false, false},
{[]interface{}{types.NewDecFromStringForTest("0.000001"), 1}, 1, false, false},
{[]interface{}{types.NewDecFromStringForTest("0.000001"), 1}, 0, false, false},
{[]interface{}{types.NewDecFromStringForTest("0.000000"), nil}, 0, true, false},
{[]interface{}{types.NewDecFromStringForTest("0.000001"), nil}, 0, true, false},

Expand Down

0 comments on commit 7d051c8

Please sign in to comment.