INTERVAL() with unordered arguments diverges from both MySQL and MariaDB
- 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)
```
SELECT INTERVAL(10, 30, 1, 17); -- TiDB: 2 | MySQL 9.7.2: 0 | MariaDB 13.1: 0
```
### 2. What did you expect to see? (Required)
```
mysql> SELECT INTERVAL(10, 30, 1, 17); -- TiDB: 2 | MySQL 9.7.2: 0 | MariaDB 13.1: 0
+-------------------------+
| INTERVAL(10, 30, 1, 17) |
+-------------------------+
| 0 |
+-------------------------+
1 row in set (0.00 sec)
mysql> select version()
-> ;
+-----------+
| version() |
+-----------+
| 9.7.2 |
+-----------+
1 row in set (0.00 sec)
```
### 3. What did you see instead (Required)
```
mysql> SELECT INTERVAL(10, 30, 1, 17); -- TiDB: 2 | MySQL 9.7.2: 0 | MariaDB 13.1: 0
+-------------------------+
| INTERVAL(10, 30, 1, 17) |
+-------------------------+
| 2 |
+-------------------------+
1 row in set (0.00 sec)
```
### 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
Research direction
Start by running SELECT INTERVAL(10, 30, 1, 17) on TiDB and compare its result with the MySQL and MariaDB results shown in the report. Trace the INTERVAL() implementation and its existing tests, then confirm the function follows the expected compatibility behavior for unordered arguments.
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
- 64/100