When the SELECT sub-statement executes a stored function that is defined
to modify a non-transactional table any modified records that the function has succeeded
on must be binlogged (as a "side effect" of CREATE-SELECT).
This of course also applies to a failing CREATE-SELECT.
Unfortunately MDEV-34150 fixes flawed this requirement through removing the cached modification before they get cached for eventual sinking into binlog.
The mtr test fails at the diff line 34.
--source include/have_binlog_format_row.inc
|
--source include/have_innodb.inc
|
--source include/master-slave.inc
|
--source include/have_sequence.inc
|
|
create table ti_pk (a int primary key) engine=innodb;
|
insert into ti_pk set a=10;
|
|
create table ta (a int) engine=myisam;
|
delimiter |;
|
create function f_ia(arg int)
|
returns integer
|
begin
|
insert into ta set a=arg;
|
insert into ti_pk set a=arg;
|
return 1;
|
end |
|
delimiter ;|
|
|
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
|
--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1)
|
|
--error ER_DUP_ENTRY
|
create table error_table (a int) engine=myisam select f_ia(seq) as a from seq_1_to_10;
|
--error ER_NO_SUCH_TABLE
|
select * from error_table;
|
|
--echo # correct execution: `ta` is modified and its new record is binlogged
|
--source include/show_binlog_events.inc
|
select count(*) from ta;
|
select count(*) from ti_pk;
|
|
--sync_slave_with_master
|
# Fails happens here
|
--let $diff_tables=master:ta,slave:ta
|
--source include/diff_tables.inc
|
|
# Cleanup
|
--connection master
|
drop function f_ia;
|
drop table ti_pk, ta;
|
|
--echo End of the tests
|
--source include/rpl_end.inc
|
For fixing is enough to remove the added
thd->binlog_remove_rows_events(); .
Apparently it should not have been there, as proper emptying (either with reset for the transactional cache or flush and then reset for the statement cache) is (must be) always done via binlog_rollback of the top-level statement.