pingcap / pingcap/tidb

RPAD() with utf8 returns different values with MySQL

Open
#32,600 1 comment 0 reactions 0 assignees View on GitHub
affects-5.0 affects-5.1 affects-5.2 affects-5.3 affects-5.4 affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 affects-8.1 may-affects-4.0 severity/major sig/execution type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

### 1. Minimal reproduce step
```sql
SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'яэюя'));
SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'йцуя'));
```
### 2. What did you expect to see?
```sql
mysql> SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'яэюя'));
+-------------------------------------------------+
| LENGTH(RPAD(0.0115E88, 61297, _utf8'яэюя')) |
+-------------------------------------------------+
| 122587 |
+-------------------------------------------------+
1 row in set, 1 warning (0.01 sec)

mysql> SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'йцуя'));
+-------------------------------------------------+
| LENGTH(RPAD(0.0115E88, 61297, _utf8'йцуя')) |
+-------------------------------------------------+
| 122587 |
+-------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
```
### 3. What did you see instead
```sql
tidb> SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'яэюя'));
+-------------------------------------------------+
| LENGTH(RPAD(0.0115E88, 61297, _utf8'яэюя')) |
+-------------------------------------------------+
| 122507 |
+-------------------------------------------------+
1 row in set (0.01 sec)

tidb> SELECT LENGTH(RPAD(0.0115E88, 61297, _utf8'йцуя'));
+-------------------------------------------------+
| LENGTH(RPAD(0.0115E88, 61297, _utf8'йцуя')) |
+-------------------------------------------------+
| 122507 |
+-------------------------------------------------+
1 row in set (0.01 sec)
```
### 4. What is your TiDB version?
```
tidb_version(): Release Version: v5.5.0-alpha-210-g11f4ca802
Edition: Community
Git Commit Hash: 11f4ca802083ee38d5972730ba8f9b72395316fb
Git Branch: master
UTC Build Time: 2022-02-24 04:52:01
GoVersion: go1.17.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```

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.