pingcap / pingcap/tidb

SELECT '2023-03-21 12:00:00' + INTERVAL (1+2)*3 DAY reports "Incorrect parameter count" error

Open
#42,416 2 comments 0 reactions 1 assignee Claimed by @Defined2014 View on GitHub
component/parser 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)

```sql
SELECT '2023-03-21 12:00:00' + INTERVAL (1+2)*3 DAY;
```

### 2. What did you expect to see? (Required)
```
mysql> SELECT '2023-03-21 12:00:00' + INTERVAL (1+2)*3 DAY;
+----------------------------------------------+
| '2023-03-21 12:00:00' + INTERVAL (1+2)*3 DAY |
+----------------------------------------------+
| 2023-03-30 12:00:00 |
+----------------------------------------------+
1 row in set (0.00 sec)
```

### 3. What did you see instead (Required)
```
mysql> SELECT '2023-03-21 12:00:00' + INTERVAL (1+2)*3 DAY;
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'interval'
```
This query is ok on MySQL 5.7.

```
mysql> SELECT version();
+------------+
| version() |
+------------+
| 5.7.41-log |
+------------+
1 row in set (0.00 sec)

mysql> SELECT '2023-03-21 12:00:00' + INTERVAL (1+2)*3 DAY;
+----------------------------------------------+
| '2023-03-21 12:00:00' + INTERVAL (1+2)*3 DAY |
+----------------------------------------------+
| 2023-03-30 12:00:00 |
+----------------------------------------------+
1 row in set (0.00 sec)
```

### 4. What is your TiDB version? (Required)

```
+--------------------+
| version() |
+--------------------+
| 5.7.25-TiDB-v6.6.0 |
+--------------------+
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.