pingcap / pingcap/tidb

a compatibility difference for CONVERT with MySQL

Open
#41,230 1 comment 0 reactions 0 assignees View on GitHub
affects-6.5 affects-7.0 affects-7.1 affects-7.5 affects-8.1 may-affects-4.0 may-affects-5.0 may-affects-5.1 may-affects-5.2 may-affects-5.3 may-affects-5.4 may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 may-affects-6.4 may-affects-6.6 severity/major sig/execution type/bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.