Things like 'optimize table' / 'alter table' shall be able to close all handler tables that are not in use. This can be done in the following way: - When accessing 'thd->handler_tables_hash' have a lock on LOCK_open. - Add a marker in the table object that the table is locked (should already exists, but better to verify that this is reset properly on unlock tables). - In remove_table_from_cache(), call mysql_ha_flush_table(... MYSQL_HA_REOPEN_ON_USAGE) for all handler tables that are not locked.
