使用下面命令部署数据库
docker pull oceanbase/oceanbase-ce:4.3.5-lts
docker run -p 2881:2881 --name oceanbase-ce -d oceanbase/oceanbase-ce:4.3.5-lts
mysql -h127.0.0.1 -P12881 -uroot@test # Connect with the root account of a general tenant
运行一下测试用例,其中查询语句返回了不正确的结果。
CREATE TABLE t0 (c1 TEXT);
INSERT INTO t0 VALUES (14954857449029110191);
SELECT BIT_COUNT(c1) FROM t0; -- actual:{63}, expected:{37}
在测试用例中,我们尝试存储一个较大的数值,但是符合MySQL中BIGINT UNSIGNED的存储范围。当使用BIT_COUNT进行运算时,该值能够无损转成BIGINT UNSIGNED值,因此返回结果应该是37。
我们可以运行下面的PoC用例得到预期的结果。
CREATE TABLE t0 (c1 TEXT);
INSERT INTO t0 VALUES (14954857449029110191);
SELECT BIT_COUNT(CAST(c1 AS UNSIGNED)) FROM t0; -- 37