| 1 |
# |
| 2 |
# This test verifies if concurrent transactions that call a |
| 3 |
# function which invokes a 'after/before insert action' trigger |
| 4 |
# that inserts more than one values into a table with autoinc |
| 5 |
# column will make the autoinc values become inconsistent on |
| 6 |
# master and slave. |
| 7 |
# |
| 8 |
|
| 9 |
connection master; |
| 10 |
create table t1(a int) engine=innodb; |
| 11 |
create table t2(i1 int not null auto_increment, a int, primary key(i1)) engine=innodb; |
| 12 |
create table t3(i1 int not null auto_increment, a int, primary key(i1)) engine=innodb; |
| 13 |
delimiter |; |
| 14 |
CREATE FUNCTION f1_two_inserts_trigger() RETURNS INTEGER |
| 15 |
BEGIN |
| 16 |
INSERT INTO t2(a) values(2),(3); |
| 17 |
INSERT INTO t2(a) values(2),(3); |
| 18 |
RETURN 1; |
| 19 |
END | |
| 20 |
eval create trigger tr11 $insert_action on t2 for each row begin |
| 21 |
insert into t3(a) values(new.a); |
| 22 |
insert into t3(a) values(new.a); |
| 23 |
end | |
| 24 |
delimiter ;| |
| 25 |
begin; |
| 26 |
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1); |
| 27 |
insert into t1(a) values(f1_two_inserts_trigger()); |
| 28 |
|
| 29 |
connection master1; |
| 30 |
#The default autocommit is set to 1, so the statement is auto committed |
| 31 |
insert into t2(a) values(4),(5); |
| 32 |
|
| 33 |
connection master; |
| 34 |
commit; |
| 35 |
insert into t1(a) values(f1_two_inserts_trigger()); |
| 36 |
--echo # To verify if insert/update in an autoinc column causes statement to be logged in row format |
| 37 |
source include/show_binlog_events.inc; |
| 38 |
commit; |
| 39 |
|
| 40 |
connection master; |
| 41 |
sync_slave_with_master; |
| 42 |
--echo #Test if the results are consistent on master and slave |
| 43 |
--echo #for 'CALLS A FUNCTION which INVOKES A TRIGGER with $insert_action action' |
| 44 |
let $diff_tables= master:t2, slave:t2; |
| 45 |
source include/diff_tables.inc; |
| 46 |
let $diff_tables= master:t3, slave:t3; |
| 47 |
source include/diff_tables.inc; |
| 48 |
|
| 49 |
connection master; |
| 50 |
drop table t1; |
| 51 |
drop table t2; |
| 52 |
drop table t3; |
| 53 |
drop function f1_two_inserts_trigger; |
| 54 |
sync_slave_with_master; |
| 55 |
|