Description:
Thus documented:
BIT_AND(expr)
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.