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]: information_schema.VIEWS reports aggregate views as updatable and returns CREATE VIEW as the definition #27655
information_schema.VIEWS hard-codes every view as IS_UPDATABLE='YES', including aggregate views that MatrixOne rejects for DML. VIEW_DEFINITION also contains the complete CREATE VIEW ... statement rather than the view's SELECT definition.
The behavior was reproduced 3/3 with fresh databases and was identical on both CNs:
IS_UPDATABLE=YES
VIEW_DEFINITION=create view agg_v as select a,count(*) cnt from t group by a
UPDATE agg_v ... -> ERROR 20301: cannot insert/update/delete from view
Expected Behavior
A grouped/aggregate view is reported as IS_UPDATABLE='NO'.
VIEW_DEFINITION contains the SELECT statement defining the view, matching the documented MySQL information-schema contract.
Metadata and actual DML capability do not contradict each other.
Steps to Reproduce
DROPDATABASE IF EXISTS metadata_view_repro;
CREATEDATABASEmetadata_view_repro;
USE metadata_view_repro;
CREATETABLEt(a INT);
CREATEVIEWagg_vASSELECT a,COUNT(*) cnt FROM t GROUP BY a;
SELECT TABLE_NAME,VIEW_DEFINITION,IS_UPDATABLE
FROMinformation_schema.VIEWSWHERE TABLE_SCHEMA='metadata_view_repro';
UPDATE agg_v SET cnt=1;
Additional information
The current InformationSchemaViewsDDL in pkg/util/sysview/predefined.go returns tbl.rel_createsql and the literal 'YES'. This can mislead ORM and migration tools that use information_schema.VIEWS to decide whether a view is writable or to compare definitions.
Activity
Ariznawlll commentedon Oct 21, 2026
测试版本
main7038c8520e5fc1ba456914b3c389ccedb69e22f7(执行时官方 main,包含修复 PR fix: correct information schema views metadata #27716;发布前 main 后续仅新增与本问题无关的 Top 算子提交)原问题验证
按 issue 原始步骤创建
t(a,b),插入(1,10),(1,20),(2,30),创建agg_v AS SELECT a,COUNT(*) cnt FROM t GROUP BY a,并查询information_schema.VIEWS。两个 CN 各独立执行 3 轮,共 6/6:agg_v.IS_UPDATABLE=NO,VIEW_DEFINITION以select开头、含COUNT(*)和GROUP BY,不再返回完整CREATE VIEW;实际聚合结果均为a=1,cnt=2、a=2,cnt=1。元数据字段均非 NULL。Happy Path 覆盖
direct_v AS SELECT a,b FROM t:其VIEW_DEFINITION同样为 SELECT 定义,而非 CREATE 语句;当前产品不支持对 view 写入,因此IS_UPDATABLE=NO与实际能力一致。两个 CN 各 3/3。UPDATE t SET b=11 WHERE a=1 AND b=10,最终行集精确为(1,11),(1,20),(2,30),两个 CN 各 3/3;每轮删除独立数据库,6/6 清理完成。Unhappy Path 覆盖
UPDATE agg_v SET cnt=1:两个 CN 各 3/3 被拒绝,拒绝后的基础表仍精确为(1,10),(1,20),(2,30),没有部分写入。另对普通 view 的 UPDATE 做了单次对照,返回ERROR 20301: cannot insert/update/delete from view,因此没有把普通 view 错判为可更新。白盒验证
独立运行
pkg/util/sysview的TestInformationSchemaViewsMetadata -count=3通过;pkg/sql/plan/function的TestViewDefinitionFunctionRegistration、TestViewDefinitionFromPersistedData、TestBuiltInViewDefinition、TestBuiltInViewCheckOption均以-count=3通过。此 issue 的原始缺陷可通过公开 SQL 完整触发,未另做故障注入或 race;初版 QA 脚本对COUNT字母大小写的假设导致一次测试脚本失败,已改用大小写无关的断言,该次不计入产品结果。回归测试
修复 PR #27716 已合入 main,包含公开 SQL/BVT 成对用例
information_schema_views_metadata.sql/.result,覆盖聚合/普通 view 元数据、DML 拒绝和更多定义解析边界。PR 的 Linux 多 CN BVT 与 CI Required 为 SUCCESS;我本地未另跑完整 BVT suite,也未向 MOTR 重复添加同一公开 SQL 用例。测试证据
160013/3、160023/3;每轮元数据NO/SELECT、聚合结果1:2,2:1、拒绝后行集不变、基础表更新和清理均通过。隔离服务已正常停止,两个端口释放。information_schema_views_metadata.sql,job SUCCESS;CI Required SUCCESS。测试结论
测试通过。
fix(bootstrap): remove view scan and enforce complete tenant initiali…