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

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

Description

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:

1 2 3 4 a b 1 10 2 2 3 3

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

Test case:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 --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); --sync_slave_with_master 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
1 2 3 4 revision-id: sanja@askmonty.org-20140108131630-9am80xd8lbr9witb revno: 3916 branch-nick: 10.0-mdev5095-sanja BUILD/compile-pentium-debug-max-no-ndb

Environment

None

Status

Assignee

Oleksandr Byelkin

Reporter

Elena Stepanova

Fix versions

Priority

Major