matrixorigin / matrixorigin/matrixone

[Bug]: information_schema.VIEWS reports aggregate views as updatable and returns CREATE VIEW as the definition

Open
#27,655 0 comments 0 reactions 1 assignee Claimed by @iamlinjunhong View on GitHub
kind/bug needs-triage
Dominant language
Go
Stars
1.9k
Forks
311
Avg merge
1d 3h
Merged PRs (30d)
768

Description

### Is there an existing issue for the same bug?

- [x] I have checked the existing issues.

### Branch Name

main

### Commit ID

a53f5a3b757c5b21a36e539e4471533fe1d091a8

### Other Environment Information

- Deployment: local multi-CN (`launch-multi-cn`)
- Server: `8.0.30-MatrixOne-v20260826`

### Actual Behavior

`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:

```text
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

```sql
DROP DATABASE IF EXISTS metadata_view_repro;
CREATE DATABASE metadata_view_repro;
USE metadata_view_repro;

CREATE TABLE t(a INT);
CREATE VIEW agg_v AS SELECT a,COUNT(*) cnt FROM t GROUP BY a;

SELECT TABLE_NAME,VIEW_DEFINITION,IS_UPDATABLE
FROM information_schema.VIEWS
WHERE 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.