Skip to content

Converting a partitioned table from a normal table results in duplicate data for the primary key #55721

@harry1129

Description

@harry1129

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t1(id bigint,id_1 bigint,name varchar(10),primary key (id) NONCLUSTERED);
Query OK, 0 rows affected (0.08 sec)

mysql> insert into t1 values(1,1,'AA'),(2,2,'BB'),(3,3,'CC'),(4,4,'DD');
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> alter table t1 partition by hash(id_1) partitions 4;
Query OK, 0 rows affected, 1 warning (1.58 sec)

mysql> insert into t1 values(2,1,'AA');
Query OK, 1 row affected (0.00 sec)

mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v7.5.3
Edition: Community
Git Commit Hash: 70bfd90035cc81e80d78b4f1f76ca4baef8a5756
Git Branch: HEAD
UTC Build Time: 2024-07-31 13:17:12
GoVersion: go1.21.10
Race Enabled: false
Check Table Before Drop: false
Store: tikv
1 row in set (0.00 sec)

2. What did you expect to see? (Required)

mysql> alter table t1 partition by hash(id_1) partitions 4;
ERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function

3. What did you see instead (Required)

mysql> alter table t1 partition by hash(id_1) partitions 4;
Query OK, 0 rows affected, 1 warning (1.58 sec)

4. What is your TiDB version? (Required)

mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v7.5.3
Edition: Community
Git Commit Hash: 70bfd90035cc81e80d78b4f1f76ca4baef8a5756
Git Branch: HEAD
UTC Build Time: 2024-07-31 13:17:12
GoVersion: go1.21.10
Race Enabled: false
Check Table Before Drop: false
Store: tikv
1 row in set (0.00 sec)

PS: v8.3.0 does not reproduce this issue

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions