Description:
BACKUP TABLE should flush the table to disk before copying the files. Follows
a simple case to prove it's not done correctly currently.
How to repeat:
mysql> create table btest ( id int not null auto_increment primary key );
Query OK, 0 rows affected (0.00 sec)
mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)
mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)
mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)
mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)
mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)
mysql> select * from btest;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+----+
5 rows in set (0.00 sec)
mysql> delete from btest where id in (4,5);
Query OK, 2 rows affected (0.00 sec)
mysql> backup table btest to '/tmp';
+-----------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+-----------+--------+----------+----------+
| bug.btest | backup | status | OK |
+-----------+--------+----------+----------+
1 row in set (0.00 sec)
mysql> drop table btest;
Query OK, 0 rows affected (0.01 sec)
mysql> flush tables;
Query OK, 0 rows affected (0.00 sec)
mysql> restore table btest from '/tmp';+-----------+---------+----------
+-------------------------------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+-----------+---------+----------
+-------------------------------------------------------------------------------+
| bug.btest | repair | error | Couldn't fix table with quick recovery: Found wrong number of
deleted records |
| bug.btest | repair | error | Run recovery again without -q |
| bug.btest | restore | status | OK |
+-----------+---------+----------
+-------------------------------------------------------------------------------+
3 rows in set (0.01 sec)
mysql> select * from btest;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
+----+
3 rows in set (0.00 sec)
mysql> insert into btest values (null);
Query OK, 1 row affected (0.00 sec)
mysql> select * from btest;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
| 4 | <-- should be 6!
+----+
4 rows in set (0.00 sec)