mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-36685 CREATE-SELECT may lose in binlog side-effects of stored-routine
When the SELECT sub-statement executes a stored function that is defined to modify a non-transactional table, like delimiter |; create function f_ia(arg int) returns integer begin insert into ti_pk set a=1; insert into ta set a=1; insert into ti_pk set a=arg; return 1; end | delimiter ;| any modified records that the function has succeeded on must be binlogged as a "side effect" of CREATE-SELECT. It is expected that a failing CREATE-SELECT like --error ER_DUP_ENTRY set statement binlog_format = ROW for create table t_y (a int) engine=aria select f_ia(1 /* err in Innodb after Aria stmt is done */) as a; leaves upon itself the following state: include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Gtid # # BEGIN GTID #-#-# master-bin.000001 # Table_map # # table_id: # (test. ta) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # COMMIT select * from ta; a 1 select count(*) = 0 from ti_pk; true However it's not so for the binlog part. The reason is that prior to MDEV-34150 fixes the CREATE-SELECT's errored phase leaves the binlog caches intact (the file:pos from 10.11c06c36218a
) to defer their reset to the rollback phase of the top-level /* the statement cache gets binlogged */ where the side-effect changes gets binlogged. MDEV-34150 fixes harmed (+#4 line) the statement cache in particular in the error phase (file:pos are from395db6f1d5
the current 11.8 ) /* The caches incl the statement cache are gone */ /* 'cos of MDEV-34150 */ +#4 0x00005d75f9b6a92e in THD::binlog_remove_rows_events (this=0x52c000240288) at log.cc:579 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. To observe the above requirement the case is fixed with the removal of thd->binlog_remove_rows_events() and its definition. Tested with rpl.rpl_create_select_row. Reviewed-by Brandon Nesterenko.
This commit is contained in:
@ -5438,9 +5438,6 @@ void select_create::abort_result_set()
|
||||
bool table_creation_was_logged= (!tmp_table ||
|
||||
table->s->table_creation_was_logged);
|
||||
|
||||
/* CREATE SELECT failed. Remove all row events and clear caches */
|
||||
thd->binlog_remove_rows_events();
|
||||
|
||||
if (tmp_table)
|
||||
{
|
||||
DBUG_ASSERT(saved_tmp_table_share);
|
||||
|
Reference in New Issue
Block a user