partition value strings in TiDB is not formatted the same as in 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!
If a newline character is in the partition definition value, it is printed as a newline, instead of `\n`.
Preferably the values should be normalised to the columns data type and quoted where possible to print, otherwise presented as a hex string.
### 1. Minimal reproduce step (Required)
```sql
create table t (a varchar(255)) partition by range columns (a) (partition p values less than ('\\''\t\n'));
show create table t;
```
### 2. What did you expect to see? (Required)
```sql
mysql> create table t (a varchar(255)) partition by range columns (a) (partition p values less than ('\\''\t\n'));
Query OK, 0 rows affected (0,02 sec)
mysql> show create table t;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
/*!50500 PARTITION BY RANGE COLUMNS(a)
(PARTITION p VALUES LESS THAN ('\\'' \n') ENGINE = InnoDB) */ |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0,00 sec)
```
### 3. What did you see instead (Required)
```sql
tidb> create table t (a varchar(255)) partition by range columns (a) (partition p values less than ('\\''\t\n'));
Query OK, 0 rows affected (0,02 sec)
tidb> show create table t;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`a` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE COLUMNS(`a`)
(PARTITION `p` VALUES LESS THAN ('\\''
')) |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0,01 sec)
```
### 4. What is your TiDB version? (Required)
```
Release Version: v6.3.0-alpha-149-g6b8cf9d5b2
Edition: Community
Git Commit Hash: 6b8cf9d5b29b160ecb20513895fab05bffb6ae3b
Git Branch: master
UTC Build Time: 2022-09-07 15:38:45
GoVersion: go1.19
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore
```
Contributor guide
Assessment
This issue has not been assessed yet.