Bug #64565 binlog|replicate_do|ignore_db and stmts with 'fully qualified table names'
Submitted: 6 Mar 2012 13:30 Modified: 17 Mar 2012 12:53
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S4 (Feature request)
Version:any OS:Any
Assigned to: CPU Architecture:Any
Tags: qc

[6 Mar 2012 13:30] Peter Laursen
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.
[6 Mar 2012 18:04] Valeriy Kravchuk
Thank you for the feature request.
[17 Mar 2012 12:53] Peter Laursen
The other report of mine here I referrred to is http://bugs.mysql.com/bug.php?id=60188.  This one was verified (as a *bug* - not as a *feature request*) but I believe developers did not have their final say yet.