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]: zero-like and empty strings fail MySQL-compatible numeric casts #25243
select cast('-0'as unsigned) as unsigned_neg_zero;
select cast('+000'asdecimal(6,2)) as decimal_plus_zero;
select cast(''as signed) as empty_signed,
cast(''as unsigned) as empty_unsigned,
cast(''asdecimal(6,2)) as empty_decimal,
''+1as empty_plus_one;
select cast(''as signed) as space_signed,
cast(''asdecimal(6,2)) as space_decimal,
''+1as space_plus_one;
select cast('-0' as unsigned);
ERROR 20203 (HY000): invalid argument cast to uint64, bad value -0
select cast('+000' as decimal(6,2));
ERROR 20301 (HY000): invalid input: +000 beyond the range, can't be converted to Decimal64(6,2).
select cast('' as signed);
ERROR 20203 (HY000): invalid argument cast to int, bad value
Expected Behavior
MySQL coerces zero-like strings, empty strings, and all-space strings to numeric zero in expression context, emitting warnings instead of failing the query. MatrixOne should align these string-to-numeric cast/coercion paths with MySQL.
Duplicate Check
Related but not identical: #25225 covers a leading-plus string converted to UNSIGNED. This issue tracks zero-like and empty/all-space string-to-numeric conversion cases on latest main.
Validation SQL and result for the zero-like cases that were called out for fixing:
select cast('-0'as unsigned) as neg_zero_unsigned,
cast('-0b0'as unsigned) as neg_bin_zero_unsigned,
cast('-0o0'as unsigned) as neg_oct_zero_unsigned,
cast('-0x0'as unsigned) as neg_hex_zero_unsigned;
-- result-- neg_zero_unsigned | neg_bin_zero_unsigned | neg_oct_zero_unsigned | neg_hex_zero_unsigned-- 0 | 0 | 0 | 0select cast('+000'asdecimal(6,2)) as plus_zero_decimal,
cast('-000'asdecimal(6,2)) as minus_zero_decimal;
-- result-- plus_zero_decimal | minus_zero_decimal-- 0.00 | 0.00
Additional check:
Empty string / all-space string casts still return MO errors, for example cast('' as signed) and cast(' ' as signed) still return invalid argument cast to int.
I did not add those rows to motr because the earlier R&D comment said non-numeric string-to-number conversion should continue to follow MO's existing behavior rather than MySQL's warning-and-zero behavior.
Conclusion:
The zero-like cases explicitly mentioned in the issue comments are fixed on latest main.
Non-numeric empty/all-space string coercion remains MO current behavior and is not included in the regression case.
Added motr regression coverage in matrixorigin/motr#39:
Activity
daviszhen commentedon Jul 3, 2026
字符串 'abc','123abc' 转 数字, mo 既 不返回0, 也不返回 NULL, 一直报错的。 这类case 也避免掉。mo不会改已经用了多年的行为。
daviszhen commentedon Jul 3, 2026
这类问题要修改
select cast('-0' as unsigned) as unsigned_neg_zero;
select cast('+000' as decimal(6,2)) as decimal_plus_zero;
fix cast digital string (#25449)
daviszhen commentedon Jul 7, 2026
修改了行为.
Ariznawlll commentedon Jul 8, 2026
Verified on latest
main.Build tested:
mainec01c62e4Validation SQL and result for the zero-like cases that were called out for fixing:
Additional check:
cast('' as signed)andcast(' ' as signed)still returninvalid argument cast to int.Conclusion:
main.Added motr regression coverage in matrixorigin/motr#39:
suites/14_issue_regression/t/issue_25243_cast_zero_like_strings.testsuites/14_issue_regression/r/issue_25243_cast_zero_like_strings.resultmotr validation:
add mysql compatibility type conversion and comparison bvt cases (#25219
fix cast digital string (matrixorigin#25449)
add mysql compatibility type conversion and comparison bvt cases (mat…
fix cast digital string (matrixorigin#25449)
add mysql compatibility type conversion and comparison bvt cases (mat…
fix cast digital string (matrixorigin#25449)
add mysql compatibility type conversion and comparison bvt cases (mat…