Bug #89580 | Wrong results of XOR expression | ||
---|---|---|---|
Submitted: | 8 Feb 2018 2:57 | Modified: | 8 Feb 2018 14:20 |
Reporter: | Eric Fu | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Data Types | Severity: | S3 (Non-critical) |
Version: | 5.7.19 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | arithmetic, expression, Logical, operators, xor |
[8 Feb 2018 2:57]
Eric Fu
[8 Feb 2018 14:15]
MySQL Verification Team
Hi, That is expected behavior because of > select cast(0.4 AS unsigned int), cast(0.6 as unsigned int); +---------------------------+---------------------------+ | cast(0.4 AS unsigned int) | cast(0.6 as unsigned int) | +---------------------------+---------------------------+ | 0 | 1 | +---------------------------+---------------------------+ 1 row in set (0.00 sec) all best Bogdan
[8 Feb 2018 14:17]
MySQL Verification Team
NOT() is a little inconsistent to operators as it looks at != 0 instead of cast to int so you get > select not(0.4), not(0.6); +----------+----------+ | not(0.4) | not(0.6) | +----------+----------+ | 0 | 0 | +----------+----------+ 1 row in set (0.00 sec) and that's why there's a confusion, but is expected behavior
[8 Feb 2018 14:20]
MySQL Verification Team
hi, looking forward, this actually is a bug as it's not only not() .. XOR is def. behaving differently then others mysql [localhost] {msandbox} ((none)) > select 0 and 1; +---------+ | 0 and 1 | +---------+ | 0 | +---------+ 1 row in set (0.00 sec) mysql [localhost] {msandbox} ((none)) > select 0.3 and 1; +-----------+ | 0.3 and 1 | +-----------+ | 1 | +-----------+ 1 row in set (0.00 sec) > select 0.3 or 0; +----------+ | 0.3 or 0 | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) verifying this thanks for report Bogdan