Bug #119154 Incorrect BIT_COUNT value for TEXT column
Submitted: 14 Oct 13:24
Reporter: John Jove Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:8.4.6 OS:Any
Assigned to: CPU Architecture:Any

[14 Oct 13:24] John Jove
Description:
I run the following statements in case 1, where an incorrect result is returned.
The possible root cause is that when internally casting 14954857449029110191 to an unsigned number, an overflowed value is returned. 
However, the 14954857449029110191 value is able to store into the BIGINT UNSIGNED column, thus such overflow should not happen. In the PoC case, a correct value is returned.

How to repeat:
-- case 1
CREATE TABLE t0 (c1 TEXT);
INSERT INTO t0 VALUES (14954857449029110191);
SELECT BIT_COUNT(c1) FROM t0; -- actual:{63}, expected:{37}

-- PoC case
CREATE TABLE t0 (c1 BIGINT UNSIGNED);
INSERT INTO t0 VALUES (14954857449029110191);
SELECT BIT_COUNT(c1) FROM t0; -- 37