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]: Qualified sequence-backed view resolves NEXTVAL in the session database #27581
- Topology: local 1 CN / 1 TN / 1 Log
- Protocol: MySQL
Actual Behavior
When the caller's current database differs from the database that owns a sequence-backed view, an unqualified sequence name inside NEXTVAL resolves against the caller session database.
The source database and sequence both exist; the failure occurs only while evaluating the database-qualified view.
Expected Behavior
SELECT * FROM issue27049q.seq_view should resolve NEXTVAL('seq1') to issue27049q.seq1 and return 10, regardless of the caller session's current database.
Steps to Reproduce
1. Execute:
~~~sqlCREATEDATABASEissue27049q;
USE issue27049q;
CREATESEQUENCEseq1 START WITH 10;
CREATEVIEWseq_viewASSELECT NEXTVAL('seq1') AS n;
USE mysql;
SELECT*FROMissue27049q.seq_view;
~~~2. Observe ERROR 1146 referring to mysql.seq1.
Additional information
Validation:
Exact reproducer: 3/3 failed on latest official main.
Passing control: 3/3 a database-qualified ordinary base-table view remained readable after USE mysql.
This is a derived name-resolution defect, distinct from #27049 clone preservation. The clone repair is ae01f96. No matching open or closed issue was found during duplicate search.
[Hypothesis] View expression evaluation binds an unqualified NEXTVAL name to the session current database instead of the view owner database.
Regression after fixing: add BVT coverage for selecting a sequence-backed qualified view from a different default database, with the ordinary qualified-view control.
Activity
fix(plan): resolve view sequences in stored database (#28116)
jiangxinmeng1 commentedon Sep 9, 2026
fixed by #28116
Ariznawlll commentedon Sep 9, 2026
测试版本
maincd04bb4c1af5bc595e2147dc645dfa754f4c395b原问题验证
创建 owner/caller 两个数据库,并在两边创建同名
seq1。owner 库 VIEW 使用未限定的NEXTVAL、CURRVAL、SETVAL;从 caller 库访问时,3/3 均解析到 owner 库 sequence:SETVAL=50、NEXTVAL=50、CURRVAL=50、SETVAL(..., false)=70、后续NEXTVAL=71。caller 的 sequence 保持独立序列100/101/102。Happy Path 覆盖
NEXTVAL、CURRVAL、两种SETVAL均返回预期值。11。Unhappy Path 覆盖
missing_seq返回ERROR 1146;错误后 caller sequence 仍返回102,普通表 VIEW 仍返回11,会话未受污染。白盒验证
不适用:本 issue 为 SQL 绑定/解析行为,已使用修复前父提交
74668fc075c965c462b30f10ae24a1c19c289cfd运行新用例验证 red 状态;旧版本错误使用 caller 的同名 sequence(51/72/73),当前 main 已修复。回归测试
suites/14_issue_regression/t/issue_27581_cross_database_view_sequence.test14_issue_regression套件中该用例通过。测试证据
ad5d9b10c3401e613628755018b0d343893a7eaa测试结论
测试通过。
fix(plan): resolve view sequences in stored database (matrixorigin#28116
fix(plan): resolve view sequences in stored database (matrixorigin#28116
fix(plan): resolve view sequences in stored database (matrixorigin#28116