Skip to content

Commit af67056

Browse files
author
Luis Soares
committed
Manual merge from mysql-next-mr bug branch.
Conflicts ========= Text conflict in sql/sql_base.cc
2 parents 7f83359 + f4f4a2c commit af67056

File tree

8 files changed

+167
-77
lines changed

8 files changed

+167
-77
lines changed

mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,9 @@ ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
744744
show binlog events from <binlog_start>;
745745
Log_name Pos Event_type Server_id End_log_pos Info
746746
master-bin.000001 # Query # # BEGIN
747-
master-bin.000001 # Intvar # # INSERT_ID=3
748-
master-bin.000001 # Query # # use `test`; insert into t2 values (bug27417(2))
747+
master-bin.000001 # Table_map # # table_id: # (test.t2)
748+
master-bin.000001 # Table_map # # table_id: # (test.t1)
749+
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
749750
master-bin.000001 # Query # # COMMIT
750751
select count(*) from t1 /* must be 3 */;
751752
count(*)
@@ -761,8 +762,9 @@ count(*)
761762
show binlog events from <binlog_start>;
762763
Log_name Pos Event_type Server_id End_log_pos Info
763764
master-bin.000001 # Query # # BEGIN
764-
master-bin.000001 # Intvar # # INSERT_ID=4
765-
master-bin.000001 # Query # # use `test`; delete from t2 where a=bug27417(3)
765+
master-bin.000001 # Table_map # # table_id: # (test.t2)
766+
master-bin.000001 # Table_map # # table_id: # (test.t1)
767+
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
766768
master-bin.000001 # Query # # COMMIT
767769
select count(*) from t1 /* must be 5 */;
768770
count(*)
@@ -784,6 +786,10 @@ insert into t2 values (bug27417(1));
784786
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
785787
show binlog events from <binlog_start>;
786788
Log_name Pos Event_type Server_id End_log_pos Info
789+
master-bin.000001 # Query # # BEGIN
790+
master-bin.000001 # Table_map # # table_id: # (test.t1)
791+
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
792+
master-bin.000001 # Query # # COMMIT
787793
select count(*) from t1 /* must be 1 */;
788794
count(*)
789795
1
@@ -795,6 +801,10 @@ insert into t2 select bug27417(1) union select bug27417(2);
795801
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
796802
show binlog events from <binlog_start>;
797803
Log_name Pos Event_type Server_id End_log_pos Info
804+
master-bin.000001 # Query # # BEGIN
805+
master-bin.000001 # Table_map # # table_id: # (test.t1)
806+
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
807+
master-bin.000001 # Query # # COMMIT
798808
select count(*) from t1 /* must be 2 */;
799809
count(*)
800810
2
@@ -806,8 +816,11 @@ ERROR 23000: Duplicate entry '4' for key 'b'
806816
show binlog events from <binlog_start>;
807817
Log_name Pos Event_type Server_id End_log_pos Info
808818
master-bin.000001 # Query # # BEGIN
809-
master-bin.000001 # Intvar # # INSERT_ID=4
810-
master-bin.000001 # Query # # use `test`; update t3 set b=b+bug27417(1)
819+
master-bin.000001 # Table_map # # table_id: # (test.t3)
820+
master-bin.000001 # Table_map # # table_id: # (test.t1)
821+
master-bin.000001 # Write_rows # # table_id: #
822+
master-bin.000001 # Update_rows # # table_id: #
823+
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
811824
master-bin.000001 # Query # # COMMIT
812825
select count(*) from t1 /* must be 2 */;
813826
count(*)
@@ -821,6 +834,10 @@ UPDATE t4,t3 SET t4.a=t3.a + bug27417(1) /* top level non-ta table */;
821834
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
822835
show binlog events from <binlog_start>;
823836
Log_name Pos Event_type Server_id End_log_pos Info
837+
master-bin.000001 # Query # # BEGIN
838+
master-bin.000001 # Table_map # # table_id: # (test.t1)
839+
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
840+
master-bin.000001 # Query # # COMMIT
824841
select count(*) from t1 /* must be 4 */;
825842
count(*)
826843
4
@@ -834,7 +851,7 @@ UPDATE t3,t4 SET t3.a=t4.a + bug27417(1);
834851
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
835852
select count(*) from t1 /* must be 1 */;
836853
count(*)
837-
1
854+
2
838855
drop table t4;
839856
delete from t1;
840857
delete from t2;
@@ -848,6 +865,11 @@ delete from t2;
848865
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
849866
show binlog events from <binlog_start>;
850867
Log_name Pos Event_type Server_id End_log_pos Info
868+
master-bin.000001 # Query # # BEGIN
869+
master-bin.000001 # Table_map # # table_id: # (test.t3)
870+
master-bin.000001 # Table_map # # table_id: # (test.t1)
871+
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
872+
master-bin.000001 # Query # # COMMIT
851873
select count(*) from t1 /* must be 1 */;
852874
count(*)
853875
1
@@ -864,6 +886,10 @@ delete t2.* from t2,t5 where t2.a=t5.a + 1;
864886
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
865887
show binlog events from <binlog_start>;
866888
Log_name Pos Event_type Server_id End_log_pos Info
889+
master-bin.000001 # Query # # BEGIN
890+
master-bin.000001 # Table_map # # table_id: # (test.t1)
891+
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
892+
master-bin.000001 # Query # # COMMIT
867893
select count(*) from t1 /* must be 1 */;
868894
count(*)
869895
1
@@ -881,6 +907,10 @@ count(*)
881907
2
882908
show binlog events from <binlog_start>;
883909
Log_name Pos Event_type Server_id End_log_pos Info
910+
master-bin.000001 # Query # # BEGIN
911+
master-bin.000001 # Table_map # # table_id: # (test.t1)
912+
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
913+
master-bin.000001 # Query # # COMMIT
884914
drop trigger trg_del_t2;
885915
drop table t1,t2,t3,t4,t5;
886916
drop function bug27417;

sql/event_db_repository.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,8 +1053,8 @@ update_timing_fields_for_event(THD *thd,
10531053
Turn off row binlogging of event timing updates. These are not used
10541054
for RBR of events replicated to the slave.
10551055
*/
1056-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
1057-
thd->clear_current_stmt_binlog_format_row();
1056+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
1057+
thd->clear_current_stmt_binlog_format_row();
10581058

10591059
DBUG_ASSERT(thd->security_ctx->master_access & SUPER_ACL);
10601060

@@ -1097,7 +1097,9 @@ update_timing_fields_for_event(THD *thd,
10971097
if (table)
10981098
close_thread_tables(thd);
10991099
/* Restore the state of binlog format */
1100-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
1100+
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
1101+
if (save_binlog_row_based)
1102+
thd->set_current_stmt_binlog_format_row();
11011103

11021104
DBUG_RETURN(test(ret));
11031105
}

sql/events.cc

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
335335
Turn off row binlogging of this statement and use statement-based
336336
so that all supporting tables are updated for CREATE EVENT command.
337337
*/
338-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
339-
thd->clear_current_stmt_binlog_format_row();
338+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
339+
thd->clear_current_stmt_binlog_format_row();
340340

341341
mysql_mutex_lock(&LOCK_event_metadata);
342342

@@ -377,7 +377,9 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
377377
sql_print_error("Event Error: An error occurred while creating query string, "
378378
"before writing it into binary log.");
379379
/* Restore the state of binlog format */
380-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
380+
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
381+
if (save_binlog_row_based)
382+
thd->set_current_stmt_binlog_format_row();
381383
DBUG_RETURN(TRUE);
382384
}
383385
/* If the definer is not set or set to CURRENT_USER, the value of CURRENT_USER
@@ -387,7 +389,9 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
387389
}
388390
mysql_mutex_unlock(&LOCK_event_metadata);
389391
/* Restore the state of binlog format */
390-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
392+
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
393+
if (save_binlog_row_based)
394+
thd->set_current_stmt_binlog_format_row();
391395

392396
DBUG_RETURN(ret);
393397
}
@@ -471,8 +475,8 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
471475
Turn off row binlogging of this statement and use statement-based
472476
so that all supporting tables are updated for UPDATE EVENT command.
473477
*/
474-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
475-
thd->clear_current_stmt_binlog_format_row();
478+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
479+
thd->clear_current_stmt_binlog_format_row();
476480

477481
mysql_mutex_lock(&LOCK_event_metadata);
478482

@@ -509,7 +513,9 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
509513
}
510514
mysql_mutex_unlock(&LOCK_event_metadata);
511515
/* Restore the state of binlog format */
512-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
516+
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
517+
if (save_binlog_row_based)
518+
thd->set_current_stmt_binlog_format_row();
513519

514520
DBUG_RETURN(ret);
515521
}
@@ -570,8 +576,8 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
570576
Turn off row binlogging of this statement and use statement-based so
571577
that all supporting tables are updated for DROP EVENT command.
572578
*/
573-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
574-
thd->clear_current_stmt_binlog_format_row();
579+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
580+
thd->clear_current_stmt_binlog_format_row();
575581

576582
mysql_mutex_lock(&LOCK_event_metadata);
577583
/* On error conditions my_error() is called so no need to handle here */
@@ -585,7 +591,9 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
585591
}
586592
mysql_mutex_unlock(&LOCK_event_metadata);
587593
/* Restore the state of binlog format */
588-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
594+
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
595+
if (save_binlog_row_based)
596+
thd->set_current_stmt_binlog_format_row();
589597
DBUG_RETURN(ret);
590598
}
591599

sql/sp.cc

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,8 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
927927
row-based replication. The flag will be reset at the end of the
928928
statement.
929929
*/
930-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
931-
thd->clear_current_stmt_binlog_format_row();
930+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
931+
thd->clear_current_stmt_binlog_format_row();
932932

933933
saved_count_cuted_fields= thd->count_cuted_fields;
934934
thd->count_cuted_fields= CHECK_FIELD_WARN;
@@ -1136,7 +1136,9 @@ sp_create_routine(THD *thd, int type, sp_head *sp)
11361136

11371137
close_thread_tables(thd);
11381138
/* Restore the state of binlog format */
1139-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
1139+
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
1140+
if (save_binlog_row_based)
1141+
thd->set_current_stmt_binlog_format_row();
11401142
DBUG_RETURN(ret);
11411143
}
11421144

@@ -1174,8 +1176,8 @@ sp_drop_routine(THD *thd, int type, sp_name *name)
11741176
row-based replication. The flag will be reset at the end of the
11751177
statement.
11761178
*/
1177-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
1178-
thd->clear_current_stmt_binlog_format_row();
1179+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
1180+
thd->clear_current_stmt_binlog_format_row();
11791181

11801182
if (!(table= open_proc_table_for_update(thd)))
11811183
DBUG_RETURN(SP_OPEN_TABLE_FAILED);
@@ -1194,7 +1196,9 @@ sp_drop_routine(THD *thd, int type, sp_name *name)
11941196

11951197
close_thread_tables(thd);
11961198
/* Restore the state of binlog format */
1197-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
1199+
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
1200+
if (save_binlog_row_based)
1201+
thd->set_current_stmt_binlog_format_row();
11981202
DBUG_RETURN(ret);
11991203
}
12001204

@@ -1233,8 +1237,8 @@ sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
12331237
row-based replication. The flag will be reset at the end of the
12341238
statement.
12351239
*/
1236-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
1237-
thd->clear_current_stmt_binlog_format_row();
1240+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
1241+
thd->clear_current_stmt_binlog_format_row();
12381242

12391243
if (!(table= open_proc_table_for_update(thd)))
12401244
DBUG_RETURN(SP_OPEN_TABLE_FAILED);
@@ -1269,7 +1273,9 @@ sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
12691273

12701274
close_thread_tables(thd);
12711275
/* Restore the state of binlog format */
1272-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
1276+
DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row());
1277+
if (save_binlog_row_based)
1278+
thd->set_current_stmt_binlog_format_row();
12731279
DBUG_RETURN(ret);
12741280
}
12751281

0 commit comments

Comments
 (0)