Bug #100830 data differs with source table after importing tablespace
Submitted: 14 Sep 2020 2:04 Modified: 14 Sep 2020 14:54
Reporter: Brian Yue (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:MySQL8.0.18 OS:Any (rhel-7.4)
Assigned to: CPU Architecture:Any (intel x86)
Tags: data changes, import

[14 Sep 2020 2:04] Brian Yue
Description:
Hello, dear verification team:
  For tablespace export and import, if decimal field of source table and dest table have same precision but different scale, import operation works successfully but data of dest table differs with source table.
  Please check `How to repeat` part for detail.

How to repeat:
(1) create table `d1` and `d4` (column b have same precision but different scale)
mysql> create table d1 (id int, b decimal(20,5));
Query OK, 0 rows affected (0.56 sec)

mysql> insert into d1 values (1, 1.003343);
Query OK, 1 row affected, 1 warning (0.22 sec)

mysql> create table d4 (id int, b decimal(20,8));
Query OK, 0 rows affected (0.09 sec)

(2) export, copy and import tablespace from `d1` to `d4`
mysql> alter table d4 discard tablespace;
Query OK, 0 rows affected (0.03 sec)

mysql> flush table d1 for export;
Query OK, 0 rows affected (0.00 sec)

[yxx_git@zxin21 yxx]$ cp d1.cfg d4.cfg
[yxx_git@zxin21 yxx]$ cp d1.ibd d4.ibd

mysql> unlock tables;
Query OK, 0 rows affected (0.00 sec)

mysql> alter table d4 import tablespace;
Query OK, 0 rows affected (0.15 sec)

(3) check data, we found that data in table `d4` differs with data in table `d1`
mysql> select * from d4;
+------+------------+
| id   | b          |
+------+------------+
|    1 | 0.16777550 |
+------+------------+
1 row in set (0.00 sec)

mysql> select * from d1;
+------+---------+
| id   | b       |
+------+---------+
|    1 | 1.00334 |
+------+---------+
1 row in set (0.00 sec)

Suggested fix:
I suppose that import tablespace command should fail if decimal scale of dest table differs with source table
[14 Sep 2020 14:54] MySQL Verification Team
Hi,

This is a rather interesting bug, thanks for the report. Verified as described.

kind regards
Bogdan