Bug #1096 mysqlbinlog does not comment the original LOAD DATA INFILE is it has a "use xx"
Submitted: 19 Aug 2003 6:33 Modified: 19 Aug 2003 6:54
Reporter: Guilhem Bichot Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0 OS:Any (all)
Assigned to: Guilhem Bichot CPU Architecture:Any

[19 Aug 2003 6:33] Guilhem Bichot
Description:
mysqlbinlog prints the original LOAD DATA INFILE with a leading #, so that this command is displayed for information of the user but not executed (as it will be later rewritten to a LOAD DATA LOCAL before execution).
When the database in use changes in a binlog, mysqlbinlog prints a "USE" command before the LOAD command (or any query).
So sometimes we end up with

#use test;
LOAD DATA INFILE '/m/grosse_table2' INTO TABLE uu  FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LI
NES TERMINATED BY '\n' STARTING BY '' (a,b);
# file_id: 3  block_len: 131072
#Exec_load: file_id=3
LOAD DATA LOCAL INFILE '/tmp/grosse_table2-00000003' INTO TABLE uu  FIELDS TERMINATED BY '\t' ENCLOSED BY '' E
SCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (a,b);
# file_id: 3  block_len: 131072

which is bad (see how the USE stole the # which was intended for the LOAD DATA INFILE '/m/grosse_table2').

How to repeat:
To get the "use" to see the problem, make LOAD DATA INFILE the first command of your binlog.

Suggested fix:
will fix it shortly to have
#use test;
#LOAD DATA INFILE '/m/grosse_table2' INTO TABLE uu  FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LI
NES TERMINATED BY '\n' STARTING BY '' (a,b);
# file_id: 3  block_len: 131072
#Exec_load: file_id=3
LOAD DATA LOCAL INFILE '/tmp/grosse_table2-00000003' INTO TABLE uu  FIELDS TERMINATED BY '\t' ENCLOSED BY '' E
SCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (a,b);
# file_id: 3
[19 Aug 2003 6:47] 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

ChangeSet@1.1573, 2003-08-19 15:46:47+02:00, guilhem@mysql.com