ROUND(int_col, -1) rounds half-to-even; MySQL rounds half-away-from-zero for exact types
- 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 rt(v INT); INSERT INTO rt VALUES (25),(45);
SELECT ROUND(v, -1) FROM rt; -- TiDB: 20, 40 | MySQL: 30, 50
SELECT ROUND(25.0, -1); -- TiDB: 30 (decimal path — half-away, matches MySQL)
SELECT ROUND(25, -1); -- TiDB: 20 (int path — half-even)
```
### 2. What did you expect to see? (Required)
```
mysql> SELECT ROUND(25.0, -1); -- TiDB: 30 (decimal path — half-away, matches MySQL)
+-----------------+
| ROUND(25.0, -1) |
+-----------------+
| 30 |
+-----------------+
1 row in set (0.00 sec)
mysql> SELECT ROUND(25, -1); -- TiDB: 20 (int path — half-even)
+---------------+
| ROUND(25, -1) |
+---------------+
| 30 |
+---------------+
1 row in set (0.00 sec)
mysql>
mysql>
mysql> select version();
+-----------+
| version() |
+-----------+
| 9.7.2 |
+-----------+
1 row in set (0.00 sec)
```
### 3. What did you see instead (Required)
```
mysql> SELECT ROUND(25.0, -1); -- TiDB: 30 (decimal path — half-away, matches MySQL)
+-----------------+
| ROUND(25.0, -1) |
+-----------------+
| 30 |
+-----------------+
1 row in set (0.00 sec)
mysql> SELECT ROUND(25, -1); -- TiDB: 20 (int path — half-even)
+---------------+
| ROUND(25, -1) |
+---------------+
| 20 |
+---------------+
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
Reproduce the two ROUND(v, -1) cases from the report and trace the integer path, comparing it with the decimal path that already returns half-away-from-zero. Done means integer exact values such as 25 and 45 round to 30 and 50, matching the stated MySQL behavior, with the existing decimal behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, mysql, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100