Bug #6671 mysqlbinlog does not show thread_id for LOAD DATA INFILE
Submitted: 16 Nov 2004 22:20 Modified: 7 Dec 2004 11:18
Reporter: Guilhem Bichot Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:4.0 OS:Any (all)
Assigned to: Guilhem Bichot CPU Architecture:Any

[16 Nov 2004 22:20] Guilhem Bichot
Description:
mysqlbinlog does not show thread_id for LOAD DATA INFILE.
Showing it would allow users of 4.0 to at least manually be able to recover when they have been using homonymous temporary tables which led to interleaved statements in the binlog (and then you need to know to which thread's each LOAD DATA INFILE loaded data).

How to repeat:
execute a LOAD DATA INFILE and run mysqlbinlog on the generated binlog.

Suggested fix:
===== log_event.cc 1.159 vs edited =====
*** /home/guilhem/tmp/bk_log_event.cc-1.159_K3hNWE      2004-09-07 14:57:51 +02:00
--- edited/log_event.cc 2004-11-16 22:48:22 +01:00
***************
*** 1612,1618 ****

    if (enable_local)
    {
!     Load_log_event::print(file, 1, last_db, !check_fname_outside_temp_buf());
      /*
         That one is for "file_id: etc" below: in mysqlbinlog we want the #, in
         SHOW BINLOG EVENTS we don't.
--- 1612,1618 ----

    if (enable_local)
    {
!     Load_log_event::print(file, 0, last_db, !check_fname_outside_temp_buf());
      /*
         That one is for "file_id: etc" below: in mysqlbinlog we want the #, in
         SHOW BINLOG EVENTS we don't.
[17 Nov 2004 1:05] Timothy Smith
Guilhem, this affects 4.1, too, in that the SET @@session.pseudo_thread_id=NNNN statement is missing from the binary log before a LOAD DATA INFILE statement.

This will cause the LOAD DATA to be applied to the wrong temporary table.

Here is an example:

Session A                       Session B
=============                   ==============

create temporary table foo (id int);

                                create temporary table foo (id int);

load data infile '../ones.txt' into table foo;

drop table if exists x;

                                load data infile '../twos.txt' into table foo;

create table x select * from foo;

                                drop table if exists y;

                                create table y select * from foo;

quit

                                quit

If I take the dump from the above commands and run them through 'mysql', then
table y get's all the rows, and table x has no rows in it.  I will attach the dump file I
get from the above commands as a 'file' on this bug report.

Timothy
[17 Nov 2004 1:06] Timothy Smith
output of 'mysqlbinlog data/myhost-bin.000011 (after running commands shown in my comment)

Attachment: test-binlog.txt (text/plain), 2.53 KiB.

[7 Dec 2004 11:18] 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:

First bug fixed in 4.0 in
ChangeSet@1.1996.1.86, 2004-11-18 22:59:17+01:00, guilhem@mysql.com
Second bug fixed in 4.1 in
ChangeSet@1.2117.81.1, 2004-12-03 23:07:08+01:00, guilhem@mysql.com