Where the open source database community meets: Use code PERCONA75 and secure your spot for Percona Live.  Register

Can you Trust CHECK TABLE ?

September 11, 2008
Author
Peter Zaitsev
Share this Post:

Take a look at this:

The sort order is obviously wrong while CHECK TABLE is not reporting any error

Why ? Because CHECK TABLE only looks at MyISAM data and Index files and it does not compare information in these to table definition (.frm file)

In this particular case I replaced .frm file for the table from different one changing INT to UNSIGNED INT to see what effect it will give – as you can see you get quite funny table which is considered OK by CHECK TABLE, which does store values larger than max signed int but which sorts them as unsigned ints. Quite fun.

I hope the task of fixing this is somewhere on MySQL roadmap 🙂

0 0 votes
Article Rating
Subscribe
Notify of
guest

6 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
hartmut
hartmut
17 years ago

Hi Peter,

is there a bug report for this already or should we create one?

Pat
Pat
17 years ago

How’s check table even going to if there’s an error here w/o carrying a second copy of the metadata in the MYD file? Seems like he can only reasonably be expected to compare the data in the MYD with the data in the FRM and if they look consistent all is well.

If you spoof the metadata like this, I think that qualifies as an event the product can’t reasonably be expected to recover from. Like going out and deleting the binary log from the file system and then opening a bug that replication is broken.

James Aylett
17 years ago

You can detect this situation to some extent by having some kind of hash of the frm in the myd/myi files. On the other hand, you can always break systems by messing directly with their internal files, so I wouldn’t argue that this is as important as perhaps providing tools for managing rollback/restore of these files as a group. Or just telling you not to do that sort of thing 🙂

kissimmee vacation homes
kissimmee vacation homes
17 years ago

I wanted to thank you for this excellent read!! I definitely loved every little bit of it.Cheers for the info!!!! & This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you ………
thanks

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved