ALTER MATERIALIZED VIEW REFRESH/COMMENT is accepted but silently ignored, leaving stale MV data
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
```sql
CREATE TABLE t(a INT PRIMARY KEY, b INT NOT NULL);
INSERT INTO t VALUES (1,10),(2,20),(3,30);
CREATE MATERIALIZED VIEW LOG ON t (a,b);
CREATE MATERIALIZED VIEW mv (a, s, c) AS
SELECT a, SUM(b), COUNT(*) FROM t GROUP BY a;
-- Initial MV build is correct: 1,10,1; 2,20,1; 3,30,1.
INSERT INTO t VALUES (4,40);
SELECT a, SUM(b), COUNT(*) FROM t GROUP BY a ORDER BY a;
-- truth includes 4,40,1
ALTER MATERIALIZED VIEW mv REFRESH;
SELECT * FROM mv ORDER BY a;
-- actual: still 1,10,1; 2,20,1; 3,30,1 (row 4 missing)
ALTER MATERIALIZED VIEW mv COMMENT='hello';
SHOW CREATE TABLE mv;
-- actual: no COMMENT='hello'
SHOW WARNINGS; -- empty
```
Probe output:
```text
CONTROL_TRUTH=['1\t10\t1', '2\t20\t1', '3\t30\t1']
CONTROL_MV=['1\t10\t1', '2\t20\t1', '3\t30\t1']
CONTROL_MV_INITIAL_BUILD_OK
TRIGGER_TRUTH=['1\t10\t1', '2\t20\t1', '3\t30\t1', '4\t40\t1']
TRIGGER_MV=['1\t10\t1', '2\t20\t1', '3\t30\t1']
TIDB_ALTER_MVIEW_REFRESH_IGNORED
TIDB_ALTER_MVIEW_COMMENT_IGNORED
```
### 2. What did you expect to see? (Required)
`ALTER MATERIALIZED VIEW ... REFRESH` must rebuild/update the MV so it matches the base-table aggregate, and `COMMENT` must be reflected in MV metadata. If an action is unsupported, the statement must fail explicitly instead of returning success with no effect.
### 3. What did you see instead (Required)
Initial MV matches aggregate. Insert (4,40): direct aggregate includes 4,40,1; MV remains 1,10,1/2,20,1/3,30,1 after ALTER MATERIALIZED VIEW mv REFRESH. ALTER MATERIALIZED VIEW mv COMMENT='hello' returns success but SHOW CREATE TABLE mv has no comment.
### 4. What is your TiDB version? (Required)
```text
Release Version: v8.4.0-this-is-a-placeholder
Edition: Community
Git Commit Hash: None
Git Branch: None
UTC Build Time: None
GoVersion: go1.25.12
Race Enabled: false
Check Table Before Drop: false
Store: unistore
Kernel Type: Classic
```
Built from source commit `a514a92784c9654502686e6ee6efc9e0aeda8afa` (pingcap/tidb master, 2026-09-07).
### 5. Root cause (optional)
- pkg/parser/ast/ddl.go:2109-2155 defines AlterMaterializedViewStmt and actions
- pkg/parser/parser.y parses ALTER MATERIALIZED VIEW REFRESH/ATTRIBUTES/COMMENT
- pkg/executor/ddl.go:161-237 has no case for *ast.AlterMaterializedViewStmt
Contributor guide
Research direction
Start by running the SQL reproduction to confirm the refresh and comment behavior. Read pkg/parser/ast/ddl.go, pkg/parser/parser.y, and pkg/executor/ddl.go, especially the AlterMaterializedViewStmt definitions and executor dispatch. Done means REFRESH updates the MV, COMMENT appears in SHOW CREATE TABLE, and unsupported actions fail explicitly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100