You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: BIT_COUNT exposes a parsing error instead of coercing nonnumeric strings #28219
The same conversion error aborts a query over a VARCHAR column as soon as one row contains either value:
CREATETABLEt(id INTPRIMARY KEY, v VARCHAR(20));
INSERT INTO t VALUES (1, 'abc'), (2, '12x'), (3, '');
SELECT id, BIT_COUNT(v) FROM t ORDER BY id;
-- MatrixOne: ERROR 1105 (HY000): strconv.ParseUint: parsing "abc": invalid syntax-- MySQL: (1,0), (2,2), (3,0)
Numeric strings, surrounding spaces, negative strings, and empty strings already produce the expected values. The affected constant and column cases reproduced identically in three runs.
Expected Behavior
BIT_COUNT() should use MySQL-compatible numeric string conversion: a nonnumeric string converts to zero, and a leading numeric prefix is consumed. It must not expose a Go parsing error or abort the whole row set for these inputs.
Steps to Reproduce
SELECT BIT_COUNT('abc');
SELECT BIT_COUNT('12x');
CREATEDATABASEbit_count_repro;
USE bit_count_repro;
CREATETABLEt(id INTPRIMARY KEY, v VARCHAR(20));
INSERT INTO t VALUES (1, 'abc'), (2, '12x'), (3, '');
SELECT id, BIT_COUNT(v) FROM t ORDER BY id;
Additional information
BitCountNonBinaryString calls bitCountFromMysqlIntegerString, but the parser returns its conversion error instead of applying MySQL's string-to-integer coercion behavior. The unit test TestBitCountStringInvalidFormat currently asserts that these formats return an error, so the incorrect behavior is encoded in the implementation test.
Activity
fix(sql): align ORD, BIT_COUNT and REGEXP UTF-8 semantics (#28267)
Ariznawlll commentedon Sep 7, 2026
测试版本
mainbcd5ed833b5400fe95f322e4028adb2bde3de0a4etc/launch/launch.toml,SQL 端口 6001原问题验证
在上述版本执行原问题中的常量和列值:
BIT_COUNT('abc')、BIT_COUNT('12x')、BIT_COUNT(''),并补充带空格和负号的前缀值BIT_COUNT(' -3tail')。常量结果分别为0、2、0、63,不再返回strconv.ParseUint错误。建立VARCHAR表插入相同四类值后逐行查询,结果为(1,0)、(2,2)、(3,0)、(4,63)。以上 SQL 在同一环境连续执行 3 轮,3/3 轮结果一致,查询均正常完成;表和数据库均在每轮结束时清理。
Happy Path 覆盖
BIT_COUNT('64')返回1。0、2、0、63。VARCHAR列逐行执行相同转换,所有行均返回结果且行顺序、值与输入一致。Unhappy Path 覆盖
abc:不再暴露解析错误,返回0。12x:不报错,按数字前缀转换并返回2。0和63;失败后表数据保持完整并完成清理。白盒验证
不适用。本问题通过公开 SQL 接口验证,未使用内部故障注入。
回归测试
已加入现有 MOTR PR #147,新增:
suites/14_issue_regression/t/issue_28219_bit_count_string_coercion.test对应结果文件:
suites/14_issue_regression/r/issue_28219_bit_count_string_coercion.result本地 MOTR 定向回归命令
./motr --repeat 3 14_issue_regression.issue_28219_bit_count_string_coercion结果为 3/3 success、27/27 statements success。测试证据
stmts=27 ok=27 fail=0测试结论
测试通过。
fix(sql): align ORD, BIT_COUNT and REGEXP UTF-8 semantics (matrixorig…
fix(sql): align ORD, BIT_COUNT and REGEXP UTF-8 semantics (matrixorig…
fix(sql): align ORD, BIT_COUNT and REGEXP UTF-8 semantics (matrixorig…