Skip to content

Commit 9ba5583

Browse files
author
Luis Soares
committed
BUG#51021: current_stmt_binlog_row_based not removed in next-mr
As part of BUG@39934 fix, the public: - THD::current_stmt_binlog_row_based variable had been removed and replaced by a private variable: - THD::current_stmt_binlog_format. THD was refactored and some modifiers and accessors were implemented for the new variable. However, due to a bad merge, the THD::current_stmt_binlog_row_based variable is back as a public member of THD. This in itself is already potentially harmful. What's even worse is that while merging some more patches and resolving conflicts, the variable started being used again, which is obviously wrong. To fix this we: 1. remove the extraneous variable from sql_class.h 2. revert a bad merge for BUG#49132 3. merge BUG#49132 properly again (actually, making use of the cset used to merge the original patch to mysql-pe).
1 parent 68ac1c9 commit 9ba5583

File tree

7 files changed

+135
-74
lines changed

7 files changed

+135
-74
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: 4 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,8 @@ 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+
if (save_binlog_row_based)
1101+
thd->set_current_stmt_binlog_format_row();
11011102

11021103
DBUG_RETURN(test(ret));
11031104
}

sql/events.cc

Lines changed: 14 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,8 @@ 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+
if (save_binlog_row_based)
381+
thd->set_current_stmt_binlog_format_row();
381382
DBUG_RETURN(TRUE);
382383
}
383384
/* If the definer is not set or set to CURRENT_USER, the value of CURRENT_USER
@@ -387,7 +388,8 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
387388
}
388389
mysql_mutex_unlock(&LOCK_event_metadata);
389390
/* Restore the state of binlog format */
390-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
391+
if (save_binlog_row_based)
392+
thd->set_current_stmt_binlog_format_row();
391393

392394
DBUG_RETURN(ret);
393395
}
@@ -471,8 +473,8 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
471473
Turn off row binlogging of this statement and use statement-based
472474
so that all supporting tables are updated for UPDATE EVENT command.
473475
*/
474-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
475-
thd->clear_current_stmt_binlog_format_row();
476+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
477+
thd->clear_current_stmt_binlog_format_row();
476478

477479
mysql_mutex_lock(&LOCK_event_metadata);
478480

@@ -509,7 +511,8 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
509511
}
510512
mysql_mutex_unlock(&LOCK_event_metadata);
511513
/* Restore the state of binlog format */
512-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
514+
if (save_binlog_row_based)
515+
thd->set_current_stmt_binlog_format_row();
513516

514517
DBUG_RETURN(ret);
515518
}
@@ -570,8 +573,8 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
570573
Turn off row binlogging of this statement and use statement-based so
571574
that all supporting tables are updated for DROP EVENT command.
572575
*/
573-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
574-
thd->clear_current_stmt_binlog_format_row();
576+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
577+
thd->clear_current_stmt_binlog_format_row();
575578

576579
mysql_mutex_lock(&LOCK_event_metadata);
577580
/* On error conditions my_error() is called so no need to handle here */
@@ -585,7 +588,8 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
585588
}
586589
mysql_mutex_unlock(&LOCK_event_metadata);
587590
/* Restore the state of binlog format */
588-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
591+
if (save_binlog_row_based)
592+
thd->set_current_stmt_binlog_format_row();
589593
DBUG_RETURN(ret);
590594
}
591595

sql/sp.cc

Lines changed: 12 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,8 @@ 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+
if (save_binlog_row_based)
1140+
thd->set_current_stmt_binlog_format_row();
11401141
DBUG_RETURN(ret);
11411142
}
11421143

@@ -1174,8 +1175,8 @@ sp_drop_routine(THD *thd, int type, sp_name *name)
11741175
row-based replication. The flag will be reset at the end of the
11751176
statement.
11761177
*/
1177-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
1178-
thd->clear_current_stmt_binlog_format_row();
1178+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
1179+
thd->clear_current_stmt_binlog_format_row();
11791180

11801181
if (!(table= open_proc_table_for_update(thd)))
11811182
DBUG_RETURN(SP_OPEN_TABLE_FAILED);
@@ -1194,7 +1195,8 @@ sp_drop_routine(THD *thd, int type, sp_name *name)
11941195

11951196
close_thread_tables(thd);
11961197
/* Restore the state of binlog format */
1197-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
1198+
if (save_binlog_row_based)
1199+
thd->set_current_stmt_binlog_format_row();
11981200
DBUG_RETURN(ret);
11991201
}
12001202

@@ -1233,8 +1235,8 @@ sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
12331235
row-based replication. The flag will be reset at the end of the
12341236
statement.
12351237
*/
1236-
save_binlog_row_based= thd->is_current_stmt_binlog_format_row();
1237-
thd->clear_current_stmt_binlog_format_row();
1238+
if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row()))
1239+
thd->clear_current_stmt_binlog_format_row();
12381240

12391241
if (!(table= open_proc_table_for_update(thd)))
12401242
DBUG_RETURN(SP_OPEN_TABLE_FAILED);
@@ -1269,7 +1271,8 @@ sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics)
12691271

12701272
close_thread_tables(thd);
12711273
/* Restore the state of binlog format */
1272-
thd->current_stmt_binlog_row_based= save_binlog_row_based;
1274+
if (save_binlog_row_based)
1275+
thd->set_current_stmt_binlog_format_row();
12731276
DBUG_RETURN(ret);
12741277
}
12751278

0 commit comments

Comments
 (0)