pingcap / pingcap/tidb

Bare WITH CHECK OPTION rejected by the parser

Open
#70,820 2 comments 0 reactions 0 assignees View on GitHub
contribution severity/moderate sig/sql-infra type/bug
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)

```
create table vbase(v int);
CREATE VIEW vv AS SELECT * FROM vbase WHERE v > 15 WITH CHECK OPTION;
-- TiDB: ERROR 1064 near "CHECK OPTION"
-- MySQL 9.7.2: 接受(等价 WITH CASCADED CHECK OPTION)
-- MariaDB 13.1: 接受

-- TiDB 自己的显式形式却可用:
drop view vv;
CREATE VIEW vv AS SELECT * FROM vbase WHERE v > 15 WITH CASCADED CHECK OPTION; -- OK
drop view vv;
CREATE VIEW vv AS SELECT * FROM vbase WHERE v > 15 WITH LOCAL CHECK OPTION;
```

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

```
mysql> create table vbase(v int);
ERROR 1050 (42S01): Table 'vbase' already exists
mysql> CREATE VIEW vv AS SELECT * FROM vbase WHERE v > 15 WITH CHECK OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> -- TiDB 自己的显式形式却可用:
mysql> drop view vv;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE VIEW vv AS SELECT * FROM vbase WHERE v > 15 WITH CASCADED CHECK OPTION; -- OK
Query OK, 0 rows affected (0.00 sec)

mysql> drop view vv;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE VIEW vv AS SELECT * FROM vbase WHERE v > 15 WITH LOCAL CHECK OPTION;
Query OK, 0 rows affected (0.02 sec)

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

```
mysql> CREATE VIEW vv AS SELECT * FROM vbase WHERE v > 15 WITH CHECK OPTION;
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 1 column 61 near "CHECK OPTION"
```
### 4. What is your TiDB version? (Required)
```
mysql> select tidb_version();
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v9.0.0-beta.2.pre-2174-g65ac2fad58-dirty
Edition: Community
Git Commit Hash: 65ac2fad582510b92d3c4b79999e48217c989737
Git Branch: master
UTC Build Time: 2026-08-30 15:18:00
GoVersion: go1.25.12
Race Enabled: false
Check Table Before Drop: false
Store: unistore
Kernel Type: Classic |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported CREATE VIEW statements and compare the bare WITH CHECK OPTION with the accepted LOCAL and CASCADED forms. Trace the parser path that handles CREATE VIEW syntax, then add coverage showing that the bare form is accepted as equivalent to WITH CASCADED CHECK OPTION and confirm the regression test passes.

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
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.