diff --git a/mysql-test/suite/binlog/r/binlog_show_binlog_events_session_variables.result b/mysql-test/suite/binlog/r/binlog_show_binlog_events_session_variables.result new file mode 100644 index 0000000000000..946b732186fdb --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_show_binlog_events_session_variables.result @@ -0,0 +1,9 @@ +reset master; +set foreign_key_checks= 0, sql_auto_is_null=1, check_constraint_checks=0, unique_checks=0; +create table t (a int, check(a>1), foreign key(a) references x (x)) engine=InnoDB as select 1 as a; +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; set foreign_key_checks=0, sql_auto_is_null=1, unique_checks=0; create table t (a int, check(a>1), foreign key(a) references x (x)) engine=InnoDB as select 1 as a +drop table t; +reset master; diff --git a/mysql-test/suite/binlog/r/foreign_key.result b/mysql-test/suite/binlog/r/foreign_key.result index 171018f22be78..d3f80779c2cd2 100644 --- a/mysql-test/suite/binlog/r/foreign_key.result +++ b/mysql-test/suite/binlog/r/foreign_key.result @@ -31,4 +31,4 @@ master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F master-bin.000001 # Xid # # COMMIT /* XID */ master-bin.000001 # Gtid # # GTID #-#-# -master-bin.000001 # Query # # use `test`; set foreign_key_checks=1; DROP TABLE `t1` /* generated by server */ +master-bin.000001 # Query # # use `test`; set foreign_key_checks=0; DROP TABLE `t1` /* generated by server */ diff --git a/mysql-test/suite/binlog/t/binlog_show_binlog_events_session_variables.test b/mysql-test/suite/binlog/t/binlog_show_binlog_events_session_variables.test new file mode 100644 index 0000000000000..9dc5aeea2cf57 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_show_binlog_events_session_variables.test @@ -0,0 +1,25 @@ +# ==== Purpose ==== +# +# Test verifies that reading binary log by using "SHOW BINLOG EVENTS" command +# from should correctly print the values of session variables such as +# foreign_key_checks, sql_auto_is_null, unique_checks etc +# +# ==== References ==== +# +# MDEV-29804 SHOW BINLOG EVENTS produces semantically/syntactically incorrect statements + + +--source include/have_log_bin.inc +--source include/have_innodb.inc +--source include/have_binlog_format_statement.inc + +reset master; + +set foreign_key_checks= 0, sql_auto_is_null=1, check_constraint_checks=0, unique_checks=0; +create table t (a int, check(a>1), foreign key(a) references x (x)) engine=InnoDB as select 1 as a; + +source include/show_binlog_events.inc; + +# Cleanup +drop table t; +reset master; diff --git a/mysql-test/suite/rpl/r/rpl_alter_rollback.result b/mysql-test/suite/rpl/r/rpl_alter_rollback.result index 3bd91a516c45f..89b8b821f3c85 100644 --- a/mysql-test/suite/rpl/r/rpl_alter_rollback.result +++ b/mysql-test/suite/rpl/r/rpl_alter_rollback.result @@ -42,9 +42,9 @@ master-bin.000001 # Query # # use `test`; alter table t2 add constraint c1 forei master-bin.000001 # Gtid # # GTID #-#-# ROLLBACK ALTER id=# master-bin.000001 # Query # # use `test`; alter table t2 add constraint c1 foreign key (f1) references t1(f1) master-bin.000001 # Gtid # # GTID #-#-# START ALTER -master-bin.000001 # Query # # use `test`; set foreign_key_checks=1; alter table t2 add constraint c1 foreign key (f1) references t1(f1) +master-bin.000001 # Query # # use `test`; set foreign_key_checks=0; alter table t2 add constraint c1 foreign key (f1) references t1(f1) master-bin.000001 # Gtid # # GTID #-#-# ROLLBACK ALTER id=# -master-bin.000001 # Query # # use `test`; set foreign_key_checks=1; alter table t2 add constraint c1 foreign key (f1) references t1(f1) +master-bin.000001 # Query # # use `test`; set foreign_key_checks=0; alter table t2 add constraint c1 foreign key (f1) references t1(f1) connection slave; connection master; drop table t2, t1; diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 53216ff6a4a5e..5e033c576c0d9 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -1064,13 +1064,13 @@ void Query_log_event::pack_info(Protocol *protocol) { buf.append(STRING_WITH_LEN("set ")); if (flags2 & OPTION_NO_FOREIGN_KEY_CHECKS) - buf.append(STRING_WITH_LEN("foreign_key_checks=1, ")); + buf.append(STRING_WITH_LEN("foreign_key_checks=0, ")); if (flags2 & OPTION_AUTO_IS_NULL) - buf.append(STRING_WITH_LEN("sql_auto_is_null, ")); + buf.append(STRING_WITH_LEN("sql_auto_is_null=1, ")); if (flags2 & OPTION_RELAXED_UNIQUE_CHECKS) - buf.append(STRING_WITH_LEN("unique_checks=1, ")); + buf.append(STRING_WITH_LEN("unique_checks=0, ")); if (flags2 & OPTION_NO_CHECK_CONSTRAINT_CHECKS) - buf.append(STRING_WITH_LEN("check_constraint_checks=1, ")); + buf.append(STRING_WITH_LEN("check_constraint_checks=0, ")); if (flags2 & OPTION_IF_EXISTS) buf.append(STRING_WITH_LEN("@@sql_if_exists=1, ")); if (flags2 & OPTION_INSERT_HISTORY)