正在加载……
Can you Trust CHECK TABLE ?
| |
Posted in LAMP on September 12, 2008 / 引用(0)

Take a look at this:

SQL:
  1. mysql> repair TABLE a3;
  2. +---------+--------+----------+----------+
  3. | TABLE   | Op     | Msg_type | Msg_text |
  4. +---------+--------+----------+----------+
  5. | test.a3 | repair | STATUS   | OK       |
  6. +---------+--------+----------+----------+
  7. 1 row IN SET (0.10 sec)
  8. mysql> SELECT * FROM a3 ORDER BY i;
  9. +------------+
  10. | i          |
  11. +------------+
  12. | 2147483648 |
  13. |         11 |
  14. |         13 |
  15. |         14 |
  16. | 2147483647 |
  17. +------------+
  18. 5 rows IN SET (0.00 sec)

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

from

This entry comes from 本站原创 and has been read for 321 times.It is tagged with , , , .
发表评论

昵称

网址

电邮

OpenID登入 高级选项 表情