pingcap / pingcap/tidb

mview: ALTER MATERIALIZED VIEW REFRESH START WITH rejects valid time expressions

Open
#69,346 0 comments 0 reactions 0 assignees View on GitHub
component/mview feature/developing severity/moderate type/bug
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 and a materialized view log.
2. Create a `REFRESH FAST` materialized view with a valid `NEXT` schedule.
3. Try to alter only the `START WITH` value:

```sql
ALTER MATERIALIZED VIEW mv_refresh_013_next_int
REFRESH START WITH DATE_ADD(NOW(), INTERVAL 20 SECOND);
```

4. Also try a past start expression:

```sql
ALTER MATERIALIZED VIEW mv_refresh_013_next_int
REFRESH START WITH NOW(0) - INTERVAL 1 SECOND;
```

### 2. What did you expect to see? (Required)

`ALTER MATERIALIZED VIEW ... REFRESH START WITH

The parser tests on `feature/release-8.5-materialized-view-2603` include `ALTER MATERIALIZED VIEW mv REFRESH START WITH now()` as an accepted statement:

```text
pkg/parser/parser_test.go
```

### 3. What did you see instead (Required)

Both `ALTER` statements failed with syntax errors:

```text
Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 2 column 57 near ""
Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 2 column 48 near ""
```

The schedule definition stayed unchanged after the failed `ALTER`.

### 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

Open the contributing guide

Research direction

Start with the parser coverage in pkg/parser/parser_test.go and reproduce the two ALTER MATERIALIZED VIEW statements using DATE_ADD(NOW(), INTERVAL 20 SECOND) and NOW(0) - INTERVAL 1 SECOND. Trace why START WITH accepts the expression in CREATE but rejects it in ALTER, then add regression coverage showing both forms parse and update the refresh schedule consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.