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)