Bug #108045 On the negative result representation of the unary operator &, |,^,~
Submitted: 1 Aug 12:06 Modified: 9 Aug 8:43
Reporter: chenglin Tian Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Operator Severity:S3 (Non-critical)
Version:8.0.29 OS:Ubuntu
Assigned to: CPU Architecture:Any

[1 Aug 12:06] chenglin Tian
Description:
On MySQL database of version 8.0.29, when using unary operator to calculate, if the result is negative, the result will show an exception.

How to repeat:
SELECT -5 & -4; -- expected: -8, actual: 18446744073709551608
SELECT '-5' | '-4'; -- expected: -3, actual: 18446744073709551615
SELECT '5' ^ '-4'; -- expected: -7, actual: 18446744073709551609
SELECT ~5; -- expected: -6, actual: 18446744073709551610

SELECT -3 > ('5' ^ '-4'); -- expected: 1, actual: 0
[1 Aug 19:16] MySQL Verification Team
Hi,

Thanks for the report
[9 Aug 8:43] Roy Lyseng
Posted by developer:
 
Not a bug.

Bitwise AND contains the following documentation:
 
Binary-string evaluation occurs when the arguments have a binary string type,
and at least one of them is not a hexadecimal literal, bit literal, or NULL
literal. Numeric evaluation occurs otherwise, with argument conversion to
unsigned 64-bit integers as necessary.
 
So, this is the expected behavior.