Loading include/my_sys.h +1 −1 Original line number Diff line number Diff line Loading @@ -587,7 +587,7 @@ extern gptr _my_memdup(const byte *from,uint length, const char *sFile, uint uLine,myf MyFlag); extern my_string _my_strdup(const char *from, const char *sFile, uint uLine, myf MyFlag); extern char *_my_strndup(const byte *from, uint length, extern char *_my_strndup(const char *from, uint length, const char *sFile, uint uLine, myf MyFlag); Loading mysql-test/extra/binlog_tests/binlog.test +32 −0 Original line number Diff line number Diff line Loading @@ -49,3 +49,35 @@ show binlog events in 'master-bin.000001' from 102; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events in 'master-bin.000002' from 102; # Test of a too big SET INSERT_ID: see if the truncated value goes # into binlog (right), or the too big value (wrong); we look at the # binlog further down with SHOW BINLOG EVENTS. reset master; create table t1 (id tinyint auto_increment primary key); set insert_id=128; insert into t1 values(null); select * from t1; drop table t1; # Test of binlogging of INSERT_ID with INSERT DELAYED create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; # First, avoid BUG#20627: set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1; # Verify that only one INSERT_ID event is binlogged. insert delayed into t1 values (207); # We use sleeps between statements, that's the only way to get a # repeatable binlog in a normal test run and under Valgrind. # It may be that the "binlog missing rows" of BUG#20821 shows up # here. sleep 2; insert delayed into t1 values (null); sleep 2; insert delayed into t1 values (300); sleep 2; # time for the delayed queries to reach disk select * from t1; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; drop table t1; mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test +14 −13 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ insert into t1 values(1); insert into t2 select * from t1; commit; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -43,7 +43,7 @@ insert into t2 select * from t1; # should say some changes to non-transact1onal tables couldn't be rolled back rollback; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -59,7 +59,7 @@ insert into t2 select * from t1; rollback to savepoint my_savepoint; commit; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -77,7 +77,7 @@ insert into t1 values(7); commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -99,7 +99,7 @@ connection con2; # so SHOW BINLOG EVENTS may come before con1 does the loggin. To be sure that # logging has been done, we use a user lock. select get_lock("a",10); --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -111,7 +111,7 @@ reset master; insert into t1 values(9); insert into t2 select * from t1; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -124,13 +124,13 @@ reset master; insert into t1 values(10); # first make t1 non-empty begin; insert into t2 select * from t1; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; insert into t1 values(11); commit; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -149,7 +149,7 @@ insert into t1 values(12); insert into t2 select * from t1; commit; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -162,7 +162,7 @@ insert into t1 values(13); insert into t2 select * from t1; rollback; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -178,7 +178,7 @@ insert into t2 select * from t1; rollback to savepoint my_savepoint; commit; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -196,7 +196,7 @@ insert into t1 values(18); commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading Loading @@ -257,7 +257,7 @@ insert into t2 values (3); disconnect con2; connection con3; select get_lock("lock1",60); --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; do release_lock("lock1"); Loading Loading @@ -324,6 +324,7 @@ CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * ROLLBACK; SELECT * from t2; DROP TABLE t1,t2; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading mysql-test/extra/rpl_tests/rpl_auto_increment.test +39 −1 Original line number Diff line number Diff line Loading @@ -104,9 +104,47 @@ select * from t1; sync_slave_with_master; select * from t1; connection master; # Test for BUG#20524 "auto_increment_* not observed when inserting # a too large value". When an autogenerated value was bigger than the # maximum possible value of the field, it was truncated to that max # possible value, without being "rounded down" to still honour # auto_increment_* variables. connection master; drop table t1; create table t1 (a tinyint not null auto_increment primary key) engine=myisam; insert into t1 values(103); set auto_increment_increment=11; set auto_increment_offset=4; insert into t1 values(null); insert into t1 values(null); --error 1062 insert into t1 values(null); select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t1 order by a; # same but with a larger value create table t2 (a tinyint unsigned not null auto_increment primary key) engine=myisam; set auto_increment_increment=10; set auto_increment_offset=1; set insert_id=1000; insert into t2 values(null); select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t2 order by a; # An offset so big that even first value does not fit create table t3 like t1; set auto_increment_increment=1000; set auto_increment_offset=700; insert into t3 values(null); select * from t3 order by a; sync_slave_with_master; select * from t1 order by a; select * from t2 order by a; select * from t3 order by a; connection master; drop table t1,t2,t3; # End cleanup sync_slave_with_master; mysql-test/extra/rpl_tests/rpl_insert_id.test +117 −1 Original line number Diff line number Diff line Loading @@ -144,6 +144,23 @@ insert into t1 (last_id) values (bug15728()); # This should be exactly one greater than in the previous call. select last_insert_id(); # BUG#20339 - stored procedure using LAST_INSERT_ID() does not # replicate statement-based --disable_warnings drop procedure if exists foo; --enable_warnings delimiter |; create procedure foo() begin declare res int; insert into t2 (last_id) values (bug15728()); insert into t1 (last_id) values (bug15728()); end| delimiter ;| call foo(); select * from t1; select * from t2; save_master_pos; connection slave; sync_with_master; Loading @@ -153,8 +170,107 @@ connection master; drop function bug15728; drop function bug15728_insert; drop table t1, t2; drop table t1; drop procedure foo; # test of BUG#20188 REPLACE or ON DUPLICATE KEY UPDATE in # auto_increment breaks binlog create table t1 (n int primary key auto_increment not null, b int, unique(b)); # First, test that we do not call restore_auto_increment() too early # in write_record(): set sql_log_bin=0; insert into t1 values(null,100); replace into t1 values(null,50),(null,100),(null,150); select * from t1 order by n; truncate table t1; set sql_log_bin=1; insert into t1 values(null,100); select * from t1 order by n; sync_slave_with_master; # make slave's table autoinc counter bigger insert into t1 values(null,200),(null,300); delete from t1 where b <> 100; # check that slave's table content is identical to master select * from t1 order by n; # only the auto_inc counter differs. connection master; replace into t1 values(null,100),(null,350); select * from t1 order by n; sync_slave_with_master; select * from t1 order by n; # Same test as for REPLACE, but for ON DUPLICATE KEY UPDATE # We first check that if we update a row using a value larger than the # table's counter, the counter for next row is bigger than the # after-value of the updated row. connection master; insert into t1 values (NULL,400),(3,500),(NULL,600) on duplicate key UPDATE n=1000; select * from t1 order by n; sync_slave_with_master; select * from t1 order by n; # and now test for the bug: connection master; drop table t1; create table t1 (n int primary key auto_increment not null, b int, unique(b)); insert into t1 values(null,100); select * from t1 order by n; sync_slave_with_master; insert into t1 values(null,200),(null,300); delete from t1 where b <> 100; select * from t1 order by n; connection master; insert into t1 values(null,100),(null,350) on duplicate key update n=2; select * from t1 order by n; sync_slave_with_master; select * from t1 order by n; connection master; drop table t1; # End of 5.0 tests # Test for BUG#20341 "stored function inserting into one # auto_increment puts bad data in slave" truncate table t2; create table t1 (id tinyint primary key); # no auto_increment delimiter |; create function insid() returns int begin insert into t2 (last_id) values (0); return 0; end| delimiter ;| set sql_log_bin=0; insert into t2 (id) values(1),(2),(3); delete from t2; set sql_log_bin=1; #inside SELECT, then inside INSERT select insid(); set sql_log_bin=0; insert into t2 (id) values(5),(6),(7); delete from t2 where id>=5; set sql_log_bin=1; insert into t1 select insid(); select * from t1; select * from t2; sync_slave_with_master; select * from t1; select * from t2; connection master; drop table t1, t2; drop function insid; sync_slave_with_master; Loading
include/my_sys.h +1 −1 Original line number Diff line number Diff line Loading @@ -587,7 +587,7 @@ extern gptr _my_memdup(const byte *from,uint length, const char *sFile, uint uLine,myf MyFlag); extern my_string _my_strdup(const char *from, const char *sFile, uint uLine, myf MyFlag); extern char *_my_strndup(const byte *from, uint length, extern char *_my_strndup(const char *from, uint length, const char *sFile, uint uLine, myf MyFlag); Loading
mysql-test/extra/binlog_tests/binlog.test +32 −0 Original line number Diff line number Diff line Loading @@ -49,3 +49,35 @@ show binlog events in 'master-bin.000001' from 102; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events in 'master-bin.000002' from 102; # Test of a too big SET INSERT_ID: see if the truncated value goes # into binlog (right), or the too big value (wrong); we look at the # binlog further down with SHOW BINLOG EVENTS. reset master; create table t1 (id tinyint auto_increment primary key); set insert_id=128; insert into t1 values(null); select * from t1; drop table t1; # Test of binlogging of INSERT_ID with INSERT DELAYED create table t1 (a int not null auto_increment, primary key (a)) engine=myisam; # First, avoid BUG#20627: set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1; # Verify that only one INSERT_ID event is binlogged. insert delayed into t1 values (207); # We use sleeps between statements, that's the only way to get a # repeatable binlog in a normal test run and under Valgrind. # It may be that the "binlog missing rows" of BUG#20821 shows up # here. sleep 2; insert delayed into t1 values (null); sleep 2; insert delayed into t1 values (300); sleep 2; # time for the delayed queries to reach disk select * from t1; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ show binlog events from 102; drop table t1;
mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test +14 −13 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ insert into t1 values(1); insert into t2 select * from t1; commit; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -43,7 +43,7 @@ insert into t2 select * from t1; # should say some changes to non-transact1onal tables couldn't be rolled back rollback; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -59,7 +59,7 @@ insert into t2 select * from t1; rollback to savepoint my_savepoint; commit; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -77,7 +77,7 @@ insert into t1 values(7); commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -99,7 +99,7 @@ connection con2; # so SHOW BINLOG EVENTS may come before con1 does the loggin. To be sure that # logging has been done, we use a user lock. select get_lock("a",10); --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -111,7 +111,7 @@ reset master; insert into t1 values(9); insert into t2 select * from t1; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -124,13 +124,13 @@ reset master; insert into t1 values(10); # first make t1 non-empty begin; insert into t2 select * from t1; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; insert into t1 values(11); commit; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -149,7 +149,7 @@ insert into t1 values(12); insert into t2 select * from t1; commit; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -162,7 +162,7 @@ insert into t1 values(13); insert into t2 select * from t1; rollback; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -178,7 +178,7 @@ insert into t2 select * from t1; rollback to savepoint my_savepoint; commit; --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading @@ -196,7 +196,7 @@ insert into t1 values(18); commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading Loading @@ -257,7 +257,7 @@ insert into t2 values (3); disconnect con2; connection con3; select get_lock("lock1",60); --replace_column 5 # --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; do release_lock("lock1"); Loading Loading @@ -324,6 +324,7 @@ CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) engine=innodb select * ROLLBACK; SELECT * from t2; DROP TABLE t1,t2; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// show binlog events from 102; Loading
mysql-test/extra/rpl_tests/rpl_auto_increment.test +39 −1 Original line number Diff line number Diff line Loading @@ -104,9 +104,47 @@ select * from t1; sync_slave_with_master; select * from t1; connection master; # Test for BUG#20524 "auto_increment_* not observed when inserting # a too large value". When an autogenerated value was bigger than the # maximum possible value of the field, it was truncated to that max # possible value, without being "rounded down" to still honour # auto_increment_* variables. connection master; drop table t1; create table t1 (a tinyint not null auto_increment primary key) engine=myisam; insert into t1 values(103); set auto_increment_increment=11; set auto_increment_offset=4; insert into t1 values(null); insert into t1 values(null); --error 1062 insert into t1 values(null); select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t1 order by a; # same but with a larger value create table t2 (a tinyint unsigned not null auto_increment primary key) engine=myisam; set auto_increment_increment=10; set auto_increment_offset=1; set insert_id=1000; insert into t2 values(null); select a, mod(a-@@auto_increment_offset,@@auto_increment_increment) from t2 order by a; # An offset so big that even first value does not fit create table t3 like t1; set auto_increment_increment=1000; set auto_increment_offset=700; insert into t3 values(null); select * from t3 order by a; sync_slave_with_master; select * from t1 order by a; select * from t2 order by a; select * from t3 order by a; connection master; drop table t1,t2,t3; # End cleanup sync_slave_with_master;
mysql-test/extra/rpl_tests/rpl_insert_id.test +117 −1 Original line number Diff line number Diff line Loading @@ -144,6 +144,23 @@ insert into t1 (last_id) values (bug15728()); # This should be exactly one greater than in the previous call. select last_insert_id(); # BUG#20339 - stored procedure using LAST_INSERT_ID() does not # replicate statement-based --disable_warnings drop procedure if exists foo; --enable_warnings delimiter |; create procedure foo() begin declare res int; insert into t2 (last_id) values (bug15728()); insert into t1 (last_id) values (bug15728()); end| delimiter ;| call foo(); select * from t1; select * from t2; save_master_pos; connection slave; sync_with_master; Loading @@ -153,8 +170,107 @@ connection master; drop function bug15728; drop function bug15728_insert; drop table t1, t2; drop table t1; drop procedure foo; # test of BUG#20188 REPLACE or ON DUPLICATE KEY UPDATE in # auto_increment breaks binlog create table t1 (n int primary key auto_increment not null, b int, unique(b)); # First, test that we do not call restore_auto_increment() too early # in write_record(): set sql_log_bin=0; insert into t1 values(null,100); replace into t1 values(null,50),(null,100),(null,150); select * from t1 order by n; truncate table t1; set sql_log_bin=1; insert into t1 values(null,100); select * from t1 order by n; sync_slave_with_master; # make slave's table autoinc counter bigger insert into t1 values(null,200),(null,300); delete from t1 where b <> 100; # check that slave's table content is identical to master select * from t1 order by n; # only the auto_inc counter differs. connection master; replace into t1 values(null,100),(null,350); select * from t1 order by n; sync_slave_with_master; select * from t1 order by n; # Same test as for REPLACE, but for ON DUPLICATE KEY UPDATE # We first check that if we update a row using a value larger than the # table's counter, the counter for next row is bigger than the # after-value of the updated row. connection master; insert into t1 values (NULL,400),(3,500),(NULL,600) on duplicate key UPDATE n=1000; select * from t1 order by n; sync_slave_with_master; select * from t1 order by n; # and now test for the bug: connection master; drop table t1; create table t1 (n int primary key auto_increment not null, b int, unique(b)); insert into t1 values(null,100); select * from t1 order by n; sync_slave_with_master; insert into t1 values(null,200),(null,300); delete from t1 where b <> 100; select * from t1 order by n; connection master; insert into t1 values(null,100),(null,350) on duplicate key update n=2; select * from t1 order by n; sync_slave_with_master; select * from t1 order by n; connection master; drop table t1; # End of 5.0 tests # Test for BUG#20341 "stored function inserting into one # auto_increment puts bad data in slave" truncate table t2; create table t1 (id tinyint primary key); # no auto_increment delimiter |; create function insid() returns int begin insert into t2 (last_id) values (0); return 0; end| delimiter ;| set sql_log_bin=0; insert into t2 (id) values(1),(2),(3); delete from t2; set sql_log_bin=1; #inside SELECT, then inside INSERT select insid(); set sql_log_bin=0; insert into t2 (id) values(5),(6),(7); delete from t2 where id>=5; set sql_log_bin=1; insert into t1 select insid(); select * from t1; select * from t2; sync_slave_with_master; select * from t1; select * from t2; connection master; drop table t1, t2; drop function insid; sync_slave_with_master;