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]: SET @a = 1, @b = 2; SELECT @a + @b;reported invalid argument operator +, bad value [TEXT TEXT] in 3.0-dev #24492
-- 方案 1: 分开执行 SET 语句SET @a =1;
SET @b =2;
SELECT @a + @b;
-- 方案 2: 直接在 SELECT 中计算SELECT1+2;
-- 方案 3: 使用子查询或 CTE 代替变量
WITH vars AS (SELECT1AS a, 2AS b)
SELECT a + b FROM vars;
Supplemented a prepared-statement variant on latest main (git_version() = 51656deb6).
This appears to share the same root cause as the user-variable numeric coercion issue: parameter markers are treated as TEXT during arithmetic analysis.
dropdatabase if exists mysql_compat_model14_prepare;
createdatabasemysql_compat_model14_prepare;
use mysql_compat_model14_prepare;
prepare ps_count from'select ? + ? as sum_val';
set @c1 =1, @c2 =2;
execute ps_count using @c1, @c2;
MySQL 8.0.45:
sum_val
3
MO:
ERROR 20203 (HY000): invalid argument operator +, bad value [TEXT TEXT]
ERROR 20400 (HY000): invalid state prepared statement 'ps_count' does not exist
Activity
Ariznawlll commentedon Jul 3, 2026
Supplemented a prepared-statement variant on latest
main(git_version() = 51656deb6).This appears to share the same root cause as the user-variable numeric coercion issue: parameter markers are treated as
TEXTduring arithmetic analysis.MySQL
8.0.45:MO:
Ariznawlll commentedon Aug 20, 2026
测试版本
mainc8e3fa745a336a406a0d17f29c3c05fb48bd394c原问题验证
执行用户变量整数、负数、DECIMAL、数字文本和 NULL 运算,并通过 SQL PREPARE 参数重用验证数值类型保持。整数
1+2返回 3,负数和 DECIMAL 结果正确;错误文本遵循 MySQL 兼容转换规则,未再出现[TEXT TEXT]类型错误。Happy Path 覆盖
@a+@b、负数、DECIMAL 和数字文本运算结果正确。?+?在整数、DECIMAL 和 NULL 参数下结果正确。Unhappy Path 覆盖
白盒验证
不适用:问题是用户可见 SQL 表达式和 prepared 参数类型语义,已由黑盒矩阵覆盖。
回归测试
已加入 MOTR PR #114,用例为
issue_24492_user_variable_arithmetic.test。该问题是小数据确定性 SQL 语义,不需要大数据量回归。测试证据
MOTR focused repeat:
total=18 success=18 failed=0,本用例每轮 26/26 语句通过。测试结论
测试通过。