Bug #6749 binlog-do-db/binlog-ignore-db do not behave like doc says if no current db
Submitted: 22 Nov 2004 10:35 Modified: 17 Feb 2005 17:47
Reporter: Guilhem Bichot Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:4.0 OS:Any (all)
Assigned to: Lars Thalmann CPU Architecture:Any

[22 Nov 2004 10:35] Guilhem Bichot
Description:
Doc says:
http://dev.mysql.com/doc/mysql/en/Binary_log.html

The rules for logging or ignoring updates to the binary log are evaluated in the following order:

   1. Are there binlog-do-db or binlog-ignore-db rules?
          * No: Write the statement to the binary log and exit.
          * Yes: Go to the next step.
   2. There are some rules (binlog-do-db or binlog-ignore-db or both). Is there a current database (has any
+database been selected by USE?)?
          * No: Do not write the statement, and exit.
          * Yes: Go to the next step.

But the last "No" is not what happens. The statement *will* be written.
This is not logical; the manual is right and the code is wrong.

How to repeat:
see description

Suggested fix:
in sql/log.cc:
    if ((thd && !(thd->options & OPTION_BIN_LOG)) ||
	(local_db && !db_ok(local_db, binlog_do_db, binlog_ignore_db)))
probably the local_db should be removed, and then db_ok will ignore the statement.
[10 Feb 2005 21:30] Lars Thalmann
Pushed in 4.1
[17 Feb 2005 17:26] Lars Thalmann
Pushed in 4.1.10:

ChangeSet@1.2154.43.1, 2005-02-10 21:23:48+01:00, lars@mysql.com
  BUG#6749: If there is no current database, then nothing should be binlogged if
  binlog-do-db or binlog-ignore-db are in effect.   (In the future 5.1? 5.0? I think
  each statement should be verified against the filtering criteria based on the database
  it *uses* and not the *current* one.  But, right now the *current* database is what
  counts according to the semantics of the manual.)
[17 Feb 2005 17:47] Paul DuBois
Mentioned in 4.1.10 change notes.