pingcap / pingcap/tidb

LPAD / RPAD with an empty pad string discards the input

Open Beginner friendly
#70,819 2 comments 0 reactions 0 assignees View on GitHub
contribution may-affects-25.10 may-affects-26.3 may-affects-7.5 may-affects-8.1 may-affects-8.5 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)

```
SELECT LPAD('hi', 3, '');
-- TiDB: '' (input lost)
-- MySQL 9.7.2: 'hi' (no padding needed → original returned)
-- MariaDB: NULL
```
### 2. What did you expect to see? (Required)

```
mysql>
mysql> select version();
+-----------+
| version() |
+-----------+
| 9.7.2 |
+-----------+
1 row in set (0.00 sec)

mysql> SELECT LPAD('hi', 3, '');
+-------------------+
| LPAD('hi', 3, '') |
+-------------------+
| hi |
+-------------------+
1 row in set (0.00 sec)
```
### 3. What did you see instead (Required)

```
mysql> SELECT LPAD('hi', 3, '');
+-------------------+
| LPAD('hi', 3, '') |
+-------------------+
| |
+-------------------+
1 row in set (0.00 sec)

mysql> -- TiDB: '' (input lost)
mysql> -- MySQL 9.7.2: 'hi' (no padding needed → original returned)
mysql> -- MariaDB: NULL
```
### 4. What is your TiDB version? (Required)

```
mysql> select tidb_version();
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v9.0.0-beta.2.pre-2174-g65ac2fad58-dirty
Edition: Community
Git Commit Hash: 65ac2fad582510b92d3c4b79999e48217c989737
Git Branch: master
UTC Build Time: 2026-08-30 15:18:00
GoVersion: go1.25.12
Race Enabled: false
Check Table Before Drop: false
Store: unistore
Kernel Type: Classic |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

Contributor guide

Open the contributing guide

Research direction

Start by locating the LPAD and RPAD SQL function implementations and their existing tests, then reproduce SELECT LPAD('hi', 3, ''). Verify the focused SQL tests cover an empty pad string and that the original input is preserved when no padding is needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.