Bug #68829 BIT_AND s width is always 64 bits????
Submitted: 1 Apr 2013 21:10
Reporter: Programmer Old Email Updates:
Status: Open Impact on me:
Category:MySQL Server Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[1 Apr 2013 21:10] Programmer Old
Thus documented:


Returns the bitwise AND of all bits in expr. The calculation is performed with 64-bit (BIGINT) precision.

This function returns 18446744073709551615 if there were no matching rows. (This is the value of an unsigned BIGINT value with all bits set to 1.)

How to repeat:
Why isn't the result just as wide as the argument? The bit operations AND, OR, XOR (and also the operations MAX and MIN) need no more, no less, precision than their widest arguments. In the case of an aggregate operation, all arguments are of the very same type, no?

Suggested fix:
Make BIT_AND s result of the same type as its argument s, with same width, and all--and the same for the other bit aggregate functions.