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]: FORMAT truncates zero-decimal values and loses the negative sign while rounding #28213
#10152 was closed in 2023 and contains only an attached result sheet. The concrete rounding, sign-loss, and decimal-limit behavior below remains on current main.
Branch Name
main
Commit ID
e7bb0572235ec4bac81eb098eb0ad8900f0065ab
Other Environment Information
Local standalone MatrixOne; MySQL text protocol
Reference: MySQL 8.3.0
Actual Behavior
FORMAT() truncates instead of rounding when D = 0, and loses the minus sign when a fractional value is rounded:
The formatting routine performs fractional rounding only inside if position > 0; its rounding branch resets the output buffer after the minus sign has already been removed and written; and it does not cap the parsed scale.
Activity
fix(sql): harden FORMAT numeric and locale handling (#28508)
Ariznawlll commentedon Sep 10, 2026
测试版本
mainfc621e3616d229c7a29d0c80e73ed8eb1997459c1 Log / 1 TN / 1 CN原问题验证
FORMAT(1.5,0)、FORMAT(2.5,0)、FORMAT(-1.5,0)、FORMAT(-2.5,0)连续 3 次稳定返回2 / 3 / -2 / -3;FORMAT(-1.25,1)、FORMAT(-1.35,1)返回-1.3 / -1.4,负号不再丢失。Happy Path 覆盖
1.5、-1.5、-1.25、-1.35按D=0/1得到与常量相同的正确结果。FORMAT(1.5,100)的结果长度为32,即整数、分隔符和 30 位小数,正确执行上限保护。Unhappy Path 覆盖
本 issue 的
D=100是合法边界而非应拒绝输入;已验证其被限制到 30 位小数且查询后数据可继续读取。畸形文本参数的无 panic 覆盖见 #28475。白盒验证
修复 PR matrixone#28508 已合入;
pkg/vectorize/format的定向单测在本地最新 main 上通过。回归测试
已加入 MOTR PR #153:
issue_28213_28475_28476_28478_28480_format_compatibility.test。新用例连续 3 次通过,共 90 statements / 90 successes。测试证据
fc621e3616。测试结论
测试通过。
fix(sql): harden FORMAT numeric and locale handling (matrixorigin#28508)
fix(sql): harden FORMAT numeric and locale handling (matrixorigin#28508)
fix(sql): harden FORMAT numeric and locale handling (matrixorigin#28508)