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]: Reading an undefined user variable @x errors instead of returning NULL; SELECT … INTO @var rejected #25123
Others: Found by the JDBC 4.2 API conformance probe (driver-level java.sql.* surface, JDBC_COMPAT.md), reduced to a driver-independent SQL repro. MySQL 8.0.30 wire protocol.
Actual Behavior
Two related user-defined-variable gaps. Basic assignment/readback works (SET @x = 5; SELECT @x; → 5), but:
SELECT @never_set; -- MatrixOne: 20101 internal error: the user variable never_set does not existSELECT abs(-5) INTO @o; -- MatrixOne: 1064 SQL parser error near "@o"
Expected Behavior
In MySQL, referencing a user variable that has never been assigned yields NULL (not an error), and SELECT expr INTO @var is standard syntax:
SELECT @never_set; -- MySQL: NULLSELECT abs(-5) INTO @o; -- MySQL: OK (sets @o = 5)
Steps to Reproduce
SET @x =5; SELECT @x; -- works: 5SELECT @never_set; -- MySQL: NULL MatrixOne: 20101 ... the user variable never_set does not existSELECT abs(-5) INTO @o; -- MySQL: OK (@o = 5) MatrixOne: 1064 SQL parser error near "@o"
Additional information
Impact: breaks JDBC CallableStatement function out-parameters. Connector/J implements {? = call f(?)} by capturing the result into a session variable named @com_mysql_jdbc_outparam_0 and reading it back; on MatrixOne this fails with "the user variable com_mysql_jdbc_outparam_0 does not exist". More generally, any application using @var accumulators or SELECT … INTO @var (a common MySQL idiom) is affected.
Fix: return NULL when reading an unassigned user variable (MySQL semantics), and support SELECT … INTO @var.
Related: the SELECT … INTO @var syntax gap overlaps with #24500 (§2 "SELECT INTO Variable"). The undefined-variable-returns-NULL behavior and the JDBC OUT-parameter impact above are not yet tracked separately.
Background: dengn/php-tester JDBC 4.2 API conformance probe (JDBC_COMPAT.md).
Supplemented a stored-procedure variant on latest main (git_version() = 51656deb6).
The original issue tracks SELECT expr INTO @var being rejected. The same parser gap appears inside a stored procedure when assigning to an OUT parameter:
dropdatabase if exists mysql_compat_model15_out_min;
createdatabasemysql_compat_model15_out_min;
use mysql_compat_model15_out_min;
createtablet_routine (id intprimary key, v varchar(20));
insert into t_routine values (1,'a'),(2,'b'),(3,'c');
create procedure p_out_select_into(out p_cnt int)
'begin select count(*) into p_cnt from t_routine; end';
call p_out_select_into(@cnt3);
select @cnt3 as cnt3;
MySQL equivalent returns:
cnt3
3
MO:
ERROR 1105 (HY000): syntax error ... near " p_cnt from t_routine; end";
ERROR 20101 (HY000): internal error: the user variable cnt3 does not exist
Activity
Ariznawlll commentedon Jul 3, 2026
Supplemented a stored-procedure variant on latest
main(git_version() = 51656deb6).The original issue tracks
SELECT expr INTO @varbeing rejected. The same parser gap appears inside a stored procedure when assigning to an OUT parameter:MySQL equivalent returns:
MO:
Ariznawlll commentedon Aug 20, 2026
测试版本
maind7899e703dfaef428f272c2fc0452813c0b8636c原问题验证
在同一会话执行原始 SQL:
连续 3 轮结果均为:已赋值变量返回
7,未赋值变量返回NULL,SELECT ... INTO @var写入并返回5,后续查询返回1。Happy Path 覆盖
SELECT ABS(-5) INTO @out_25123成功执行,变量值为5。SELECT INTO后仍可继续执行查询。Unhappy Path 覆盖
NULL。白盒验证
不适用:该 issue 的验收目标是客户端可见 SQL 语义,已用黑盒协议验证。
回归测试
已加入 MOTR:
14_issue_regression.issue_25123_user_variables,执行--repeat 3,3/3 通过。测试证据
MOTR 输出:
total=3 success=3 failed=0;每轮stmts=10 ok=10 fail=0。测试结论
测试通过。