We're updating the issue view to help you get more done.Learn more

Row-based triggers: Trigger is applied to the rows after first one

The test case below creates one trigger (after insert) on the master and another trigger (before insert) on the slave.
The master trigger writes into a different table. The slave trigger modifies the values on its own table (sets 2nd column := 1st column).

Here is the result of the test case on slave:

a	b
1	10
2	2
3	3

That is, the first row is not updated, while the other two are.

Test case:

--source include/master-slave.inc
--source include/have_binlog_format_row.inc

--connection master

create table t1 (a int, b int);
create table tlog (a int);

set sql_log_bin=0;
create trigger tr1 after insert on t1 for each row insert into tlog values (1);
set sql_log_bin=1;

--connection slave

set @slave_run_triggers_for_rbr.saved = @@slave_run_triggers_for_rbr;
set global slave_run_triggers_for_rbr=1;
create trigger tr2 before insert on t1 for each row set new.b = new.a;

--connection master

insert into t1 values (1,10),(2,20),(3,30);


select * from t1;

# Cleanup 

set global slave_run_triggers_for_rbr = @slave_run_triggers_for_rbr.saved;

--connection master

drop table t1, tlog;

--source include/rpl_end.inc
revision-id: sanja@askmonty.org-20140108131630-9am80xd8lbr9witb
revno: 3916
branch-nick: 10.0-mdev5095-sanja