mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Merge dl145h.mysql.com:/data0/mkindahl/mysql-5.0-rpl
into dl145h.mysql.com:/data0/mkindahl/mysql-5.0-rpl-merge include/my_sys.h: Auto merged mysql-test/r/blackhole.result: Auto merged mysql-test/r/case.result: Auto merged mysql-test/r/mysqlbinlog2.result: Auto merged mysql-test/t/blackhole.test: Auto merged mysql-test/t/case.test: Auto merged sql/set_var.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_parse.cc: Auto merged
This commit is contained in:
commit
206770562d
32 changed files with 15931 additions and 120 deletions
|
@ -530,6 +530,12 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *);
|
|||
#define my_b_tell(info) ((info)->pos_in_file + \
|
||||
(uint) (*(info)->current_pos - (info)->request_pos))
|
||||
|
||||
#define my_b_get_buffer_start(info) (info)->request_pos
|
||||
#define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \
|
||||
(char*) my_b_get_buffer_start(info)
|
||||
#define my_b_get_pos_in_file(info) (info)->pos_in_file
|
||||
|
||||
|
||||
/* tell write offset in the SEQ_APPEND cache */
|
||||
my_off_t my_b_append_tell(IO_CACHE* info);
|
||||
my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
|
||||
|
|
5
mysql-test/include/show_binlog_events2.inc
Normal file
5
mysql-test/include/show_binlog_events2.inc
Normal file
|
@ -0,0 +1,5 @@
|
|||
--let $binlog_start=98
|
||||
--replace_result $binlog_start <binlog_start>
|
||||
--replace_column 2 # 5 #
|
||||
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
|
||||
--eval show binlog events from $binlog_start
|
|
@ -1,3 +1,4 @@
|
|||
reset master;
|
||||
drop table if exists t1,t2;
|
||||
create table t1 (word varchar(20)) -- create table t1;
|
||||
create table t2 (word varchar(20)) -- create table t2;
|
||||
|
@ -11,3 +12,4 @@ flush logs;
|
|||
select * from t2;
|
||||
word
|
||||
Ada
|
||||
drop table t1,t2;
|
||||
|
|
|
@ -100,9 +100,10 @@ insert into t1 values(9);
|
|||
insert into t2 select * from t1;
|
||||
show binlog events from 98;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 98 Query 1 # use `test`; insert into t1 values(9)
|
||||
master-bin.000001 185 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 212 Query 1 # use `test`; insert into t2 select * from t1
|
||||
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
||||
master-bin.000001 166 Query 1 # use `test`; insert into t1 values(9)
|
||||
master-bin.000001 253 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 280 Query 1 # use `test`; insert into t2 select * from t1
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
reset master;
|
||||
|
@ -111,19 +112,21 @@ begin;
|
|||
insert into t2 select * from t1;
|
||||
show binlog events from 98;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 98 Query 1 # use `test`; insert into t1 values(10)
|
||||
master-bin.000001 186 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 213 Query 1 # use `test`; insert into t2 select * from t1
|
||||
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
||||
master-bin.000001 166 Query 1 # use `test`; insert into t1 values(10)
|
||||
master-bin.000001 254 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 281 Query 1 # use `test`; insert into t2 select * from t1
|
||||
insert into t1 values(11);
|
||||
commit;
|
||||
show binlog events from 98;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 98 Query 1 # use `test`; insert into t1 values(10)
|
||||
master-bin.000001 186 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 213 Query 1 # use `test`; insert into t2 select * from t1
|
||||
master-bin.000001 307 Query 1 # use `test`; BEGIN
|
||||
master-bin.000001 375 Query 1 # use `test`; insert into t1 values(11)
|
||||
master-bin.000001 463 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 98 Query 1 # use `test`; BEGIN
|
||||
master-bin.000001 166 Query 1 # use `test`; insert into t1 values(10)
|
||||
master-bin.000001 254 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 281 Query 1 # use `test`; insert into t2 select * from t1
|
||||
master-bin.000001 375 Query 1 # use `test`; BEGIN
|
||||
master-bin.000001 443 Query 1 # use `test`; insert into t1 values(11)
|
||||
master-bin.000001 531 Xid 1 # COMMIT /* XID */
|
||||
alter table t2 engine=INNODB;
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
|
@ -235,25 +238,29 @@ master-bin.000001 98 Query 1 # use `test`; BEGIN
|
|||
master-bin.000001 166 Query 1 # use `test`; insert into t1 values(16)
|
||||
master-bin.000001 254 Query 1 # use `test`; insert into t1 values(18)
|
||||
master-bin.000001 342 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 369 Query 1 # use `test`; delete from t1
|
||||
master-bin.000001 446 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 473 Query 1 # use `test`; delete from t2
|
||||
master-bin.000001 550 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 577 Query 1 # use `test`; alter table t2 type=MyISAM
|
||||
master-bin.000001 666 Query 1 # use `test`; insert into t1 values (1)
|
||||
master-bin.000001 754 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 781 Query 1 # use `test`; insert into t2 values (20)
|
||||
master-bin.000001 870 Query 1 # use `test`; drop table t1,t2
|
||||
master-bin.000001 949 Query 1 # use `test`; create temporary table ti (a int) engine=innodb
|
||||
master-bin.000001 1059 Query 1 # use `test`; insert into ti values(1)
|
||||
master-bin.000001 1146 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 1173 Query 1 # use `test`; create temporary table t1 (a int) engine=myisam
|
||||
master-bin.000001 1283 Query 1 # use `test`; insert t1 values (1)
|
||||
master-bin.000001 1366 Query 1 # use `test`; create table t0 (n int)
|
||||
master-bin.000001 1452 Query 1 # use `test`; insert t0 select * from t1
|
||||
master-bin.000001 1541 Query 1 # use `test`; insert into t0 select GET_LOCK("lock1",null)
|
||||
master-bin.000001 1648 Query 1 # use `test`; create table t2 (n int) engine=innodb
|
||||
master-bin.000001 1748 Query 1 # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti`
|
||||
master-bin.000001 369 Query 1 # use `test`; BEGIN
|
||||
master-bin.000001 437 Query 1 # use `test`; delete from t1
|
||||
master-bin.000001 514 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 541 Query 1 # use `test`; BEGIN
|
||||
master-bin.000001 609 Query 1 # use `test`; delete from t2
|
||||
master-bin.000001 686 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 713 Query 1 # use `test`; alter table t2 type=MyISAM
|
||||
master-bin.000001 802 Query 1 # use `test`; BEGIN
|
||||
master-bin.000001 870 Query 1 # use `test`; insert into t1 values (1)
|
||||
master-bin.000001 958 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 985 Query 1 # use `test`; insert into t2 values (20)
|
||||
master-bin.000001 1074 Query 1 # use `test`; drop table t1,t2
|
||||
master-bin.000001 1153 Query 1 # use `test`; create temporary table ti (a int) engine=innodb
|
||||
master-bin.000001 1263 Query 1 # use `test`; BEGIN
|
||||
master-bin.000001 1331 Query 1 # use `test`; insert into ti values(1)
|
||||
master-bin.000001 1418 Xid 1 # COMMIT /* XID */
|
||||
master-bin.000001 1445 Query 1 # use `test`; create temporary table t1 (a int) engine=myisam
|
||||
master-bin.000001 1555 Query 1 # use `test`; insert t1 values (1)
|
||||
master-bin.000001 1638 Query 1 # use `test`; create table t0 (n int)
|
||||
master-bin.000001 1724 Query 1 # use `test`; insert t0 select * from t1
|
||||
master-bin.000001 1813 Query 1 # use `test`; insert into t0 select GET_LOCK("lock1",null)
|
||||
master-bin.000001 1920 Query 1 # use `test`; create table t2 (n int) engine=innodb
|
||||
master-bin.000001 2020 Query 1 # use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `test`.`t1`,`test`.`ti`
|
||||
do release_lock("lock1");
|
||||
drop table t0,t2;
|
||||
reset master;
|
||||
|
@ -402,7 +409,7 @@ insert into t2 values (bug27417(1));
|
|||
ERROR 23000: Duplicate entry '1' for key 1
|
||||
show master status /* the offset must denote there is the query */;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 267
|
||||
master-bin.000001 335
|
||||
select count(*) from t1 /* must be 1 */;
|
||||
count(*)
|
||||
1
|
||||
|
@ -414,7 +421,7 @@ insert into t2 select bug27417(1) union select bug27417(2);
|
|||
ERROR 23000: Duplicate entry '2' for key 1
|
||||
show master status /* the offset must denote there is the query */;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 290
|
||||
master-bin.000001 358
|
||||
select count(*) from t1 /* must be 2 */;
|
||||
count(*)
|
||||
2
|
||||
|
@ -438,7 +445,7 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
|
|||
ERROR 23000: Duplicate entry '2' for key 1
|
||||
show master status /* the offset must denote there is the query */;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 301
|
||||
master-bin.000001 369
|
||||
select count(*) from t1 /* must be 4 */;
|
||||
count(*)
|
||||
4
|
||||
|
@ -466,7 +473,7 @@ delete from t2;
|
|||
ERROR 23000: Duplicate entry '1' for key 1
|
||||
show master status /* the offset must denote there is the query */;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 246
|
||||
master-bin.000001 314
|
||||
select count(*) from t1 /* must be 1 */;
|
||||
count(*)
|
||||
1
|
||||
|
@ -483,7 +490,7 @@ delete t2.* from t2,t5 where t2.a=t5.a + 1;
|
|||
ERROR 23000: Duplicate entry '1' for key 1
|
||||
show master status /* the offset must denote there is the query */;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 274
|
||||
master-bin.000001 342
|
||||
select count(*) from t1 /* must be 1 */;
|
||||
count(*)
|
||||
1
|
||||
|
@ -501,7 +508,7 @@ count(*)
|
|||
2
|
||||
show master status /* the offset must denote there is the query */;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 376
|
||||
master-bin.000001 444
|
||||
drop trigger trg_del_t2;
|
||||
drop table t1,t2,t3,t4,t5;
|
||||
drop function bug27417;
|
||||
|
|
|
@ -545,7 +545,7 @@ a b
|
|||
4 4
|
||||
show master status /* there must be the UPDATE query event */;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 260
|
||||
master-bin.000001 328
|
||||
delete from t1;
|
||||
delete from t2;
|
||||
insert into t1 values (1,2),(3,4),(4,4);
|
||||
|
@ -555,7 +555,7 @@ UPDATE t2,t1 SET t2.a=t2.b where t2.a=t1.a;
|
|||
ERROR 23000: Duplicate entry '4' for key 1
|
||||
show master status /* there must be the UPDATE query event */;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
master-bin.000001 275
|
||||
master-bin.000001 343
|
||||
drop table t1, t2;
|
||||
drop table if exists t1, t2, t3;
|
||||
CREATE TABLE t1 (a int, PRIMARY KEY (a));
|
||||
|
|
|
@ -48,7 +48,7 @@ Master_User root
|
|||
Master_Port MASTER_PORT
|
||||
Connect_Retry 1
|
||||
Master_Log_File master-bin.000001
|
||||
Read_Master_Log_Pos 609
|
||||
Read_Master_Log_Pos 515
|
||||
Relay_Log_File #
|
||||
Relay_Log_Pos #
|
||||
Relay_Master_Log_File master-bin.000001
|
||||
|
@ -63,7 +63,7 @@ Replicate_Wild_Ignore_Table
|
|||
Last_Errno 0
|
||||
Last_Error
|
||||
Skip_Counter 0
|
||||
Exec_Master_Log_Pos 609
|
||||
Exec_Master_Log_Pos 515
|
||||
Relay_Log_Space #
|
||||
Until_Condition None
|
||||
Until_Log_File
|
||||
|
|
28
mysql-test/r/rpl_loaddata_map.result
Normal file
28
mysql-test/r/rpl_loaddata_map.result
Normal file
|
@ -0,0 +1,28 @@
|
|||
stop slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
create table t2 (id int not null primary key auto_increment);
|
||||
select @@session.read_buffer_size - @@session.max_allowed_packet > 0 ;
|
||||
@@session.read_buffer_size - @@session.max_allowed_packet > 0
|
||||
1
|
||||
load data infile 'MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' into table t2;
|
||||
select count(*) from t2 /* 5 000 */;
|
||||
count(*)
|
||||
5000
|
||||
show binlog events in 'master-bin.000002' from 98;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000002 98 Query 1 # use `test`; create table t2 (id int not null primary key auto_increment)
|
||||
master-bin.000002 221 Begin_load_query 1 # ;file_id=1;block_len=7168
|
||||
master-bin.000002 7412 Append_block 1 # ;file_id=1;block_len=7168
|
||||
master-bin.000002 14603 Append_block 1 # ;file_id=1;block_len=2048
|
||||
master-bin.000002 16674 Append_block 1 # ;file_id=1;block_len=7168
|
||||
master-bin.000002 23865 Append_block 1 # ;file_id=1;block_len=341
|
||||
master-bin.000002 24229 Execute_load_query 1 # use `test`; load data infile 'MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' into table t2 ;file_id=1
|
||||
select count(*) from t2 /* 5 000 */;
|
||||
count(*)
|
||||
5000
|
||||
drop table t1, t2;
|
||||
end of the tests
|
34
mysql-test/r/rpl_server_id.result
Normal file
34
mysql-test/r/rpl_server_id.result
Normal file
|
@ -0,0 +1,34 @@
|
|||
set global server_id=1;
|
||||
reset master;
|
||||
drop table if exists t1,t2,t3;
|
||||
create table t1 (a int);
|
||||
select @@server_id;
|
||||
@@server_id
|
||||
1
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query 1 # use `test`; drop table if exists t1,t2,t3
|
||||
master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
|
||||
set global server_id=2;
|
||||
create table t2 (b int);
|
||||
select @@server_id;
|
||||
@@server_id
|
||||
2
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query 1 # use `test`; drop table if exists t1,t2,t3
|
||||
master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
|
||||
master-bin.000001 # Query 2 # use `test`; create table t2 (b int)
|
||||
set global server_id=3;
|
||||
create table t3 (c int);
|
||||
select @@server_id;
|
||||
@@server_id
|
||||
3
|
||||
show binlog events from <binlog_start>;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query 1 # use `test`; drop table if exists t1,t2,t3
|
||||
master-bin.000001 # Query 1 # use `test`; create table t1 (a int)
|
||||
master-bin.000001 # Query 2 # use `test`; create table t2 (b int)
|
||||
master-bin.000001 # Query 3 # use `test`; create table t3 (c int)
|
||||
set global server_id=1;
|
||||
drop table t1,t2,t3;
|
|
@ -5,8 +5,10 @@ reset slave;
|
|||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
**** On Master ****
|
||||
CREATE TABLE t1 (a INT, b SET('master','slave')) ENGINE=INNODB;
|
||||
CREATE TABLE t2 (a INT, b SET('master','slave')) ENGINE=MYISAM;
|
||||
CREATE TABLE t1 (a INT, b SET('master','slave')) ENGINE=InnoDB;
|
||||
CREATE TABLE t2 (a INT, b SET('master','slave')) ENGINE=MyISAM;
|
||||
CREATE TABLE t3 (a CHAR(20), b SET('master','slave')) ENGINE=InnoDB;
|
||||
CREATE TABLE t4 (a CHAR(20), b SET('master','slave')) ENGINE=MyISAM;
|
||||
==== Skipping normal transactions ====
|
||||
**** On Slave ****
|
||||
STOP SLAVE;
|
||||
|
@ -139,6 +141,102 @@ a b
|
|||
SELECT * FROM t2 ORDER BY a;
|
||||
a b
|
||||
5 master,slave
|
||||
==== Skipping first event of a LOAD DATA for a transactional table ====
|
||||
**** On Slave ****
|
||||
STOP SLAVE;
|
||||
**** On Master ****
|
||||
SET AUTOCOMMIT=1;
|
||||
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t3(a) SET b = 'master';
|
||||
INSERT INTO t3 VALUES ('Go Rin No Sho', 'master,slave');
|
||||
SELECT COUNT(*) FROM t3;
|
||||
COUNT(*)
|
||||
71
|
||||
**** On Slave ****
|
||||
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
||||
START SLAVE;
|
||||
-- Should only contain records marked 'master,slave'
|
||||
SELECT * FROM t3 ORDER BY a;
|
||||
a b
|
||||
Go Rin No Sho master,slave
|
||||
**** On Master ****
|
||||
DELETE FROM t3;
|
||||
==== Skipping first event of a LOAD DATA for a non-transactional table ====
|
||||
**** On Slave ****
|
||||
STOP SLAVE;
|
||||
**** On Master ****
|
||||
SET AUTOCOMMIT=1;
|
||||
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t4(a) SET b = 'master';
|
||||
INSERT INTO t4 VALUES ('Go Rin No Sho', 'master,slave');
|
||||
SELECT COUNT(*) FROM t4;
|
||||
COUNT(*)
|
||||
71
|
||||
**** On Slave ****
|
||||
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
||||
START SLAVE;
|
||||
-- Should only contain records marked 'master,slave'
|
||||
SELECT * FROM t4 ORDER BY a;
|
||||
a b
|
||||
Go Rin No Sho master,slave
|
||||
**** On Master ****
|
||||
DELETE FROM t4;
|
||||
==== Try with a big file so that we get an append_block event as well
|
||||
**** On Slave ****
|
||||
STOP SLAVE;
|
||||
**** On Master ****
|
||||
SET AUTOCOMMIT=1;
|
||||
SET SQL_LOG_BIN=0;
|
||||
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t4(a) SET b = 'master';
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
SELECT a FROM t4 INTO OUTFILE 'rpl_slave_skip_words.dat';
|
||||
SET SQL_LOG_BIN=1;
|
||||
LOAD DATA INFILE 'rpl_slave_skip_words.dat' INTO TABLE t4(a) SET b = 'master';
|
||||
INSERT INTO t4 VALUES ('Go Rin No Sho', 'master,slave');
|
||||
SELECT COUNT(*) FROM t4;
|
||||
COUNT(*)
|
||||
286721
|
||||
**** On Slave ****
|
||||
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
||||
START SLAVE;
|
||||
-- Should only contain records marked 'master,slave'
|
||||
SELECT * FROM t4 ORDER BY a;
|
||||
a b
|
||||
Go Rin No Sho master,slave
|
||||
**** On Master ****
|
||||
DELETE FROM t4;
|
||||
**** On Master ****
|
||||
CREATE TABLE t5 (a int, b int, c SET('master','slave'), PRIMARY KEY (a,b)) ENGINE=MyISAM;
|
||||
LOAD DATA INFILE '../std_data_ln/loaddata5.dat' INTO TABLE t5 FIELDS TERMINATED BY '' ENCLOSED BY '' (a,b) SET c='master,slave';
|
||||
**** On Slave ****
|
||||
STOP SLAVE;
|
||||
**** On Master ****
|
||||
LOAD DATA INFILE '../std_data_ln/loaddata5.dat' INTO TABLE t5 FIELDS TERMINATED BY '' ENCLOSED BY '' (a,b) SET c='';
|
||||
ERROR 23000: Duplicate entry '1-2' for key 1
|
||||
INSERT INTO t5 VALUES (42, 42, 'master,slave');
|
||||
SELECT * FROM t5;
|
||||
a b c
|
||||
1 2 master,slave
|
||||
3 4 master,slave
|
||||
5 6 master,slave
|
||||
42 42 master,slave
|
||||
**** On Slave ****
|
||||
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
||||
START SLAVE;
|
||||
SELECT * FROM t5;
|
||||
a b c
|
||||
1 2 master,slave
|
||||
3 4 master,slave
|
||||
5 6 master,slave
|
||||
42 42 master,slave
|
||||
==== Cleanup ====
|
||||
**** On Master ****
|
||||
DROP TABLE t1, t2;
|
||||
DROP TABLE t1, t2, t3, t4, t5;
|
||||
|
|
95
mysql-test/r/rpl_transaction.result
Normal file
95
mysql-test/r/rpl_transaction.result
Normal file
|
@ -0,0 +1,95 @@
|
|||
stop slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
CREATE TABLE tmyisam (a int) ENGINE = MYISAM;
|
||||
CREATE TABLE tinnodb (a int) ENGINE = INNODB;
|
||||
SHOW CREATE TABLE tmyisam;
|
||||
Table Create Table
|
||||
tmyisam CREATE TABLE `tmyisam` (
|
||||
`a` int(11) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
SHOW CREATE TABLE tinnodb;
|
||||
Table Create Table
|
||||
tinnodb CREATE TABLE `tinnodb` (
|
||||
`a` int(11) default NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
==== Test 1: Non-XA Engines ====
|
||||
--- on master ---
|
||||
SET AUTOCOMMIT = 1;
|
||||
INSERT INTO tmyisam VALUES (1);
|
||||
BEGIN;
|
||||
INSERT INTO tmyisam VALUES (2);
|
||||
INSERT INTO tmyisam VALUES (3);
|
||||
COMMIT;
|
||||
BEGIN;
|
||||
INSERT INTO tmyisam VALUES (5);
|
||||
INSERT INTO tmyisam VALUES (6);
|
||||
ROLLBACK;
|
||||
Warnings:
|
||||
Warning 1196 Some non-transactional changed tables couldn't be rolled back
|
||||
SELECT * FROM tmyisam ORDER BY a;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
5
|
||||
6
|
||||
--- on slave ---
|
||||
SELECT * FROM tmyisam ORDER BY a;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
5
|
||||
6
|
||||
==== Test 2: Master crash before writing XID event on XA engine ====
|
||||
--- on master ---
|
||||
INSERT INTO tinnodb VALUES (1);
|
||||
SELECT * FROM tinnodb ORDER BY a;
|
||||
a
|
||||
1
|
||||
--- on slave ---
|
||||
STOP SLAVE;
|
||||
SHOW SLAVE STATUS;
|
||||
Slave_IO_State
|
||||
Master_Host 127.0.0.1
|
||||
Master_User root
|
||||
Master_Port #
|
||||
Connect_Retry 1
|
||||
Master_Log_File master-bin.000001
|
||||
Read_Master_Log_Pos #
|
||||
Relay_Log_File #
|
||||
Relay_Log_Pos #
|
||||
Relay_Master_Log_File master-bin.000001
|
||||
Slave_IO_Running No
|
||||
Slave_SQL_Running No
|
||||
Replicate_Do_DB
|
||||
Replicate_Ignore_DB
|
||||
Replicate_Do_Table
|
||||
Replicate_Ignore_Table #
|
||||
Replicate_Wild_Do_Table
|
||||
Replicate_Wild_Ignore_Table
|
||||
Last_Errno 0
|
||||
Last_Error
|
||||
Skip_Counter 0
|
||||
Exec_Master_Log_Pos #
|
||||
Relay_Log_Space #
|
||||
Until_Condition None
|
||||
Until_Log_File
|
||||
Until_Log_Pos 0
|
||||
Master_SSL_Allowed No
|
||||
Master_SSL_CA_File
|
||||
Master_SSL_CA_Path
|
||||
Master_SSL_Cert
|
||||
Master_SSL_Cipher
|
||||
Master_SSL_Key
|
||||
Seconds_Behind_Master #
|
||||
SELECT * FROM tinnodb ORDER BY a;
|
||||
a
|
||||
DROP TABLE tmyisam;
|
||||
DROP TABLE tinnodb;
|
||||
DROP TABLE tmyisam;
|
||||
DROP TABLE tinnodb;
|
42
mysql-test/r/rpl_user.result
Normal file
42
mysql-test/r/rpl_user.result
Normal file
|
@ -0,0 +1,42 @@
|
|||
stop slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
reset master;
|
||||
reset slave;
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
start slave;
|
||||
reset master;
|
||||
delete from mysql.user where Host='fakehost';
|
||||
create user 'foo'@'fakehost';
|
||||
create user 'foo'@'fakehost', 'bar'@'fakehost';
|
||||
ERROR HY000: Operation CREATE USER failed for 'foo'@'fakehost'
|
||||
create user 'foo'@'fakehost', 'bar'@'fakehost';
|
||||
ERROR HY000: Operation CREATE USER failed for 'foo'@'fakehost','bar'@'fakehost'
|
||||
select Host,User from mysql.user where Host='fakehost';
|
||||
Host User
|
||||
fakehost bar
|
||||
fakehost foo
|
||||
rename user 'foo'@'fakehost' to 'foofoo'@'fakehost';
|
||||
rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost';
|
||||
ERROR HY000: Operation RENAME USER failed for 'not_exist_user1'@'fakehost'
|
||||
rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'not_exist_user2'@'fakehost' to 'barfoo'@'fakehost';
|
||||
ERROR HY000: Operation RENAME USER failed for 'not_exist_user1'@'fakehost','not_exist_user2'@'fakehost'
|
||||
select Host,User from mysql.user where Host='fakehost';
|
||||
Host User
|
||||
fakehost barbar
|
||||
fakehost foofoo
|
||||
drop user 'foofoo'@'fakehost';
|
||||
drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost';
|
||||
ERROR HY000: Operation DROP USER failed for 'not_exist_user1'@'fakehost'
|
||||
drop user 'not_exist_user1'@'fakehost', 'not_exist_user2'@'fakehost';
|
||||
ERROR HY000: Operation DROP USER failed for 'not_exist_user1'@'fakehost','not_exist_user2'@'fakehost'
|
||||
select Host,User from mysql.user where Host='fakehost';
|
||||
Host User
|
||||
show binlog events from 98;
|
||||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 98 Query 1 # use `test`; delete from mysql.user where Host='fakehost'
|
||||
master-bin.000001 205 Query 1 # use `test`; create user 'foo'@'fakehost'
|
||||
master-bin.000001 296 Query 1 # use `test`; create user 'foo'@'fakehost', 'bar'@'fakehost'
|
||||
master-bin.000001 405 Query 1 # use `test`; rename user 'foo'@'fakehost' to 'foofoo'@'fakehost'
|
||||
master-bin.000001 519 Query 1 # use `test`; rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost'
|
||||
master-bin.000001 686 Query 1 # use `test`; drop user 'foofoo'@'fakehost'
|
||||
master-bin.000001 778 Query 1 # use `test`; drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost'
|
|
@ -16,6 +16,7 @@ show binlog events from 98 /* with fixes for #23333 will show there are 2 querie
|
|||
Log_name Pos Event_type Server_id End_log_pos Info
|
||||
master-bin.000001 # Query 1 # #
|
||||
master-bin.000001 # Query 1 # #
|
||||
master-bin.000001 # Query 1 # #
|
||||
select count(*),@a from t1 /* must be 1,1 */|
|
||||
count(*) @a
|
||||
1 1
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
set session transaction_prealloc_size=1024*1024*1024*1;
|
||||
show processlist;
|
||||
Id User Host db Command Time State Info
|
||||
1 root localhost test Query 0 NULL show processlist
|
||||
6 root localhost test Query 0 NULL show processlist
|
||||
set session transaction_prealloc_size=1024*1024*1024*2;
|
||||
show processlist;
|
||||
Id User Host db Command Time State Info
|
||||
1 root localhost test Query 2 NULL show processlist
|
||||
6 root localhost test Query 1 NULL show processlist
|
||||
set session transaction_prealloc_size=1024*1024*1024*3;
|
||||
show processlist;
|
||||
Id User Host db Command Time State Info
|
||||
1 root localhost test Query 0 NULL show processlist
|
||||
6 root localhost test Query 0 NULL show processlist
|
||||
set session transaction_prealloc_size=1024*1024*1024*4;
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect transaction_prealloc_size value: '4294967296'
|
||||
show processlist;
|
||||
Id User Host db Command Time State Info
|
||||
1 root localhost test Query 0 NULL show processlist
|
||||
6 root localhost test Query 0 NULL show processlist
|
||||
set session transaction_prealloc_size=1024*1024*1024*5;
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect transaction_prealloc_size value: '5368709120'
|
||||
show processlist;
|
||||
Id User Host db Command Time State Info
|
||||
1 root localhost test Query 0 NULL show processlist
|
||||
6 root localhost test Query 0 NULL show processlist
|
||||
|
|
10000
mysql-test/std_data/bug30435_10k_items.txt
Normal file
10000
mysql-test/std_data/bug30435_10k_items.txt
Normal file
File diff suppressed because it is too large
Load diff
5000
mysql-test/std_data/bug30435_5k.txt
Normal file
5000
mysql-test/std_data/bug30435_5k.txt
Normal file
File diff suppressed because it is too large
Load diff
|
@ -2,6 +2,7 @@
|
|||
# with a syntax error, replicates fine
|
||||
|
||||
-- source include/have_log_bin.inc
|
||||
reset master;
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2;
|
||||
--enable_warnings
|
||||
|
@ -11,6 +12,11 @@ load data infile '../std_data_ln/words.dat' into table t1 -- load data to t1;
|
|||
insert into t2 values ("Ada");
|
||||
flush logs;
|
||||
select * from t2;
|
||||
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 | $MYSQL
|
||||
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_start_comment.binlog
|
||||
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/binlog_start_comment.binlog
|
||||
flush logs;
|
||||
select * from t2;
|
||||
|
||||
# clean up
|
||||
drop table t1,t2;
|
||||
--system rm $MYSQLTEST_VARDIR/tmp/binlog_start_comment.binlog
|
||||
|
|
1
mysql-test/t/rpl_loaddata_map-master.opt
Normal file
1
mysql-test/t/rpl_loaddata_map-master.opt
Normal file
|
@ -0,0 +1 @@
|
|||
--read_buffer_size=9K --max_allowed_packet=8K
|
1
mysql-test/t/rpl_loaddata_map-slave.opt
Normal file
1
mysql-test/t/rpl_loaddata_map-slave.opt
Normal file
|
@ -0,0 +1 @@
|
|||
--max_allowed_packet=8K
|
52
mysql-test/t/rpl_loaddata_map.test
Normal file
52
mysql-test/t/rpl_loaddata_map.test
Normal file
|
@ -0,0 +1,52 @@
|
|||
#
|
||||
# check replication of load data with the server parameters subjected to
|
||||
# read_buffer_size > max_allowed_packet
|
||||
#
|
||||
# BUG#30435 loading large LOAD DATA INFILE breaks slave with
|
||||
# read_buffer_size set on master
|
||||
# BUG#33413 show binlog events fails if binlog has event size of close
|
||||
# to max_allowed_packet
|
||||
|
||||
source include/master-slave.inc;
|
||||
source include/have_innodb.inc;
|
||||
|
||||
--disable_query_log
|
||||
let $rows= 5000;
|
||||
create table t1 (id int not null primary key auto_increment);
|
||||
|
||||
while($rows)
|
||||
{
|
||||
eval insert into t1 values (null);
|
||||
dec $rows;
|
||||
}
|
||||
eval select * into outfile '$MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' from t1;
|
||||
flush logs;
|
||||
--enable_query_log
|
||||
|
||||
connection master;
|
||||
create table t2 (id int not null primary key auto_increment);
|
||||
|
||||
select @@session.read_buffer_size - @@session.max_allowed_packet > 0 ;
|
||||
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
eval load data infile '$MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' into table t2;
|
||||
select count(*) from t2 /* 5 000 */;
|
||||
|
||||
# the binglog will show fragmented Append_block events
|
||||
--let $binlog_start=98
|
||||
--replace_column 5 #
|
||||
--replace_regex /\/\* xid=.* \*\//\/* XID *\//
|
||||
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||
--eval show binlog events in 'master-bin.000002' from $binlog_start
|
||||
|
||||
|
||||
sync_slave_with_master;
|
||||
#connection slave;
|
||||
select count(*) from t2 /* 5 000 */;
|
||||
|
||||
connection master;
|
||||
drop table t1, t2;
|
||||
sync_slave_with_master;
|
||||
remove_file $MYSQLTEST_VARDIR/tmp/bug30435_5k.txt;
|
||||
|
||||
--echo end of the tests
|
29
mysql-test/t/rpl_server_id.test
Normal file
29
mysql-test/t/rpl_server_id.test
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Test for BUG#28908 Replication: set global server_id is not setting the session server_id
|
||||
|
||||
-- source include/have_log_bin.inc
|
||||
|
||||
let $saved_server_id=`select @@server_id`;
|
||||
set global server_id=1;
|
||||
reset master;
|
||||
|
||||
-- disable_warnings
|
||||
drop table if exists t1,t2,t3;
|
||||
-- enable_warnings
|
||||
|
||||
create table t1 (a int);
|
||||
select @@server_id;
|
||||
source include/show_binlog_events2.inc;
|
||||
|
||||
set global server_id=2;
|
||||
create table t2 (b int);
|
||||
select @@server_id;
|
||||
source include/show_binlog_events2.inc;
|
||||
|
||||
set global server_id=3;
|
||||
create table t3 (c int);
|
||||
select @@server_id;
|
||||
source include/show_binlog_events2.inc;
|
||||
|
||||
# cleanup
|
||||
eval set global server_id=$saved_server_id;
|
||||
drop table t1,t2,t3;
|
|
@ -13,8 +13,10 @@ source include/master-slave.inc;
|
|||
# it back to get the non-transactional change into the table.
|
||||
|
||||
--echo **** On Master ****
|
||||
CREATE TABLE t1 (a INT, b SET('master','slave')) ENGINE=INNODB;
|
||||
CREATE TABLE t2 (a INT, b SET('master','slave')) ENGINE=MYISAM;
|
||||
CREATE TABLE t1 (a INT, b SET('master','slave')) ENGINE=InnoDB;
|
||||
CREATE TABLE t2 (a INT, b SET('master','slave')) ENGINE=MyISAM;
|
||||
CREATE TABLE t3 (a CHAR(20), b SET('master','slave')) ENGINE=InnoDB;
|
||||
CREATE TABLE t4 (a CHAR(20), b SET('master','slave')) ENGINE=MyISAM;
|
||||
|
||||
--echo ==== Skipping normal transactions ====
|
||||
|
||||
|
@ -195,9 +197,170 @@ sync_with_master;
|
|||
SELECT * FROM t1 ORDER BY a;
|
||||
SELECT * FROM t2 ORDER BY a;
|
||||
|
||||
--echo ==== Skipping first event of a LOAD DATA for a transactional table ====
|
||||
|
||||
--echo **** On Slave ****
|
||||
connection slave;
|
||||
STOP SLAVE;
|
||||
source include/wait_for_slave_to_stop.inc;
|
||||
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
SET AUTOCOMMIT=1;
|
||||
|
||||
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t3(a) SET b = 'master';
|
||||
INSERT INTO t3 VALUES ('Go Rin No Sho', 'master,slave');
|
||||
|
||||
save_master_pos;
|
||||
|
||||
SELECT COUNT(*) FROM t3;
|
||||
|
||||
# This will skip a begin event and the first INSERT of the
|
||||
# transaction, and it should keep skipping until it has reached the
|
||||
# transaction terminator.
|
||||
|
||||
--echo **** On Slave ****
|
||||
connection slave;
|
||||
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
||||
START SLAVE;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
sync_with_master;
|
||||
--echo -- Should only contain records marked 'master,slave'
|
||||
SELECT * FROM t3 ORDER BY a;
|
||||
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
DELETE FROM t3;
|
||||
sync_slave_with_master;
|
||||
|
||||
--echo ==== Skipping first event of a LOAD DATA for a non-transactional table ====
|
||||
|
||||
--echo **** On Slave ****
|
||||
connection slave;
|
||||
STOP SLAVE;
|
||||
source include/wait_for_slave_to_stop.inc;
|
||||
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
SET AUTOCOMMIT=1;
|
||||
|
||||
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t4(a) SET b = 'master';
|
||||
INSERT INTO t4 VALUES ('Go Rin No Sho', 'master,slave');
|
||||
|
||||
save_master_pos;
|
||||
|
||||
SELECT COUNT(*) FROM t4;
|
||||
|
||||
# This will skip a begin event and the first INSERT of the
|
||||
# transaction, and it should keep skipping until it has reached the
|
||||
# transaction terminator.
|
||||
|
||||
--echo **** On Slave ****
|
||||
connection slave;
|
||||
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
||||
START SLAVE;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
sync_with_master;
|
||||
--echo -- Should only contain records marked 'master,slave'
|
||||
SELECT * FROM t4 ORDER BY a;
|
||||
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
DELETE FROM t4;
|
||||
sync_slave_with_master;
|
||||
|
||||
--echo ==== Try with a big file so that we get an append_block event as well
|
||||
|
||||
--echo **** On Slave ****
|
||||
connection slave;
|
||||
STOP SLAVE;
|
||||
source include/wait_for_slave_to_stop.inc;
|
||||
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
SET AUTOCOMMIT=1;
|
||||
|
||||
# This contain about 70 words, so we double it a few times to get more than 128 KiB
|
||||
SET SQL_LOG_BIN=0;
|
||||
LOAD DATA INFILE '../std_data_ln/words.dat' INTO TABLE t4(a) SET b = 'master';
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
INSERT INTO t4 SELECT * FROM t4;
|
||||
SELECT a FROM t4 INTO OUTFILE 'rpl_slave_skip_words.dat';
|
||||
SET SQL_LOG_BIN=1;
|
||||
|
||||
# Start the real job
|
||||
LOAD DATA INFILE 'rpl_slave_skip_words.dat' INTO TABLE t4(a) SET b = 'master';
|
||||
INSERT INTO t4 VALUES ('Go Rin No Sho', 'master,slave');
|
||||
|
||||
#SHOW BINLOG EVENTS;
|
||||
|
||||
save_master_pos;
|
||||
|
||||
SELECT COUNT(*) FROM t4;
|
||||
|
||||
# This will skip a begin event and the first INSERT of the
|
||||
# transaction, and it should keep skipping until it has reached the
|
||||
# transaction terminator.
|
||||
|
||||
--echo **** On Slave ****
|
||||
connection slave;
|
||||
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
||||
START SLAVE;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
sync_with_master;
|
||||
--echo -- Should only contain records marked 'master,slave'
|
||||
SELECT * FROM t4 ORDER BY a;
|
||||
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
DELETE FROM t4;
|
||||
sync_slave_with_master;
|
||||
|
||||
# Test to generate a Delete_file log event, and see that it works as well.
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
CREATE TABLE t5 (a int, b int, c SET('master','slave'), PRIMARY KEY (a,b)) ENGINE=MyISAM;
|
||||
LOAD DATA INFILE '../std_data_ln/loaddata5.dat' INTO TABLE t5 FIELDS TERMINATED BY '' ENCLOSED BY '' (a,b) SET c='master,slave';
|
||||
|
||||
--echo **** On Slave ****
|
||||
sync_slave_with_master;
|
||||
STOP SLAVE;
|
||||
source include/wait_for_slave_to_stop.inc;
|
||||
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
error ER_DUP_ENTRY;
|
||||
LOAD DATA INFILE '../std_data_ln/loaddata5.dat' INTO TABLE t5 FIELDS TERMINATED BY '' ENCLOSED BY '' (a,b) SET c='';
|
||||
INSERT INTO t5 VALUES (42, 42, 'master,slave');
|
||||
save_master_pos;
|
||||
|
||||
#SHOW BINLOG EVENTS;
|
||||
|
||||
SELECT * FROM t5;
|
||||
|
||||
--echo **** On Slave ****
|
||||
connection slave;
|
||||
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
|
||||
START SLAVE;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
|
||||
sync_with_master;
|
||||
SELECT * FROM t5;
|
||||
|
||||
connection slave;
|
||||
|
||||
--echo ==== Cleanup ====
|
||||
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
DROP TABLE t1, t2;
|
||||
DROP TABLE t1, t2, t3, t4, t5;
|
||||
sync_slave_with_master;
|
||||
|
|
1
mysql-test/t/rpl_transaction-master.opt
Normal file
1
mysql-test/t/rpl_transaction-master.opt
Normal file
|
@ -0,0 +1 @@
|
|||
--innodb --debug=d,do_not_write_xid
|
1
mysql-test/t/rpl_transaction-slave.opt
Normal file
1
mysql-test/t/rpl_transaction-slave.opt
Normal file
|
@ -0,0 +1 @@
|
|||
--innodb
|
106
mysql-test/t/rpl_transaction.test
Normal file
106
mysql-test/t/rpl_transaction.test
Normal file
|
@ -0,0 +1,106 @@
|
|||
# Tests that transactions are replicated correctly, with various
|
||||
# combinations of non-transactional and transactional non-XA tables.
|
||||
# Also tests that an XA transaction where the master crashes just
|
||||
# before writing the XID log event is executed correctly. See below
|
||||
# for implementation details.
|
||||
|
||||
# Note: this test should not exist in 5.1 or higher. It has been
|
||||
# replaced by rpl_ndb_transaction.test, which tests a superset of what
|
||||
# this test tests.
|
||||
|
||||
source include/have_innodb.inc;
|
||||
source include/master-slave.inc;
|
||||
|
||||
|
||||
CREATE TABLE tmyisam (a int) ENGINE = MYISAM;
|
||||
CREATE TABLE tinnodb (a int) ENGINE = INNODB;
|
||||
|
||||
SHOW CREATE TABLE tmyisam;
|
||||
SHOW CREATE TABLE tinnodb;
|
||||
|
||||
|
||||
--echo ==== Test 1: Non-XA Engines ====
|
||||
# Test that everything works fine with non-XA engines. We just try
|
||||
# all ways to do transactions involving ndb and/or myisam, with
|
||||
# rollback or commit.
|
||||
|
||||
--echo --- on master ---
|
||||
|
||||
SET AUTOCOMMIT = 1;
|
||||
|
||||
INSERT INTO tmyisam VALUES (1);
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO tmyisam VALUES (2);
|
||||
INSERT INTO tmyisam VALUES (3);
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO tmyisam VALUES (5);
|
||||
INSERT INTO tmyisam VALUES (6);
|
||||
--warning 1196
|
||||
ROLLBACK;
|
||||
|
||||
SELECT * FROM tmyisam ORDER BY a;
|
||||
|
||||
--echo --- on slave ---
|
||||
--sync_slave_with_master
|
||||
SELECT * FROM tmyisam ORDER BY a;
|
||||
|
||||
|
||||
--echo ==== Test 2: Master crash before writing XID event on XA engine ====
|
||||
# We now want to test the following scenario, to verify that BUG#26395
|
||||
# has been fixed:
|
||||
|
||||
# "master and slave have a transactional table that uses XA. Master
|
||||
# has AUTOCOMMIT on and executes a statement (in this case an
|
||||
# INSERT). Master crashes just before writing the XID event."
|
||||
|
||||
# In this scenario, master will roll back, so slave should not execute
|
||||
# the statement, and slave should roll back later when master is
|
||||
# restarted.
|
||||
|
||||
# However, we the master to be alive so that we are sure it replicates
|
||||
# the statement to the slave. So in the test case, we must therefore
|
||||
# not crash the master. Instead, we fake the crash by just not writing
|
||||
# the XID event to the binlog. This is done by the
|
||||
# --debug=d,do_not_write_xid flag in the .opt file.
|
||||
|
||||
# So, unlike if the master had crashed, the master *will* execute the
|
||||
# statement. But the slave should not execute it. Hence, after the
|
||||
# first test is executed, the expected result on master is a table
|
||||
# with one row, and on slave a table with no rows.
|
||||
|
||||
# To simulate the slave correctly, we wait until everything up to the
|
||||
# XID is replicated. We cannot sync_slave_with_master, because that
|
||||
# would wait for the transaction to end. Instead, we wait for
|
||||
# "sufficiently long time". Then we stop the slave.
|
||||
|
||||
# Note: since this puts the master binlog in an inconsistent state,
|
||||
# this should be the last test of the file.
|
||||
|
||||
--echo --- on master ---
|
||||
--connection master
|
||||
|
||||
INSERT INTO tinnodb VALUES (1);
|
||||
SELECT * FROM tinnodb ORDER BY a;
|
||||
|
||||
--echo --- on slave ---
|
||||
--connection slave
|
||||
--sleep 3
|
||||
STOP SLAVE;
|
||||
source include/wait_for_slave_to_stop.inc;
|
||||
--replace_column 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 #
|
||||
query_vertical SHOW SLAVE STATUS;
|
||||
# the following statement should show that nothing has been replicated
|
||||
SELECT * FROM tinnodb ORDER BY a;
|
||||
|
||||
|
||||
# clean up
|
||||
connection master;
|
||||
DROP TABLE tmyisam;
|
||||
DROP TABLE tinnodb;
|
||||
|
||||
connection slave;
|
||||
DROP TABLE tmyisam;
|
||||
DROP TABLE tinnodb;
|
56
mysql-test/t/rpl_user.test
Normal file
56
mysql-test/t/rpl_user.test
Normal file
|
@ -0,0 +1,56 @@
|
|||
# BUG#33862 completely failed DROP USER statement gets replicated
|
||||
|
||||
--source include/master-slave.inc
|
||||
|
||||
reset master;
|
||||
|
||||
#
|
||||
# remove all users will be used in the test
|
||||
#
|
||||
delete from mysql.user where Host='fakehost';
|
||||
sync_slave_with_master;
|
||||
|
||||
#
|
||||
# Test create user
|
||||
#
|
||||
connection master;
|
||||
create user 'foo'@'fakehost';
|
||||
--error ER_CANNOT_USER
|
||||
create user 'foo'@'fakehost', 'bar'@'fakehost';
|
||||
--error ER_CANNOT_USER
|
||||
create user 'foo'@'fakehost', 'bar'@'fakehost';
|
||||
|
||||
sync_slave_with_master;
|
||||
select Host,User from mysql.user where Host='fakehost';
|
||||
|
||||
#
|
||||
# Test rename user
|
||||
#
|
||||
connection master;
|
||||
rename user 'foo'@'fakehost' to 'foofoo'@'fakehost';
|
||||
--error ER_CANNOT_USER
|
||||
rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost';
|
||||
--error ER_CANNOT_USER
|
||||
rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'not_exist_user2'@'fakehost' to 'barfoo'@'fakehost';
|
||||
|
||||
sync_slave_with_master;
|
||||
select Host,User from mysql.user where Host='fakehost';
|
||||
|
||||
#
|
||||
# Test drop user
|
||||
#
|
||||
connection master;
|
||||
drop user 'foofoo'@'fakehost';
|
||||
--error ER_CANNOT_USER
|
||||
drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost';
|
||||
--error ER_CANNOT_USER
|
||||
drop user 'not_exist_user1'@'fakehost', 'not_exist_user2'@'fakehost';
|
||||
|
||||
sync_slave_with_master;
|
||||
select Host,User from mysql.user where Host='fakehost';
|
||||
|
||||
#
|
||||
# show the binlog events on the master
|
||||
#
|
||||
connection master;
|
||||
source include/show_binlog_events.inc;
|
100
sql/log.cc
100
sql/log.cc
|
@ -122,6 +122,20 @@ static int binlog_prepare(THD *thd, bool all)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
This function is called once after each statement.
|
||||
|
||||
It has the responsibility to flush the transaction cache to the
|
||||
binlog file on commits.
|
||||
|
||||
@param thd The client thread that executes the transaction.
|
||||
@param all true if this is the last statement before a COMMIT
|
||||
statement; false if either this is a statement in a
|
||||
transaction but not the last, or if this is a statement
|
||||
not inside a BEGIN block and autocommit is on.
|
||||
|
||||
@see handlerton::commit
|
||||
*/
|
||||
static int binlog_commit(THD *thd, bool all)
|
||||
{
|
||||
IO_CACHE *trans_log= (IO_CACHE*)thd->ha_data[binlog_hton.slot];
|
||||
|
@ -134,7 +148,15 @@ static int binlog_commit(THD *thd, bool all)
|
|||
// we're here because trans_log was flushed in MYSQL_LOG::log_xid()
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
if (all)
|
||||
/*
|
||||
Write commit event if at least one of the following holds:
|
||||
- the user sends an explicit COMMIT; or
|
||||
- the autocommit flag is on, and we are not inside a BEGIN.
|
||||
However, if the user has not sent an explicit COMMIT, and we are
|
||||
either inside a BEGIN or run with autocommit off, then this is not
|
||||
the end of a transaction and we should not write a commit event.
|
||||
*/
|
||||
if (all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
|
||||
{
|
||||
Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE);
|
||||
qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
|
||||
|
@ -144,6 +166,22 @@ static int binlog_commit(THD *thd, bool all)
|
|||
DBUG_RETURN(binlog_end_trans(thd, trans_log, &invisible_commit));
|
||||
}
|
||||
|
||||
/**
|
||||
This function is called when a transaction involving a transactional
|
||||
table is rolled back.
|
||||
|
||||
It has the responsibility to flush the transaction cache to the
|
||||
binlog file. However, if the transaction does not involve
|
||||
non-transactional tables, nothing needs to be logged.
|
||||
|
||||
@param thd The client thread that executes the transaction.
|
||||
@param all true if this is the last statement before a COMMIT
|
||||
statement; false if either this is a statement in a
|
||||
transaction but not the last, or if this is a statement
|
||||
not inside a BEGIN block and autocommit is on.
|
||||
|
||||
@see handlerton::rollback
|
||||
*/
|
||||
static int binlog_rollback(THD *thd, bool all)
|
||||
{
|
||||
int error=0;
|
||||
|
@ -1817,9 +1855,11 @@ uint MYSQL_LOG::next_file_id()
|
|||
IMPLEMENTATION
|
||||
- To support transaction over replication, we wrap the transaction
|
||||
with BEGIN/COMMIT or BEGIN/ROLLBACK in the binary log.
|
||||
We want to write a BEGIN/ROLLBACK block when a non-transactional table
|
||||
was updated in a transaction which was rolled back. This is to ensure
|
||||
that the same updates are run on the slave.
|
||||
If a transaction that only involves transactional tables is
|
||||
rolled back, we do not binlog it. However, we write a
|
||||
BEGIN/ROLLBACK block when a non-transactional table was updated
|
||||
in a transaction which was rolled back. This is to ensure that
|
||||
the same updates are run on the slave.
|
||||
*/
|
||||
|
||||
bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event)
|
||||
|
@ -1837,32 +1877,34 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event)
|
|||
byte header[LOG_EVENT_HEADER_LEN];
|
||||
|
||||
/*
|
||||
Log "BEGIN" at the beginning of the transaction.
|
||||
which may contain more than 1 SQL statement.
|
||||
Log "BEGIN" at the beginning of every transaction. Here, a
|
||||
transaction is either a BEGIN..COMMIT block or a single
|
||||
statement in autocommit mode.
|
||||
*/
|
||||
if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
|
||||
{
|
||||
Query_log_event qinfo(thd, STRING_WITH_LEN("BEGIN"), TRUE, FALSE);
|
||||
/*
|
||||
Imagine this is rollback due to net timeout, after all statements of
|
||||
the transaction succeeded. Then we want a zero-error code in BEGIN.
|
||||
In other words, if there was a really serious error code it's already
|
||||
in the statement's events, there is no need to put it also in this
|
||||
internally generated event, and as this event is generated late it
|
||||
would lead to false alarms.
|
||||
This is safer than thd->clear_error() against kills at shutdown.
|
||||
*/
|
||||
qinfo.error_code= 0;
|
||||
/*
|
||||
Now this Query_log_event has artificial log_pos 0. It must be adjusted
|
||||
to reflect the real position in the log. Not doing it would confuse the
|
||||
slave: it would prevent this one from knowing where he is in the
|
||||
master's binlog, which would result in wrong positions being shown to
|
||||
the user, MASTER_POS_WAIT undue waiting etc.
|
||||
*/
|
||||
if (qinfo.write(&log_file))
|
||||
goto err;
|
||||
}
|
||||
Query_log_event qinfo(thd, STRING_WITH_LEN("BEGIN"), TRUE, FALSE);
|
||||
/*
|
||||
Imagine this is rollback due to net timeout, after all
|
||||
statements of the transaction succeeded. Then we want a
|
||||
zero-error code in BEGIN. In other words, if there was a
|
||||
really serious error code it's already in the statement's
|
||||
events, there is no need to put it also in this internally
|
||||
generated event, and as this event is generated late it would
|
||||
lead to false alarms.
|
||||
|
||||
This is safer than thd->clear_error() against kills at shutdown.
|
||||
*/
|
||||
qinfo.error_code= 0;
|
||||
/*
|
||||
Now this Query_log_event has artificial log_pos 0. It must be
|
||||
adjusted to reflect the real position in the log. Not doing it
|
||||
would confuse the slave: it would prevent this one from
|
||||
knowing where he is in the master's binlog, which would result
|
||||
in wrong positions being shown to the user, MASTER_POS_WAIT
|
||||
undue waiting etc.
|
||||
*/
|
||||
if (qinfo.write(&log_file))
|
||||
goto err;
|
||||
|
||||
/* Read from the file used to cache the queries .*/
|
||||
if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
|
||||
goto err;
|
||||
|
|
|
@ -3793,6 +3793,7 @@ Xid_log_event(const char* buf,
|
|||
#ifndef MYSQL_CLIENT
|
||||
bool Xid_log_event::write(IO_CACHE* file)
|
||||
{
|
||||
DBUG_EXECUTE_IF("do_not_write_xid", return 0;);
|
||||
return write_header(file, sizeof(xid)) ||
|
||||
my_b_safe_write(file, (byte*) &xid, sizeof(xid));
|
||||
}
|
||||
|
|
|
@ -1449,6 +1449,7 @@ static void fix_trans_mem_root(THD *thd, enum_var_type type)
|
|||
static void fix_server_id(THD *thd, enum_var_type type)
|
||||
{
|
||||
server_id_supplied = 1;
|
||||
thd->server_id= server_id;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3348,7 +3348,10 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
|
|||
if (rli->slave_skip_counter &&
|
||||
!((type_code == INTVAR_EVENT ||
|
||||
type_code == RAND_EVENT ||
|
||||
type_code == USER_VAR_EVENT) &&
|
||||
type_code == USER_VAR_EVENT ||
|
||||
type_code == BEGIN_LOAD_QUERY_EVENT ||
|
||||
type_code == APPEND_BLOCK_EVENT ||
|
||||
type_code == CREATE_FILE_EVENT) &&
|
||||
rli->slave_skip_counter == 1) &&
|
||||
#if MYSQL_VERSION_ID < 50100
|
||||
/*
|
||||
|
|
|
@ -5333,6 +5333,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
|
|||
LEX_USER *user_name, *tmp_user_name;
|
||||
List_iterator <LEX_USER> user_list(list);
|
||||
TABLE_LIST tables[GRANT_TABLES];
|
||||
bool some_users_created= FALSE;
|
||||
DBUG_ENTER("mysql_create_user");
|
||||
|
||||
/* CREATE USER may be skipped on replication client. */
|
||||
|
@ -5361,6 +5362,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
|
|||
continue;
|
||||
}
|
||||
|
||||
some_users_created= TRUE;
|
||||
sql_mode= thd->variables.sql_mode;
|
||||
if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0))
|
||||
{
|
||||
|
@ -5371,7 +5373,10 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
|
|||
|
||||
VOID(pthread_mutex_unlock(&acl_cache->lock));
|
||||
|
||||
if (mysql_bin_log.is_open())
|
||||
if (result)
|
||||
my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
|
||||
|
||||
if (some_users_created && mysql_bin_log.is_open())
|
||||
{
|
||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
|
||||
mysql_bin_log.write(&qinfo);
|
||||
|
@ -5379,8 +5384,6 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list)
|
|||
|
||||
rw_unlock(&LOCK_grant);
|
||||
close_thread_tables(thd);
|
||||
if (result)
|
||||
my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
|
@ -5405,6 +5408,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
|
|||
LEX_USER *user_name, *tmp_user_name;
|
||||
List_iterator <LEX_USER> user_list(list);
|
||||
TABLE_LIST tables[GRANT_TABLES];
|
||||
bool some_users_deleted= FALSE;
|
||||
DBUG_ENTER("mysql_drop_user");
|
||||
|
||||
/* DROP USER may be skipped on replication client. */
|
||||
|
@ -5426,7 +5430,9 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
|
|||
{
|
||||
append_user(&wrong_users, user_name);
|
||||
result= TRUE;
|
||||
continue;
|
||||
}
|
||||
some_users_deleted= TRUE;
|
||||
}
|
||||
|
||||
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
|
||||
|
@ -5440,7 +5446,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
|
|||
DBUG_PRINT("info", ("thd->net.last_errno: %d", thd->net.last_errno));
|
||||
DBUG_PRINT("info", ("thd->net.last_error: %s", thd->net.last_error));
|
||||
|
||||
if (mysql_bin_log.is_open())
|
||||
if (some_users_deleted && mysql_bin_log.is_open())
|
||||
{
|
||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
|
||||
mysql_bin_log.write(&qinfo);
|
||||
|
@ -5473,6 +5479,7 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
|
|||
LEX_USER *user_to, *tmp_user_to;
|
||||
List_iterator <LEX_USER> user_list(list);
|
||||
TABLE_LIST tables[GRANT_TABLES];
|
||||
bool some_users_renamed= FALSE;
|
||||
DBUG_ENTER("mysql_rename_user");
|
||||
|
||||
/* RENAME USER may be skipped on replication client. */
|
||||
|
@ -5506,7 +5513,9 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
|
|||
{
|
||||
append_user(&wrong_users, user_from);
|
||||
result= TRUE;
|
||||
continue;
|
||||
}
|
||||
some_users_renamed= TRUE;
|
||||
}
|
||||
|
||||
/* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
|
||||
|
@ -5514,7 +5523,10 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
|
|||
|
||||
VOID(pthread_mutex_unlock(&acl_cache->lock));
|
||||
|
||||
if (mysql_bin_log.is_open())
|
||||
if (result)
|
||||
my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
|
||||
|
||||
if (some_users_renamed && mysql_bin_log.is_open())
|
||||
{
|
||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
|
||||
mysql_bin_log.write(&qinfo);
|
||||
|
@ -5522,8 +5534,6 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
|
|||
|
||||
rw_unlock(&LOCK_grant);
|
||||
close_thread_tables(thd);
|
||||
if (result)
|
||||
my_error(ER_CANNOT_USER, MYF(0), "RENAME USER", wrong_users.c_ptr_safe());
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -2067,7 +2067,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
|||
unregister_slave(thd,1,1);
|
||||
/* fake COM_QUIT -- if we get here, the thread needs to terminate */
|
||||
error = TRUE;
|
||||
net->error = 0;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1229,9 +1229,6 @@ bool change_master(THD* thd, MASTER_INFO* mi)
|
|||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
mi->rli.group_master_log_pos = mi->master_log_pos;
|
||||
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
|
||||
|
||||
/*
|
||||
Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block,
|
||||
so restore them to good values. If we left them to ''/0, that would work;
|
||||
|
@ -1243,6 +1240,7 @@ bool change_master(THD* thd, MASTER_INFO* mi)
|
|||
That's why we always save good coords in rli.
|
||||
*/
|
||||
mi->rli.group_master_log_pos= mi->master_log_pos;
|
||||
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
|
||||
strmake(mi->rli.group_master_log_name,mi->master_log_name,
|
||||
sizeof(mi->rli.group_master_log_name)-1);
|
||||
|
||||
|
@ -1355,6 +1353,11 @@ bool mysql_show_binlog_events(THD* thd)
|
|||
if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0)
|
||||
goto err;
|
||||
|
||||
/*
|
||||
to account binlog event header size
|
||||
*/
|
||||
thd->variables.max_allowed_packet += MAX_LOG_EVENT_HEADER;
|
||||
|
||||
pthread_mutex_lock(log_lock);
|
||||
|
||||
/*
|
||||
|
@ -1365,7 +1368,6 @@ bool mysql_show_binlog_events(THD* thd)
|
|||
This code will fail on a mixed relay log (one which has Format_desc then
|
||||
Rotate then Format_desc).
|
||||
*/
|
||||
|
||||
ev = Log_event::read_log_event(&log,(pthread_mutex_t*)0,description_event);
|
||||
if (ev)
|
||||
{
|
||||
|
@ -1556,37 +1558,52 @@ err:
|
|||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Load data's io cache specific hook to be executed
|
||||
before a chunk of data is being read into the cache's buffer
|
||||
The fuction instantianates and writes into the binlog
|
||||
replication events along LOAD DATA processing.
|
||||
|
||||
@param file pointer to io-cache
|
||||
@return 0
|
||||
*/
|
||||
int log_loaded_block(IO_CACHE* file)
|
||||
{
|
||||
DBUG_ENTER("log_loaded_block");
|
||||
LOAD_FILE_INFO *lf_info;
|
||||
uint block_len ;
|
||||
|
||||
/* file->request_pos contains position where we started last read */
|
||||
char* buffer = (char*) file->request_pos;
|
||||
if (!(block_len = (char*) file->read_end - (char*) buffer))
|
||||
return 0;
|
||||
lf_info = (LOAD_FILE_INFO*) file->arg;
|
||||
uint block_len;
|
||||
/* buffer contains position where we started last read */
|
||||
char* buffer= my_b_get_buffer_start(file);
|
||||
uint max_event_size= current_thd->variables.max_allowed_packet;
|
||||
lf_info= (LOAD_FILE_INFO*) file->arg;
|
||||
if (lf_info->last_pos_in_file != HA_POS_ERROR &&
|
||||
lf_info->last_pos_in_file >= file->pos_in_file)
|
||||
return 0;
|
||||
lf_info->last_pos_in_file = file->pos_in_file;
|
||||
if (lf_info->wrote_create_file)
|
||||
lf_info->last_pos_in_file >= my_b_get_pos_in_file(file))
|
||||
DBUG_RETURN(0);
|
||||
|
||||
for (block_len= my_b_get_bytes_in_buffer(file); block_len > 0;
|
||||
buffer += min(block_len, max_event_size),
|
||||
block_len -= min(block_len, max_event_size))
|
||||
{
|
||||
Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
|
||||
block_len, lf_info->log_delayed);
|
||||
mysql_bin_log.write(&a);
|
||||
lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
|
||||
if (lf_info->wrote_create_file)
|
||||
{
|
||||
Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
|
||||
min(block_len, max_event_size),
|
||||
lf_info->log_delayed);
|
||||
mysql_bin_log.write(&a);
|
||||
}
|
||||
else
|
||||
{
|
||||
Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
|
||||
buffer,
|
||||
min(block_len, max_event_size),
|
||||
lf_info->log_delayed);
|
||||
mysql_bin_log.write(&b);
|
||||
lf_info->wrote_create_file= 1;
|
||||
DBUG_SYNC_POINT("debug_lock.created_file_event",10);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
|
||||
buffer, block_len,
|
||||
lf_info->log_delayed);
|
||||
mysql_bin_log.write(&b);
|
||||
lf_info->wrote_create_file = 1;
|
||||
DBUG_SYNC_POINT("debug_lock.created_file_event",10);
|
||||
}
|
||||
return 0;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
#endif /* HAVE_REPLICATION */
|
||||
|
|
Loading…
Reference in a new issue