1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-26 01:44:06 +03:00
Files
mariadb/mysql-test/suite/rpl/t/rpl_auto_increment_update_failure.test
Sven Sandberg 09c80e12c5 BUG#49978: Replication tests don't clean up replication state at the end
Major replication test framework cleanup. This does the following:
 - Ensure that all tests clean up the replication state when they
   finish, by making check-testcase check the output of SHOW SLAVE STATUS.
   This implies:
    - Slave must not be running after test finished. This is good
      because it removes the risk for sporadic errors in subsequent
      tests when a test forgets to sync correctly.
    - Slave SQL and IO errors must be cleared when test ends. This is
      good because we will notice if a test gets an unexpected error in
      the slave threads near the end.
    - We no longer have to clean up before a test starts.
 - Ensure that all tests that wait for an error in one of the slave
   threads waits for a specific error. It is no longer possible to
   source wait_for_slave_[sql|io]_to_stop.inc when there is an error
   in one of the slave threads. This is good because:
    - If a test expects an error but there is a bug that causes
      another error to happen, or if it stops the slave thread without
      an error, then we will notice.
    - When developing tests, wait_for_*_to_[start|stop].inc will fail
      immediately if there is an error in the relevant slave thread.
      Before this patch, we had to wait for the timeout.
 - Remove duplicated and repeated code for setting up unusual replication
   topologies. Now, there is a single file that is capable of setting
   up arbitrary topologies (include/rpl_init.inc, but
   include/master-slave.inc is still available for the most common
   topology). Tests can now end with include/rpl_end.inc, which will clean
   up correctly no matter what topology is used. The topology can be
   changed with include/rpl_change_topology.inc.
 - Improved debug information when tests fail. This includes:
    - debug info is printed on all servers configured by include/rpl_init.inc
    - User can set $rpl_debug=1, which makes auxiliary replication files
      print relevant debug info.
 - Improved documentation for all auxiliary replication files. Now they
   describe purpose, usage, parameters, and side effects.
 - Many small code cleanups:
    - Made have_innodb.inc output a sensible error message.
    - Moved contents of rpl000017-slave.sh into rpl000017.test
    - Added mysqltest variables that expose the current state of
      disable_warnings/enable_warnings and friends.
    - Too many to list here: see per-file comments for details.
2010-12-19 18:07:28 +01:00

212 lines
7.1 KiB
Plaintext

#
# Bug45677
# This test verifies the following two properties:
# P1) insert/update in an autoinc column causes statement to
# be logged in row format if binlog_format=mixed.
# P2) if binlog_format=mixed, and a trigger or function contains
# two or more inserts/updates in a table that has an autoinc
# column, then the slave should not go out of sync, even if
# there are concurrent transactions.
#
# Property (P1) is tested by executing an insert and an update on
# a table that has an autoinc column, and verifying that these
# statements result in row events in the binlog.
# Property (P2) is tested by setting up the test scenario and
# verifying that the tables are identical on master and slave.
#
source include/have_binlog_format_mixed.inc;
source include/have_innodb.inc;
source include/master-slave.inc;
--echo # Test case1: INVOKES A TRIGGER with after insert action
let $trigger_action = after insert;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case2: INVOKES A TRIGGER with before insert action
let $trigger_action = before insert;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case3: INVOKES A TRIGGER with after update action
let $trigger_action = after update;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case4: INVOKES A TRIGGER with before update action
let $trigger_action = before update;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case5: INVOKES A TRIGGER with after delete action
let $trigger_action = after delete;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case6: INVOKES A TRIGGER with before delete action
let $trigger_action = before delete;
source extra/rpl_tests/rpl_auto_increment_invoke_trigger.test;
--echo # Test case7: CALLS A FUNCTION which INVOKES A TRIGGER with after insert action
let $insert_action = after insert;
source extra/rpl_tests/rpl_autoinc_func_invokes_trigger.test;
--echo # Test case8: CALLS A FUNCTION which INVOKES A TRIGGER with before insert action
let $insert_action = before insert;
source extra/rpl_tests/rpl_autoinc_func_invokes_trigger.test;
--echo # Test case9: INSERT DATA INTO VIEW WHICH INVOKES TRIGGERS with after insert action
let $insert_action = after insert;
source extra/rpl_tests/rpl_auto_increment_insert_view.test;
--echo # Test case10: INSERT DATA INTO VIEW WHICH INVOKES TRIGGERS with before insert action
let $insert_action = before insert;
source extra/rpl_tests/rpl_auto_increment_insert_view.test;
--echo # Test case11: INVOKES A FUNCTION TO INSERT TWO OR MORE VALUES INTO A TABLE WITH AUTOINC COLUMN
connection master;
create table t1(a int) engine=innodb;
create table t2(i1 int not null auto_increment, a int, primary key(i1)) engine=innodb;
delimiter //;
CREATE FUNCTION f1_two_inserts() RETURNS INTEGER
BEGIN
INSERT INTO t2(a) values(2);
INSERT INTO t2(a) values(2);
RETURN 1;
END//
delimiter ;//
begin;
insert into t1(a) values(f1_two_inserts());
connection master1;
#The default autocommit is set to 1, so the statement is auto committed
insert into t2(a) values(4),(5);
connection master;
commit;
insert into t1(a) values(f1_two_inserts());
commit;
connection master;
--echo #Test result for INVOKES A FUNCTION TO INSERT TWO OR MORE VALUES on master
select * from t2 ORDER BY i1;
sync_slave_with_master;
connection slave;
--echo #Test result for INVOKES A FUNCTION TO INSERT TWO OR MORE VALUES on slave
select * from t2 ORDER BY i1;
connection master;
drop table t1;
drop table t2;
drop function f1_two_inserts;
sync_slave_with_master;
--echo # Test case12: INVOKES A FUNCTION TO UPDATE TWO OR MORE VALUES OF A TABLE WITH AUTOINC COLUMN
connection master;
create table t1(a int) engine=innodb;
create table t2(i1 int not null auto_increment, a int, b int, primary key(i1)) engine=innodb;
delimiter //;
CREATE FUNCTION f1_two_updates() RETURNS INTEGER
BEGIN
update t2 set a = a + 5 where b = 1;
update t2 set a = a + 5 where b = 2;
update t2 set a = a + 5 where b = 3;
update t2 set a = a + 5 where b = 4;
RETURN 1;
END//
delimiter ;//
connection master1;
#The default autocommit is set to 1, so the statement is auto committed
insert into t2(a,b) values(1,1);
insert into t2(a,b) values(2,2);
insert into t2(a,b) values(3,3);
insert into t2(a,b) values(4,4);
insert into t1(a) values(f1_two_updates());
connection master;
begin;
insert into t1(a) values(f1_two_updates());
commit;
connection master;
--echo #Test result for INVOKES A FUNCTION TO UPDATE TWO OR MORE VALUES on master
select * from t2 ORDER BY i1;
sync_slave_with_master;
connection slave;
--echo #Test result for INVOKES A FUNCTION TO UPDATE TWO OR MORE VALUES on slave
select * from t2 ORDER BY i1;
connection master;
drop table t1;
drop table t2;
drop function f1_two_updates;
sync_slave_with_master;
--echo # Test case13: UPDATE MORE THAN ONE TABLES ON TOP-STATEMENT
connection master;
create table t1(i1 int not null auto_increment, a int, b int, primary key(i1)) engine=innodb;
create table t2(i1 int not null auto_increment, a int, b int, primary key(i1)) engine=innodb;
begin;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
insert into t1(a,b) values(1,1),(2,2);
insert into t2(a,b) values(1,1),(2,2);
update t1,t2 set t1.a=t1.a+5, t2.a=t2.a+5 where t1.b=t2.b;
insert into t1(a,b) values(3,3);
insert into t2(a,b) values(3,3);
commit;
--echo # To verify if it works fine when these statements are not be marked as unsafe
source include/show_binlog_events.inc;
sync_slave_with_master;
--echo #Test if the results are consistent on master and slave
--echo #for 'UPDATE MORE THAN ONE TABLES ON TOP-STATEMENT'
let $diff_tables= master:t1, slave:t1;
source include/diff_tables.inc;
let $diff_tables= master:t2, slave:t2;
source include/diff_tables.inc;
connection master;
drop table t1;
drop table t2;
sync_slave_with_master;
--echo # Test case14: INSERT DATA INTO VIEW WHICH INVOLVED MORE THAN ONE TABLES
connection master;
CREATE TABLE t1(i1 int not null auto_increment, c1 INT, primary key(i1)) engine=innodb;
CREATE TABLE t2(i1 int not null auto_increment, c2 INT, primary key(i1)) engine=innodb;
let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
begin;
INSERT INTO t1(c1) VALUES (11), (12);
INSERT INTO t2(c2) VALUES (13), (14);
CREATE VIEW v15 AS SELECT c1, c2 FROM t1, t2;
INSERT INTO v15(c1) VALUES (15),(16);
INSERT INTO v15(c2) VALUES (17),(18);
connection master1;
INSERT INTO v15(c1) VALUES (19),(20);
INSERT INTO v15(c2) VALUES (21),(22);
connection master;
INSERT INTO v15(c1) VALUES (23), (24);
INSERT INTO v15(c2) VALUES (25), (26);
commit;
--echo # To verify if it works fine when these statements are not be marked as unsafe
source include/show_binlog_events.inc;
sync_slave_with_master;
--echo #Test if the results are consistent on master and slave
--echo #for 'INSERT DATA INTO VIEW WHICH INVOLVED MORE THAN ONE TABLES'
let $diff_tables= master:t1, slave:t1;
source include/diff_tables.inc;
let $diff_tables= master:t2, slave:t2;
source include/diff_tables.inc;
connection master;
drop table t1;
drop table t2;
drop view v15;
sync_slave_with_master;
--source include/rpl_end.inc