1
# Requires statement logging
2
-- source include/have_binlog_format_mixed_or_statement.inc
4
# See if replication of a "LOAD DATA in an autoincrement column"
5
# Honours autoincrement values
6
# i.e. if the master and slave have the same sequence
8
# check replication of load data for temporary tables with additional
11
# check if duplicate entries trigger an error (they should unless IGNORE or
12
# REPLACE was used on the master) (bug 571).
14
# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and
15
# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986)
17
-- source include/master-slave.inc
18
source include/have_innodb.inc;
24
# MTR is not case-sensitive.
25
let $lower_stmt_head= load data;
26
let $UPPER_STMT_HEAD= LOAD DATA;
27
if (`SELECT '$lock_option' <> ''`)
29
#if $lock_option is null, an extra blank is added into the statement,
30
#this will change the result of rpl_loaddata test case. so $lock_option
31
#is set only when it is not null.
32
let $lower_stmt_head= load data $lock_option;
33
let $UPPER_STMT_HEAD= LOAD DATA $lock_option;
36
select last_insert_id();
37
create table t1(a int not null auto_increment, b int, primary key(a) );
38
eval $lower_stmt_head infile '../../std_data/rpl_loaddata.dat' into table t1;
39
# verify that LAST_INSERT_ID() is set by LOAD DATA INFILE
40
select last_insert_id();
42
create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60));
43
eval $lower_stmt_head infile '../../std_data/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines;
45
create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60));
46
insert into t3 select * from t2;
60
create table t1(a int, b int, unique(b));
66
# See if slave stops when there's a duplicate entry for key error in LOAD DATA
68
insert into t1 values(1,10);
71
eval $lower_stmt_head infile '../../std_data/rpl_loaddata.dat' into table t1;
75
# The SQL slave thread should be stopped now.
76
--source include/wait_for_slave_sql_to_stop.inc
78
# Skip the bad event and see if error is cleared in SHOW SLAVE STATUS by START
79
# SLAVE, even though we are not executing any event (as sql_slave_skip_counter
80
# takes us directly to the end of the relay log).
82
set global sql_slave_skip_counter=1;
85
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
86
echo Last_SQL_Errno=$last_error;
87
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
91
# Trigger error again to test CHANGE MASTER
97
eval $lower_stmt_head infile '../../std_data/rpl_loaddata.dat' into table t1;
100
# The SQL slave thread should be stopped now.
101
# Exec_Master_Log_Pos should point to the start of Execute event
102
# for last load data.
103
--source include/wait_for_slave_sql_to_stop.inc
105
# CHANGE MASTER and see if error is cleared in SHOW SLAVE STATUS.
107
change master to master_user='test';
108
change master to master_user='root';
109
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
110
echo Last_SQL_Errno=$last_error;
111
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
115
# Trigger error again to test RESET SLAVE
117
set global sql_slave_skip_counter=1;
124
eval $lower_stmt_head infile '../../std_data/rpl_loaddata.dat' into table t1;
127
# The SQL slave thread should be stopped now.
128
--source include/wait_for_slave_sql_to_stop.inc
130
# RESET SLAVE and see if error is cleared in SHOW SLAVE STATUS.
133
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
134
echo Last_SQL_Errno=$last_error;
135
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
139
# Finally, see if logging is done ok on master for a failing LOAD DATA INFILE
143
eval create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
144
unique(day)) engine=$engine_type; # no transactions
146
eval $lower_stmt_head infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
147
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
148
'\n##\n' starting by '>' ignore 1 lines;
156
# verify that if no error on slave, this is an error
158
alter table t2 drop key day;
162
eval $lower_stmt_head infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
163
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
164
'\n##\n' starting by '>' ignore 1 lines;
166
--source include/wait_for_slave_sql_to_stop.inc
171
# BUG#17233 LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed
172
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB;
175
eval $UPPER_STMT_HEAD INFILE "../../std_data/words.dat" INTO TABLE t1;
177
DROP TABLE IF EXISTS t1;
179
# BUG#48297: Schema name is ignored when LOAD DATA is written into binlog,
181
-- source include/master-slave-reset.inc
183
-- let $db1= b48297_db1
184
-- let $db2= b42897_db2
189
-- eval drop database if exists $db1
190
-- eval drop database if exists $db2
193
-- eval create database $db1
194
-- eval create database $db2
197
-- eval CREATE TABLE t1 (c1 VARCHAR(256)) engine=$engine_type;
201
-- echo ### assertion: works with cross-referenced database
202
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
203
-- eval $UPPER_STMT_HEAD LOCAL INFILE '$MYSQLTEST_VARDIR/std_data/loaddata5.dat' INTO TABLE $db1.t1
206
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
207
-- echo ### assertion: works with fully qualified name on current database
208
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
209
-- eval $UPPER_STMT_HEAD LOCAL INFILE '$MYSQLTEST_VARDIR/std_data/loaddata5.dat' INTO TABLE $db1.t1
211
-- echo ### assertion: works without fully qualified name on current database
212
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
213
-- eval $UPPER_STMT_HEAD LOCAL INFILE '$MYSQLTEST_VARDIR/std_data/loaddata5.dat' INTO TABLE t1
215
-- echo ### create connection without default database
216
-- echo ### connect (conn2,localhost,root,,*NO-ONE*);
217
connect (conn2,localhost,root,,*NO-ONE*);
219
-- echo ### assertion: works without stating the default database
220
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
221
-- eval $UPPER_STMT_HEAD LOCAL INFILE '$MYSQLTEST_VARDIR/std_data/loaddata5.dat' INTO TABLE $db1.t1
223
# We cannot disconnect right away because when inserting
224
# concurrently in a MyISAM table, the server is sending an OK
225
# to the client before updating the table state (where the
226
# number of records is kept). See: BUG#37521 and BUG#29334.
227
# So we need to wait, otherwise we would be having sporadic
228
# failures as reported here: BUG#50451.
230
# 12 = 3 rows per each LOAD DATA executed x 4
232
-- let $table= $db1.t1
233
--source include/wait_until_rows_count.inc
235
-- echo ### disconnect and switch back to master connection
239
-- sync_slave_with_master
242
let $diff_table_1=master:$db1.t1;
243
let $diff_table_2=slave:$db1.t1;
244
source include/diff_tables.inc;
248
-- eval DROP DATABASE $db1
249
-- eval DROP DATABASE $db2
251
-- sync_slave_with_master
253
# BUG#49479: LOAD DATA INFILE is binlogged without escaping field names
254
-- source include/master-slave-reset.inc
257
CREATE TABLE t1 (`key` TEXT, `text` TEXT);
259
LOAD DATA INFILE '../../std_data/loaddata2.dat' REPLACE INTO TABLE `t1` FIELDS TERMINATED BY ',';
262
-- sync_slave_with_master
265
-- sync_slave_with_master