Description:
# This is originally repored by Mr. Masahiro Tomita
MyISAM table get corrupted when inserting utf8 data
How to repeat:
Repeatable on both 4.1.12 and 5.0.7.
[4.1.12]
mysql> show create table example\G
*************************** 1. row ***************************
Table: example
Create Table: CREATE TABLE `example` (
`id` int(11) NOT NULL default '0',
`subid` int(11) NOT NULL auto_increment,
`str` varchar(255) default NULL,
UNIQUE KEY `id` (`id`,`subid`),
KEY `str` (`str`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.02 sec)
mysql> insert into example values (0,0,0xE988B4E9B9BFE88090E4B985);
Query OK, 1 row affected (0.00 sec)
mysql> insert into example values (1,0,0xE988B4E9B9BF2E686F6765);
ERROR 1032 (HY000): Can't find record in 'example'
mysql> check table example;
+--------------+-------+----------+---------------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+--------------+-------+----------+---------------------------------------------------------------+
| test.example | check | warning | Table is marked as crashed |
| test.example | check | error | Found key at page 1024 that points to record outside datafile |
| test.example | check | error | Corrupt |
+--------------+-------+----------+---------------------------------------------------------------+
3 rows in set (0.02 sec)
mysql> repair table example;
+--------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+--------------+--------+----------+----------+
| test.example | repair | status | OK |
+--------------+--------+----------+----------+
1 row in set (0.02 sec)
[5.0.7]
mysql> show create table example\G
*************************** 1. row ***************************
Table: example
Create Table: CREATE TABLE `example` (
`id` int(11) NOT NULL default '0',
`subid` int(11) NOT NULL auto_increment,
`str` varchar(255) default NULL,
UNIQUE KEY `id` (`id`,`subid`),
KEY `str` (`str`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
mysql> insert into example values (0,0,0xE988B4E9B9BFE88090E4B985);
Query OK, 1 row affected (0.00 sec)
mysql> insert into example values (1,0,0xE988B4E9B9BF2E686F6765);
ERROR 126 (HY000): Incorrect key file for table '.\test\example.MYI'; try to repair it
mysql> check table example;
+--------------+-------+----------+---------------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+--------------+-------+----------+---------------------------------------------------------------+
| test.example | check | warning | Table is marked as crashed |
| test.example | check | error | Found key at page 1024 that points to record outside datafile |
| test.example | check | error | Corrupt |
+--------------+-------+----------+---------------------------------------------------------------+
3 rows in set (0.02 sec)
mysql> repair table example;
+--------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+--------------+--------+----------+----------+
| test.example | repair | status | OK |
+--------------+--------+----------+----------+
1 row in set (0.03 sec)
Suggested fix:
N/A