Bug #5524 | MERGE engine: comparison against timestamp field fails | ||
---|---|---|---|
Submitted: | 10 Sep 2004 22:20 | Modified: | 13 Sep 2004 18:01 |
Reporter: | Timothy Smith | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 4.0.20 | OS: | Linux (Linux / Solaris) |
Assigned to: | Ingo Strüwing | CPU Architecture: | Any |
[10 Sep 2004 22:20]
Timothy Smith
[13 Sep 2004 18:01]
Ingo Strüwing
The manual is not overly clear about MERGE tables. It stresses that all merged MyISAM tables must have identical column and index information. It does not exactly say that the same is true for the MERGE table. The only exception is that primary (unique) indexes are to be replaced by normal indexes. In your example you simply dropped the primary key. So the MyISAM table had 5 keys, while the MERGE table had 4 keys. Since your query uses a range scan over the fourth index (you can see that by putting "explain " in front of the select statement), also the fourth index of the MyISAM table is used. This is however a char(255) column, not a timestamp. By simply inserting "KEY ID (ID)," as the first key of the merge table, the queries work fine. The number and order of the keys do then match between the MERGE and MyISAM table except of the uniqueness of the primary key. The reason for the third query to succeed was that the optimizer does not use a range scan over an index for the UNIX_TIMESTAMP() function. Instead a table scan is executed, which delivers all rows independent of the index mismatch.