Description:
Table corruption is not discovered by CHECK TABLE until FLUSH table is called.
Moreover SELECT from this table succeeds while fails after FLUSH, this is surprising as we do not expect MYISAM to cache rows:
How to repeat:
create table crash(i int,c char(50)) checksum=1;
insert into crash values(1,"fff");
insert into crash values(2,"fff");
insert into crash values(3,"fff");
insert into crash values(4,"fff");
insert into crash values(5,"fff");
In other shell: remove first 2 chars from .MYD file
Now try checking it with MySQL:
mysql> check table crash;
+------------+-------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+------------+-------+----------+----------+
| test.crash | check | status | OK |
+------------+-------+----------+----------+
1 row in set (0.27 sec)
mysql> select * from crash;
+------+------+
| i | c |
+------+------+
| 1 | fff |
| 2 | fff |
| 3 | fff |
| 4 | fff |
| 5 | fff |
+------+------+
5 rows in set (0.00 sec)
mysql> flush table crash;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from crash;
ERROR 1030: Got error 127 from table handler
mysql> check table crash;
+------------+-------+----------+-------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+------------+-------+----------+-------------------------------------------------+
| test.crash | check | error | Size of datafile is: 278 Should be: 280 |
| test.crash | check | error | Corrupt |
+------------+-------+----------+-------------------------------------------------+
2 rows in set (0.00 sec)