`Display width out of range` not compatible 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)
```mysql
SELECT CAST( 'a' AS BINARY(4294967296));
```
### 2. What did you expect to see? (Required)
```mysql
mysql> SELECT CAST( 'a' AS BINARY(4294967296));
ERROR 1439 (42000): Display width out of range for column 'cast as char' (max = 4294967295)
```
### 3. What did you see instead (Required)
```mysql
mysql> SELECT CAST( 'a' AS BINARY(4294967296));
+--------------------------------------------------------------------+
| CAST( 'a' AS BINARY(4294967296)) |
+--------------------------------------------------------------------+
| NULL |
+--------------------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+--------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------------------------------------------------------------+
| Warning | 1301 | Result of cast_as_binary() was larger than max_allowed_packet (67108864) - truncated |
+---------+------+--------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```
### 4. What is your TiDB version? (Required)
```
mysql> SELECT tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.0-alpha-343-g59dff48ea2
Edition: Community
Git Commit Hash: 59dff48ea2ea17f823f47ece9ef3a15209645bb4
Git Branch: master
UTC Build Time: 2024-12-16 03:41:31
GoVersion: go1.23.4
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```
Found by https://github.com/PingCAP-QE/tidb-test/blob/56e6b0d6b451a7c53978f81746cc0bdd254a4bc1/mysql_test/t/cast.test#L361
Contributor guide
Assessment
This issue has not been assessed yet.