mview: compatible DDL on non-referenced base-table columns is over-rejected with MView dependencies
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
### 1. Minimal reproduce step (Required)
1. Create a base table with columns used by a materialized view and extra columns that are not included in the materialized view log and not referenced by the materialized view definition.
2. Create a materialized view log that only includes the referenced columns.
3. Create a `REFRESH FAST` materialized view over the referenced columns and run an initial FAST refresh.
4. Try compatible DDL on the non-referenced extra columns, for example:
```sql
ALTER TABLE t_base
MODIFY COLUMN extra_v VARCHAR(50) NOT NULL DEFAULT 'b';
ALTER TABLE t_base
CHANGE COLUMN extra_v extra_v2 VARCHAR(50) NOT NULL DEFAULT 'c' AFTER g2;
ALTER TABLE t_base
MODIFY COLUMN extra_d DECIMAL(20,6) NOT NULL DEFAULT 1.234567;
```
5. Run another `REFRESH MATERIALIZED VIEW ... FAST` and compare the materialized view with the base-table aggregate.
### 2. What did you expect to see? (Required)
Compatible DDL on columns that are not part of the materialized view log and are not referenced by the materialized view definition should be allowed, and later FAST refresh should remain correct.
The ordinary TiDB column modification path already has a no-reorg compatible type classifier in:
```text
pkg/ddl/modify_column.go:getModifyColumnType
```
### 3. What did you see instead (Required)
Some compatible DDL on non-referenced extra columns was rejected:
```text
Error 8200 (HY000): Unsupported CHANGE COLUMN on base table with materialized view dependencies does not support renaming
Error 8200 (HY000): Unsupported MODIFY COLUMN on base table with materialized view dependencies only supports no-reorg compatible type changes
```
The materialized-view dependency check appears to reject the operation before the ordinary compatible-DDL path can apply. The relevant code path checked on `feature/release-8.5-materialized-view-2603` is:
```text
pkg/ddl/executor.go:checkTableMaterializedViewConstraintsWithOptions
pkg/ddl/modify_column.go:getModifyColumnType
```
### 4. What is your TiDB version? (Required)
Observed on 2026-06-21 with TiDB test image:
```text
us-docker.pkg.dev/pingcap-testing-account/dev/pingcap/tidb/images/tidb-server:v8.5.4-10609
```
Code path checked against local branch `feature/release-8.5-materialized-view-2603` at commit `3c76cfc0f8342cff08f31b67a3cd3c955f1d90cd`.
Exact `SELECT tidb_version()` output was not preserved before the validation environment was cleaned up.
Contributor guide
Research direction
Start with the reproducer and read pkg/ddl/executor.go:checkTableMaterializedViewConstraintsWithOptions alongside pkg/ddl/modify_column.go:getModifyColumnType. Trace why compatible DDL on unreferenced columns is rejected before the ordinary no-reorg path. Done means the listed ALTER TABLE operations are accepted and a subsequent FAST refresh remains correct.
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
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100