a compatibility difference for CONVERT 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)
Use utf8 encoding
If you take a multibyte character string and then hex it then the left might cut a character right in the middle which leads to this.
CONVERT fails to handle the presence of a half-yard。
```
set sql_mode='';
select char_length(CONVERT(unhex(left(hex('q3451234523453-asdfasdfasf号啥段位佛那色哦符号函数大佛啊和盛大发撒'),122)) using utf8mb4));
```
### 2. What did you expect to see? (Required)
```
char_length(CONVERT(unhex(left(hex('q3451234523453-asdfasdfasf号啥段位佛那色哦符号函数大佛啊和盛大发撒'),122)) using utf8mb4))
37
```
### 3. What did you see instead (Required)
```
MySQL [test]> select char_length(CONVERT(unhex(left(hex('q3451234523453-asdfasdfasf号啥段位佛那色哦符号函数大佛啊和盛大发撒'),122)) using utf8mb4));
+----------------------------------------------------------------------------------------------------------------------------------------------------+
| char_length(CONVERT(unhex(left(hex('q3451234523453-asdfasdfasf号啥段位佛那色哦符号函数大佛啊和盛大发撒'),122)) using utf8mb4)) |
+----------------------------------------------------------------------------------------------------------------------------------------------------+
| NULL |
+----------------------------------------------------------------------------------------------------------------------------------------------------+
```
### 4. What is your TiDB version? (Required)
Release Version: v6.5.0
Edition: Community
Git Commit Hash: 706c3fa3c526cdba5b3e9f066b1a568fb96c56e3
Git Branch: heads/refs/tags/v6.5.0
UTC Build Time: 2022-12-27 03:50:44
GoVersion: go1.19.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
Contributor guide
Assessment
This issue has not been assessed yet.