result of LENGTH(CAST(1e100 AS CHAR)) is incosistent with mysql
- 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 LENGTH(CAST(1e100 AS CHAR));
```
### 2. What did you expect to see? (Required)
```
MySQL [(none)]> SELECT LENGTH(CAST(1e100 AS CHAR));
+-----------------------------+
| LENGTH(CAST(1e100 AS CHAR)) |
+-----------------------------+
| 5 |
+-----------------------------+
1 row in set (0.00 sec)
```
### 3. What did you see instead (Required)
```
MySQL [testdb_1747239281507]> SELECT LENGTH(CAST(1e100 AS CHAR));
+-----------------------------+
| LENGTH(CAST(1e100 AS CHAR)) |
+-----------------------------+
| 101 |
+-----------------------------+
1 row in set (0.01 sec)
```
### 4. What is your TiDB version? (Required)
```
MySQL [testdb_1747239281507]> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.1
Edition: Community
Git Commit Hash: fea86c8e35ad4a86a5e1160701f99493c2ee547c
Git Branch: HEAD
UTC Build Time: 2025-01-16 07:38:34
GoVersion: go1.23.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```
Contributor guide
Research direction
Start by running SELECT LENGTH(CAST(1e100 AS CHAR)); on TiDB and MySQL, then trace the CAST and LENGTH handling in the Go codebase. Done means TiDB returns the MySQL-compatible result of 5 and includes regression coverage for this query.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, mysql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100