Bug #40809 FLUSH TABLE nonexistenttable; does not produce error
Submitted: 18 Nov 2008 2:03 Modified: 2 Mar 2009 18:30
Reporter: Donna Harmon Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1.30, 5.0.70, 4.1.22, 3.23.58 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[18 Nov 2008 2:03] Donna Harmon
Description:
FLUSH TABLE nonexistenttable; does not produce error

How to repeat:
Start up CLI and issue the below statement for a non-existent table:

FLUSH TABLE nonexistenttablename;

Suggested fix:
Should give error if table does not exist.
[18 Nov 2008 4:14] Valeriy Kravchuk
Thank you for a problem report. As this happens on all the versions, I think it is intended behaviour - FLUSH TABLE just works in this case as if no table name was provided.

Documentation (http://dev.mysql.com/doc/refman/5.0/en/flush.html etc) should explicitely explain this.
[18 Dec 2008 19:46] Konstantin Osipov
Reporting an error for non-existent table is considered a too risky change for 5.1.
The query cache related problem was moved to a separate Bug#41599

The way FLUSH TABLE algorithm works is that it doesn't try to look up the table definition on disk if the table is not in the table cache. After all, the only goal of it is to expel the table from the cache, so there is no point in doing any extra work if the table is already not there.
We could fix it by adding an extra look up, but that would make FLUSH TABLE non-atomic: after the table is not found in the cache, we'll look it up on disk,
and in between someone may add it to the cache. 
We could make sure nobody can sneak in by taking an exclusive metadata lock on the table, before flushing it, but the whole point of flush table is that it
works without exclusive metadata locks, directly with the table cache, marks the table stale in the table cache, and then waits till all users of the table finish using it. In other words, flush table does not interfere with users, unlike an exclusive metadata lock.

To sum up, the fact that flush table doesn't check that the table doesn't exist
simply needs to be documented.
[2 Mar 2009 18:30] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.