Open wangzhanbing opened 2 years ago
Thanks for your detailed report! I tried to reproduce using MySQL 5.6, 5.7, and 8.0 and I'd like to share the results. It seems that this is only a problem in 5.6.
mysql> CREATE TABLE `test_decimal` (
-> `id` decimal(32,0) NOT NULL DEFAULT '0',
-> PRIMARY KEY (`id`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.05 sec)
mysql> insert into test_decimal values('80700020220314193000');
Query OK, 1 row affected (0.01 sec)
mysql> select count(1) from test_decimal where (((`id` > _binary'80700020220314190000')) and ((`id` < _binary'80700020220405100000') or ((`id` = _binary'80700020220405100000'))));
+----------+
| count(1) |
+----------+
| 0 |
+----------+
1 row in set (0.00 sec)
mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 5.6.51 |
+-----------+
1 row in set (0.00 sec)
mysql> CREATE TABLE `test_decimal` (
-> `id` decimal(32,0) NOT NULL DEFAULT '0',
-> PRIMARY KEY (`id`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.03 sec)
mysql> insert into test_decimal values('80700020220314193000');
Query OK, 1 row affected (0.00 sec)
mysql> select count(1) from test_decimal where (((`id` > _binary'80700020220314190000')) and ((`id` < _binary'80700020220405100000') or ((`id` = _binary'80700020220405100000'))));
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 5.7.23 |
+-----------+
1 row in set (0.00 sec)
mysql> CREATE TABLE `test_decimal` (
-> `id` decimal(32,0) NOT NULL DEFAULT '0',
-> PRIMARY KEY (`id`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> insert into test_decimal values('80700020220314193000');
Query OK, 1 row affected (0.00 sec)
mysql> select count(1) from test_decimal where (((`id` > _binary'80700020220314190000')) and ((`id` < _binary'80700020220405100000') or ((`id` = _binary'80700020220405100000'))));
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.27 |
+-----------+
1 row in set (0.00 sec)
Hello:
We tried to recycle data-free space by
alter table tab engine = innodb
from a table. After gh-ost executed, no error coccurs, but data is lost:gh-ost cmd is:
the create- table info is:
The cause has been located and fixed !
It's because the unique-key contains decimal-type-column, reference: 链接
the query-sql and insert-sql of row-copy sql is like:
one of lost data records is primary-key
InstanceID = _binary'80700020220314193000'
It should be contained in row-copy sql like this, BUT notyou can reproduce this case simplely by:
one of the right solution is adding cast as follows:
we have fixed this bug and try to contribute patch gh-ost community.
Thank you! From wangzhanbing Baidu