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
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