Bug #35564 RENAME TABLES sometimes doesn't properly track table data (MyISAM row count)
Submitted: 26 Mar 2008 2:45 Modified: 26 Apr 2008 9:26
Reporter: Todd Lipcon Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.0.45 OS:Any
Assigned to: CPU Architecture:Any
Tags: myisam, rename tables

[26 Mar 2008 2:45] Todd Lipcon
Description:
Using RENAME TABLES to do a multiple rename of a MyISAM table doesn't properly maintain table statistics after the rename.

This is completely repeatable using this particular table in our production system, though I haven't been able to reproduce it using small test tables.

How to repeat:
[ some steps to build a table SongRoyalty_swap which has the same columns as SongRoyalty_cur_quarter ]

mysql> select count(*) from SongRoyalty_swap;
+----------+
| count(*) |
+----------+
|   549583 | 
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from SongRoyalty_cur_quarter;
+----------+
| count(*) |
+----------+
|   549582 | 
+----------+
1 row in set (0.00 sec)

mysql> repair table SongRoyalty_swap;
+------------------------------------+--------+----------+----------+
| Table                              | Op     | Msg_type | Msg_text |
+------------------------------------+--------+----------+----------+
| amiest_production.SongRoyalty_swap | repair | status   | OK       | 
+------------------------------------+--------+----------+----------+
1 row in set (3.10 sec)

mysql> repair table SongRoyalty_cur_quarter;
+-------------------------------------------+--------+----------+----------+
| Table                                     | Op     | Msg_type | Msg_text |
+-------------------------------------------+--------+----------+----------+
| amiest_production.SongRoyalty_cur_quarter | repair | status   | OK       | 
+-------------------------------------------+--------+----------+----------+
1 row in set (3.01 sec)

mysql>  RENAME TABLE SongRoyalty_cur_quarter TO sr_swapped_out, SongRoyalty_swap TO SongRoyalty_cur_quarter;
Query OK, 0 rows affected (0.00 sec)

mysql> repair table SongRoyalty_cur_quarter;
+-------------------------------------------+--------+----------+----------------------------------------------+
| Table                                     | Op     | Msg_type | Msg_text                                     |
+-------------------------------------------+--------+----------+----------------------------------------------+
| amiest_production.SongRoyalty_cur_quarter | repair | warning  | Number of rows changed from 549582 to 549583 | 
| amiest_production.SongRoyalty_cur_quarter | repair | status   | OK                                           | 
+-------------------------------------------+--------+----------+----------------------------------------------+
2 rows in set (2.90 sec)

mysql> repair table sr_swapped_out;
+----------------------------------+--------+----------+----------+
| Table                            | Op     | Msg_type | Msg_text |
+----------------------------------+--------+----------+----------+
| amiest_production.sr_swapped_out | repair | status   | OK       | 
+----------------------------------+--------+----------+----------+
1 row in set (3.01 sec)
[26 Mar 2008 9:26] Susanne Ebrecht
Many thanks for writing a bug report.

Unfortunately I don't understand your issue.

Do you mean the following:

You have: table a
and there are round about half a million rows in a.

Now you rename a to b. And after this there is one row missing in the table.

Is this what you wanted to explain?
[26 Apr 2008 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".