~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to mysql-test/extra/rpl_tests/rpl_loaddata.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Requires statement logging
 
2
-- source include/have_binlog_format_mixed_or_statement.inc
 
3
 
 
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
 
7
#
 
8
# check replication of load data for temporary tables with additional
 
9
# parameters
 
10
#
 
11
# check if duplicate entries trigger an error (they should unless IGNORE or
 
12
# REPLACE was used on the master) (bug 571).
 
13
#
 
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)
 
16
 
 
17
-- source include/master-slave.inc
 
18
source include/have_innodb.inc;
 
19
 
 
20
connection slave;
 
21
reset master;
 
22
connection master;
 
23
 
 
24
select last_insert_id();
 
25
create table t1(a int not null auto_increment, b int, primary key(a) );
 
26
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
 
27
# verify that LAST_INSERT_ID() is set by LOAD DATA INFILE
 
28
select last_insert_id();
 
29
 
 
30
create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60));
 
31
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by '\n##\n' starting by '>' ignore 1 lines;
 
32
 
 
33
create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60));
 
34
insert into t3 select * from t2;
 
35
 
 
36
save_master_pos;
 
37
connection slave;
 
38
sync_with_master;
 
39
 
 
40
select * from t1;
 
41
select * from t3;
 
42
 
 
43
connection master;
 
44
 
 
45
drop table t1;
 
46
drop table t2;
 
47
drop table t3;
 
48
create table t1(a int, b int, unique(b));
 
49
 
 
50
save_master_pos;
 
51
connection slave;
 
52
sync_with_master;
 
53
 
 
54
# See if slave stops when there's a duplicate entry for key error in LOAD DATA
 
55
 
 
56
insert into t1 values(1,10);
 
57
 
 
58
connection master;
 
59
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
 
60
 
 
61
save_master_pos;
 
62
connection slave;
 
63
# The SQL slave thread should be stopped now.
 
64
--source include/wait_for_slave_sql_to_stop.inc
 
65
 
 
66
# Skip the bad event and see if error is cleared in SHOW SLAVE STATUS by START
 
67
# SLAVE, even though we are not executing any event (as sql_slave_skip_counter
 
68
# takes us directly to the end of the relay log).
 
69
 
 
70
set global sql_slave_skip_counter=1;
 
71
start slave;
 
72
sync_with_master;
 
73
--replace_result $MASTER_MYPORT MASTER_PORT
 
74
--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
 
75
--query_vertical show slave status;
 
76
 
 
77
# Trigger error again to test CHANGE MASTER
 
78
 
 
79
connection master;
 
80
set sql_log_bin=0;
 
81
delete from t1;
 
82
set sql_log_bin=1;
 
83
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
 
84
save_master_pos;
 
85
connection slave;
 
86
# The SQL slave thread should be stopped now. 
 
87
# Exec_Master_Log_Pos should point to the start of Execute event
 
88
# for last load data.
 
89
--source include/wait_for_slave_sql_to_stop.inc
 
90
 
 
91
# CHANGE MASTER and see if error is cleared in SHOW SLAVE STATUS.
 
92
stop slave;
 
93
change master to master_user='test';
 
94
change master to master_user='root';
 
95
--replace_result $MASTER_MYPORT MASTER_PORT
 
96
--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
 
97
--query_vertical show slave status;
 
98
 
 
99
# Trigger error again to test RESET SLAVE
 
100
 
 
101
set global sql_slave_skip_counter=1;
 
102
start slave;
 
103
sync_with_master;
 
104
connection master;
 
105
set sql_log_bin=0;
 
106
delete from t1;
 
107
set sql_log_bin=1;
 
108
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
 
109
save_master_pos;
 
110
connection slave;
 
111
# The SQL slave thread should be stopped now.
 
112
--source include/wait_for_slave_sql_to_stop.inc
 
113
 
 
114
# RESET SLAVE and see if error is cleared in SHOW SLAVE STATUS.
 
115
stop slave;
 
116
reset slave;
 
117
--replace_result $MASTER_MYPORT MASTER_PORT
 
118
--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
 
119
--query_vertical show slave status;
 
120
 
 
121
# Finally, see if logging is done ok on master for a failing LOAD DATA INFILE
 
122
 
 
123
connection master;
 
124
reset master;
 
125
eval create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
 
126
unique(day)) engine=$engine_type; # no transactions
 
127
--error ER_DUP_ENTRY
 
128
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields
 
129
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
 
130
'\n##\n' starting by '>' ignore 1 lines;
 
131
select * from t2;
 
132
save_master_pos;
 
133
connection slave;
 
134
start slave;
 
135
sync_with_master;
 
136
select * from t2;
 
137
 
 
138
# verify that if no error on slave, this is an error
 
139
 
 
140
alter table t2 drop key day;
 
141
connection master;
 
142
delete from t2;
 
143
--error ER_DUP_ENTRY
 
144
load data infile '../std_data_ln/rpl_loaddata2.dat' into table t2 fields
 
145
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
 
146
'\n##\n' starting by '>' ignore 1 lines;
 
147
connection slave;
 
148
--source include/wait_for_slave_sql_to_stop.inc
 
149
drop table t2;
 
150
connection master;
 
151
drop table t2;
 
152
drop table t1;
 
153
 
 
154
# BUG#17233 LOAD DATA INFILE: failure causes mysqld dbug_assert, binlog not flushed
 
155
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB;
 
156
 
 
157
--error ER_DUP_ENTRY
 
158
LOAD DATA INFILE "../std_data_ln/words.dat" INTO TABLE t1;
 
159
 
 
160
--disable_warnings
 
161
DROP TABLE IF EXISTS t1;
 
162
--enable_warnings
 
163
 
 
164
# End of 4.1 tests