Description:
Posting as 'feature request' (though current implementation is a bug IMHO - for me it is not important that it is documented).
http://dev.mysql.com/doc/refman/5.5/en/replication-options-slave.html
"For example, when using statement-based logging, a server running with only --binlog-do-db=sales does not write to the binary log statements for which the default database differs from sales." (and other statments elsewhere in docs could be referenced as well).
The point here is: "For example, when using statement-based logging, a server running with only --binlog-do-db=sales does not write to the binary log statements for which the default database differs from sales - ***AND NOT EVEN EITHER if a fully qualified tablename specifying a database that is defined in configuration to replicate is specified in a statement***.
The problem is simply that a user|client cannot know if|what binlog|replicate_do|ignore_db settings are defined in configuration. They are not even exposed as variables.
With slow and remote connections (possible tunneled) sending a USE and waiting for server response every time is a considerable overhead when working on multiple databases simultaneously and randomly. In such cases you would want to minimize the number of statements by using fully qualified tablenames.
How to repeat:
See above
Suggested fix:
When 'fully qualifed table names' are used in statements don't consider latest explicit USE but get the database context from the statement itself instead. If the database-part of the tablename matches a database that is defined in configuration to binlog|replicate then binlog|replicate it.
BTW: I have an approved/verifed related bug report here where SELECT DATABASE() returns NULL and a fully-qualified INSERT or UPDATE statement fails to a server using --binlog-ignore-db. I cannot find this report now. Was it marked as private? But it would solve this as well.