Bug #3415 mysqlbinlog loses a USE command when LOAD DATA INFILE is involved
Submitted: 7 Apr 2004 9:24 Modified: 7 Apr 2004 9:41
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: Guilhem Bichot CPU Architecture:Any

[7 Apr 2004 9:24] Guilhem Bichot
Description:
See how-to-repeat for a testcase

How to repeat:
Have db1 and db2.
Do
use db2;
INSERT INTO mytable3 VALUES(1);

Then in two simultanate threads, do
use db1;
LOAD DATA INFILE 'file' into mytable;
and
use db1;
INSERT INTO mytable2 VALUES(2);

Then in the output of mysqlbinlog you may have:

use db2;
INSERT INTO mytable3 VALUES(1);
# use db1;
# LOAD DATA INFILE 'file' into mytable; (that's the Create_file event)
INSERT INTO mytable2 VALUES(2);
LOAD DATA INFILE '/tmp/file' into mytable; (that's the Exec_load event)
and when you play this you will get "db2.mytable2" does not exist.
Because the "use db1" was commented, which is ok, but was forgotten for the INSERT.

Suggested fix:
Do not update 'last_db' if you are printing "use" with a #.
[7 Apr 2004 9:41] Guilhem Bichot
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Fixed in ChangeSet@1.1771.1.1, 2004-04-07 18:34:31+02:00, guilhem@mysql.com