Commit b42c29cf authored by Leonard Zhou's avatar Leonard Zhou

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.

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'.
parent 664bb23a
......@@ -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]
......@@ -218,7 +218,7 @@ slave-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL)
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;
......
......@@ -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;
......@@ -6618,7 +6618,7 @@ void Execute_load_query_log_event::print(FILE* file,
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_event(Relay_log_info const *rli)
/* 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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment