From: Leonard Zhou Date: March 16 2009 8:21am Subject: bzr commit into mysql-5.1-bugteam branch (leonard:2810) Bug#22504 List-Archive: http://lists.mysql.com/commits/69681 X-Bug: 22504 Message-Id: <200903160821.n2G8LwqK014608@laptop.laptop> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/zhl/mysql/rep/5.1/bug22504/ 2810 Leonard Zhou 2009-03-16 BUG#22504 load data infile sql statement in replication architecture get error The problem is issued because we set wrong start position and stop position of query string into binlog. That two values are stored as part of head info of query string. When we parse binlog, we first get position values then get the query string according position values. But seems that two values are not calculated correctly after the parse of Yacc. We don't want to touch so much of yacc because it may influence other codes. So just add one space after 'INTO' key word when parsing. This can easily resolve the problem. modified: mysql-test/suite/rpl/r/rpl_loaddatalocal.result mysql-test/suite/rpl/r/rpl_stm_log.result mysql-test/suite/rpl/t/rpl_loaddatalocal.test sql/log_event.cc per-file messages: mysql-test/suite/rpl/r/rpl_loaddatalocal.result Test result mysql-test/suite/rpl/t/rpl_loaddatalocal.test Test case sql/log_event.cc Add space after 'INTO'. === modified file 'mysql-test/suite/rpl/r/rpl_loaddatalocal.result' --- a/mysql-test/suite/rpl/r/rpl_loaddatalocal.result 2007-12-12 17:19:24 +0000 +++ b/mysql-test/suite/rpl/r/rpl_loaddatalocal.result 2009-03-16 08:21:29 +0000 @@ -29,3 +29,28 @@ a 2 3 drop table t1; +==== Bug22504 Initialize ==== +[on master] +SET sql_mode='ignore_space'; +CREATE TABLE t1(a int); +insert into t1 values (1), (2), (3), (4); +select * into outfile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1; +truncate table t1; +load data local infile 'MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1; +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +[on slave] +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +==== Clean up ==== +[on master] +DROP TABLE t1; +[on slave] === modified file 'mysql-test/suite/rpl/r/rpl_stm_log.result' --- a/mysql-test/suite/rpl/r/rpl_stm_log.result 2009-02-02 11:44:18 +0000 +++ b/mysql-test/suite/rpl/r/rpl_stm_log.result 2009-03-16 08:21:29 +0000 @@ -218,7 +218,7 @@ slave-bin.000001 # Query 1 # use `test`; slave-bin.000001 # Query 1 # use `test`; drop table t1 slave-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM slave-bin.000001 # Begin_load_query 1 # ;file_id=1;block_len=581 -slave-bin.000001 # Execute_load_query 1 # use `test`; load data INFILE '../../tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1 +slave-bin.000001 # Execute_load_query 1 # use `test`; load data INFILE '../../tmp/SQL_LOAD-2-1-1.data' INTO table t1 ignore 1 lines ;file_id=1 slave-bin.000001 # Query 1 # use `test`; create table t3 (a int)ENGINE=MyISAM slave-bin.000001 # Rotate 2 # slave-bin.000002;pos=4 show binlog events in 'slave-bin.000002' from 4; === modified file 'mysql-test/suite/rpl/t/rpl_loaddatalocal.test' --- a/mysql-test/suite/rpl/t/rpl_loaddatalocal.test 2008-10-23 19:27:09 +0000 +++ b/mysql-test/suite/rpl/t/rpl_loaddatalocal.test 2009-03-16 08:21:29 +0000 @@ -64,3 +64,37 @@ drop table t1; save_master_pos; connection slave; sync_with_master; + + +# +# Bug22504 load data infile sql statement in replication architecture get error +# +--echo ==== Bug22504 Initialize ==== + +--echo [on master] +--connection master + +SET sql_mode='ignore_space'; +CREATE TABLE t1(a int); +insert into t1 values (1), (2), (3), (4); +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +eval select * into outfile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1; +truncate table t1; +--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +eval load data local infile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1; +--remove_file $MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile +SELECT * FROM t1 ORDER BY a; + +--echo [on slave] +sync_slave_with_master; +SELECT * FROM t1 ORDER BY a; + +--echo ==== Clean up ==== + +--echo [on master] +connection master; +DROP TABLE t1; + +--echo [on slave] +sync_slave_with_master; + === modified file 'sql/log_event.cc' --- a/sql/log_event.cc 2009-02-04 11:08:27 +0000 +++ b/sql/log_event.cc 2009-03-16 08:21:29 +0000 @@ -6618,7 +6618,7 @@ void Execute_load_query_log_event::print my_b_printf(&cache, "\'"); if (dup_handling == LOAD_DUP_REPLACE) my_b_printf(&cache, " REPLACE"); - my_b_printf(&cache, " INTO"); + my_b_printf(&cache, " INTO "); my_b_write(&cache, (uchar*) query + fn_pos_end, q_len-fn_pos_end); my_b_printf(&cache, "\n%s\n", print_event_info->delimiter); } @@ -6699,7 +6699,7 @@ Execute_load_query_log_event::do_apply_e /* Ordinary load data */ break; } - p= strmake(p, STRING_WITH_LEN(" INTO")); + p= strmake(p, STRING_WITH_LEN(" INTO ")); p= strmake(p, query+fn_pos_end, q_len-fn_pos_end); error= Query_log_event::do_apply_event(rli, buf, p-buf);