Bug #116340 Importing a partition tablespace skip the data validation
Submitted: 11 Oct 2024 0:39 Modified: 14 Oct 2024 8:08
Reporter: Jinyou Ma Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Partitions Severity:S3 (Non-critical)
Version:8.0, 9.0, 8.0.39 OS:Any
Assigned to: CPU Architecture:Any

[11 Oct 2024 0:39] Jinyou Ma
Description:
When I import the wrong partition tablespace, MySQL does not validate the data, leading to incorrect results.
Assuming a partition table includes two partitions p0 and p1, MySQL allows me to replace the p0 with p1.

CREATE TABLE `t1` (
  `id` int NOT NULL,
  `d` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB
/*!50100 PARTITION BY HASH (`id`)
PARTITIONS 2 */;

Although the id is unique, I can get duplicated records.
mysql> select * from t1;
+----+------+
| id | d    |
+----+------+
|  1 |    1 |
|  1 |    1 |
+----+------+
2 rows in set (0.01 sec)

How to repeat:
create database test;
use test
CREATE TABLE `t1` (
  `id` int NOT NULL,
  `d` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB
/*!50100 PARTITION BY HASH (`id`)
PARTITIONS 2 */;

insert into t1 values (1,1), (2,2);
flush tables t1 for export;

system cp -av  /var/lib/mysql/test/t1#p#p1.* /tmp/
unlock tables;
alter table t1 discard partition p0 tablespace;
system cp -av /tmp/t1#p#p1.cfg /var/lib/mysql/test/t1#p#p0.cfg
system cp -av /tmp/t1#p#p1.ibd /var/lib/mysql/test/t1#p#p0.ibd
alter table t1 import partition p0 tablespace;
select * from t1;
[14 Oct 2024 8:08] MySQL Verification Team
Hello Jinyou Ma,

Thank you for the report and test case.
verified as described.

regards,
Umesh