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]: flow-control functions evaluate skipped branches instead of short-circuiting like MySQL #25314
Latest origin/main verified locally at 200bfa7e0efb.
Reproduce Steps
set session sql_mode ='';
select if(0, cast('bad'as signed), 7) as if_skip_true_branch;
select case when 0 then cast('bad'as signed) else 7 end as case_skip_then;
select coalesce(5, cast('bad'as signed)) as coalesce_skip_later;
select ifnull(5, cast('bad'as signed)) as ifnull_skip_later;
Expected Behavior
MySQL returns 7, 7, 5, and 5; skipped branches/later fallback expressions do not make the statement fail.
ERROR 20203 (HY000): invalid argument cast to int, bad value bad
Notes
Found during MySQL compatibility Module 7 exploration. This affects IF, CASE, COALESCE, and IFNULL when an unused branch contains an expression that would be invalid if evaluated or coerced eagerly.
Activity
LeftHandCold commentedon Jul 19, 2026
fixed
Ariznawlll commentedon Jul 20, 2026
已在最新
main分支完成验证。测试环境
main826a3e3d294ba62c7c4da217d1445f3c568ce4d9go1.26.4 darwin/arm648.0.30-MatrixOne-v1.3.0 826a3e3d2测试步骤
1. 原始 SQL 场景
连续执行 3 轮以下查询,未选中的分支均包含会报错的
CAST('bad' AS SIGNED):2. 批量场景
构造多行输入,分别验证 IF、CASE 和 COALESCE 在 batch shrinking/selection 变化时,仅对当前行实际选中的分支求值;未选中的 invalid cast 不应被提前计算。连续执行 3 轮,预期分别返回:
3. 代码级回归
运行
pkg/sql/colexec中TestFlowControlShortCircuitInvalidCast,普通模式和-race模式各连续 3 轮。该用例还覆盖 invalid cast、regexp、SLEEP、参数复用、batch shrinking、partial runtime type 等路径。测试结果
-race模式各连续 3 轮全部通过。结论
最新
main上 IF、CASE、COALESCE、IFNULL 已按 MySQL 语义执行短路求值,本问题验证通过。