diff options
-rw-r--r-- | mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result | 77 | ||||
-rw-r--r-- | mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam.test | 16 | ||||
-rw-r--r-- | sql/sql_insert.cc | 19 |
3 files changed, 71 insertions, 41 deletions
diff --git a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result index 62c111af19a..564fa8d86bd 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result @@ -426,11 +426,18 @@ insert into ti values (2) /* to make the dup error in the following */; insert into tt select * from ti /* one affected and error */; ERROR 23000: Duplicate entry '2' for key 'a' rollback; +Warnings: +Warning 1196 Some non-transactional changed tables couldn't be rolled back show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 106 +master-bin.000001 589 show binlog events from <binlog_start>; Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; BEGIN +master-bin.000001 # Query # # use `test`; insert into ti values (1) +master-bin.000001 # Query # # use `test`; insert into ti values (2) /* to make the dup error in the following */ +master-bin.000001 # Query # # use `test`; insert into tt select * from ti /* one affected and error */ +master-bin.000001 # Query # # use `test`; ROLLBACK select count(*) from ti /* zero */; count(*) 0 @@ -456,10 +463,11 @@ insert into t2 select bug27417(2); reset master; insert into t2 values (bug27417(2)); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 222 -/* only (!) with fixes for #23333 will show there is the query */; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F select count(*) from t1 /* must be 3 */; count(*) 3 @@ -471,10 +479,11 @@ delete from t2 where a=bug27417(3); select count(*) from t2 /* nothing got deleted */; count(*) 2 -show master status; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 227 -/* the query must be in regardless of #23333 */; +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F select count(*) from t1 /* must be 5 */; count(*) 5 @@ -491,9 +500,12 @@ insert into t2 values (1); reset master; insert into t2 values (bug27417(1)); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -show master status /* the offset must denote there is the query */; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 293 +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -503,9 +515,13 @@ insert into t2 values (2); reset master; insert into t2 select bug27417(1) union select bug27417(2); ERROR 23000: Duplicate entry '2' for key 'PRIMARY' -show master status /* the offset must denote there is the query */; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 332 +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; ROLLBACK select count(*) from t1 /* must be 2 */; count(*) 2 @@ -514,9 +530,13 @@ insert into t3 values (1,1),(2,3),(3,4); reset master; update t3 set b=b+bug27417(1); ERROR 23000: Duplicate entry '4' for key 'b' -show master status /* the offset must denote there is the query */; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 305 +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Table_map # # table_id: # (test.t3) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Update_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F select count(*) from t1 /* must be 2 */; count(*) 2 @@ -530,9 +550,13 @@ insert into t3 values (bug27417(1), 2); reset master; delete from t2; ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -show master status /* the offset must denote there is the query */; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 335 +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Table_map # # table_id: # (test.t2) +master-bin.000001 # Table_map # # table_id: # (test.t3) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; ROLLBACK select count(*) from t1 /* must be 1 */; count(*) 1 @@ -548,9 +572,14 @@ a b select count(*) from t1 /* must be 2 */; count(*) 2 -show master status /* the offset must denote there is the query */; -File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 362 +show binlog events from <binlog_start>; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Table_map # # table_id: # (test.t4) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # use `test`; ROLLBACK drop trigger trg_del; drop table t1,t2,t3,t4; drop function bug27417; diff --git a/mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam.test b/mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam.test index 826206a1425..14397f85c38 100644 --- a/mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam.test +++ b/mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam.test @@ -120,15 +120,15 @@ insert into t2 select bug27417(2); reset master; --error ER_DUP_ENTRY -insert into t2 values (bug27417(2)); -show master status; /* only (!) with fixes for #23333 will show there is the query */; +insert into t2 values (bug27417(2)); +source include/show_binlog_events.inc; #only (!) with fixes for #23333 will show there is the query select count(*) from t1 /* must be 3 */; reset master; select count(*) from t2; delete from t2 where a=bug27417(3); select count(*) from t2 /* nothing got deleted */; -show master status; /* the query must be in regardless of #23333 */; +source include/show_binlog_events.inc; # the query must be in regardless of #23333 select count(*) from t1 /* must be 5 */; --enable_info @@ -166,7 +166,7 @@ CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique); # check - show master status /* the offset must denote there is the query */; + source include/show_binlog_events.inc; # must be event of the query select count(*) from t1 /* must be 1 */; # @@ -186,7 +186,7 @@ CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique); # check - show master status /* the offset must denote there is the query */; + source include/show_binlog_events.inc; # must be events of the query select count(*) from t1 /* must be 2 */; # @@ -203,7 +203,7 @@ CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique); update t3 set b=b+bug27417(1); # check - show master status /* the offset must denote there is the query */; + source include/show_binlog_events.inc; # must be events of the query select count(*) from t1 /* must be 2 */; @@ -225,7 +225,7 @@ CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique); --error ER_DUP_ENTRY delete from t2; # check - show master status /* the offset must denote there is the query */; + source include/show_binlog_events.inc; # must be events of the query select count(*) from t1 /* must be 1 */; @@ -245,7 +245,7 @@ CREATE TABLE t3 (a int, PRIMARY KEY (a), b int unique); # check select * from t4; select count(*) from t1 /* must be 2 */; - show master status /* the offset must denote there is the query */; + source include/show_binlog_events.inc; # must be events of the query # # bug#23333 cleanup diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 16ad280c690..2f899a35179 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3163,6 +3163,7 @@ void select_insert::abort() { */ if (table) { + bool changed, transactional_table; /* If we are not in prelocked mode, we end the bulk insert started before. @@ -3184,20 +3185,20 @@ void select_insert::abort() { If table creation failed, the number of rows modified will also be zero, so no check for that is made. */ - if (info.copied || info.deleted || info.updated) + changed= (info.copied || info.deleted || info.updated); + transactional_table= table->file->has_transactions(); + if (thd->transaction.stmt.modified_non_trans_table) { - DBUG_ASSERT(table != NULL); - if (!table->file->has_transactions()) - { if (mysql_bin_log.is_open()) thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query, thd->query_length, - table->file->has_transactions(), FALSE); - if (!thd->current_stmt_binlog_row_based && !table->s->tmp_table && - !can_rollback_data()) + transactional_table, FALSE); + if (!thd->current_stmt_binlog_row_based && !can_rollback_data()) thd->transaction.all.modified_non_trans_table= TRUE; - query_cache_invalidate3(thd, table, 1); - } + if (changed) + query_cache_invalidate3(thd, table, 1); } + DBUG_ASSERT(transactional_table || !changed || + thd->transaction.stmt.modified_non_trans_table); table->file->ha_release_auto_increment(); } |