When RENAME TABLE is executed, it apparently does not check whether the engine is available (unlike ALTER TABLE .. RENAME, which does). It means that if the engine in question was not loaded on some reason, the table might become unusable, since the engine won't know about the change.
It was an upstream bug, which existed in previous versions as well, but it seems to be fixed in 5.7. Given how many engines we have and how easy it is to get this problem accidentally, maybe it makes sense to consider backporting the fix into 10.0.
The test case below uses InnoDB to be universal for MariaDB and MySQL, so it looks a bit of a stretch. In reality, I encountered the problem with TokuDB, and it was really just a human error:
- started the server with plugin-dir where ha_tokudb.so lived;
- installed TokuDB engine;
- created a TokuDB table;
- then at some point I restarted the server, but with a different plugin-dir which did not have TokuDB;
- since TokuDB is not a default engine or anything, server didn't have any problem starting;
- I then renamed the table, which it did happily;
- then I restarted the server again with the right plugin-dir, but TokuDB would not recognize the table any longer.
Fixing it is not that easy, simple reverse rename does not work, you have to repeat the whole exercise – start server without the engine, rename the table back, start server with the engine...