mview: compatible widening on 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 referenced by a materialized view log and a `REFRESH FAST` materialized view.
2. Run an initial FAST refresh and verify the materialized view matches the base-table aggregate.
3. Try compatible widening DDL on referenced columns, for example:
```sql
ALTER TABLE t_base MODIFY COLUMN v1 BIGINT NOT NULL;
ALTER TABLE t_base MODIFY COLUMN c_fixed VARCHAR(16) NOT NULL;
ALTER TABLE t_base MODIFY COLUMN d DATETIME NOT NULL;
```
4. Insert boundary rows that require the widened definitions.
5. Run `REFRESH MATERIALIZED VIEW ... FAST` again and compare the materialized view with the base-table aggregate.
### 2. What did you expect to see? (Required)
No-reorg compatible widening on referenced columns should be accepted when the change keeps refresh semantics valid, and later FAST refresh should remain correct.
### 3. What did you see instead (Required)
Compatible widening was rejected by the materialized-view dependency guard:
```text
Error 8200 (HY000): Unsupported MODIFY COLUMN on base table with materialized view dependencies does not support modifying columns used in non-direct SELECT expressions
Error 8200 (HY000): Unsupported MODIFY COLUMN on base table with materialized view dependencies only supports no-reorg compatible type changes
```
Observed rejected examples include numeric widening, `CHAR` to `VARCHAR`, and `DATE` to `DATETIME`.
The code path checked on `feature/release-8.5-materialized-view-2603` suggests the materialized-view dependency check is stricter than the ordinary compatible column-modification path:
```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 pkg/ddl/executor.go:checkTableMaterializedViewConstraintsWithOptions and compare its dependency checks with pkg/ddl/modify_column.go:getModifyColumnType. Reproduce the SQL widening cases against a materialized view log and REFRESH FAST workflow, then verify that compatible referenced-column changes are accepted and the subsequent FAST refresh matches the base-table aggregate.
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
- Mostly clear
- Newbie friendliness
- 48/100