CREATE TABLE with TTL does not check the TTL 'expression' for composite time units
- 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)
```mysql
create table t (a int, b timestamp) ttl = b + interval "one + two" minute_second;
```
So I think both the issue needs to be fixed, i.e. check TTL 'expression' when create/alter table,
and changing the manual, from 'Expression' to 'Time string' or similar.
### 2. What did you expect to see? (Required)
Failure, saying that "one + two" is not a minute_second expression.
The [parser](https://github.com/pingcap/tidb/blob/f46ccb3ec15689b426e230f28dfda5f3e25644d5/pkg/parser/parser.y#L12407) says it only accepts a literal,
while the [documentation](https://docs.pingcap.com/tidb/stable/sql-statement-create-table) says Expression: TTL EqOpt TimeColumnName + INTERVAL Expression TimeUnit
### 3. What did you see instead (Required)
Table created without even a warning:
```mysql
tidb> create table t (a int, b timestamp) ttl = b + interval "one + two" minute_second;
Query OK, 0 rows affected (0.08 sec)
```
### 4. What is your TiDB version? (Required)
```
tidb_version(): Release Version: v7.6.0
Edition: Community
Git Commit Hash: 52794d985ba6325d75a714d4eaa0838d59425eb6
Git Branch: heads/refs/tags/v7.6.0
UTC Build Time: 2024-01-22 14:13:53
GoVersion: go1.21.5
Race Enabled: false
Check Table Before Drop: false
Store: tikv
```
Contributor guide
Assessment
This issue has not been assessed yet.