Commit 30376d28 authored by 's avatar

Manual merge

parents d695e392 abb201c1
...@@ -304,5 +304,58 @@ BINLOG ' ...@@ -304,5 +304,58 @@ BINLOG '
SHOW BINLOG EVENTS; SHOW BINLOG EVENTS;
DROP TABLE t1; DROP TABLE t1;
--echo
--echo # BUG#54903 BINLOG statement toggles session variables
--echo # ----------------------------------------------------------------------
--echo # This test verify that BINLOG statement doesn't change current session's
--echo # variables foreign_key_checks and unique_checks.
--echo
CREATE TABLE t1 (c1 INT KEY);
SET @@SESSION.foreign_key_checks= ON;
SET @@SESSION.unique_checks= ON;
--echo # INSERT INTO t1 VALUES (1)
--echo # foreign_key_checks=0 and unique_checks=0
BINLOG '
dfLtTBMBAAAAKQAAANcAAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAPkAAAAAABcAAAAAAAcAAf/+AQAAAA==
';
SELECT * FROM t1;
--echo # Their values should be ON
SHOW SESSION VARIABLES LIKE "%_checks";
--echo
SET @@SESSION.foreign_key_checks= OFF;
SET @@SESSION.unique_checks= OFF;
--echo # INSERT INTO t1 VALUES(2)
--echo # foreign_key_checks=1 and unique_checks=1
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
';
SELECT * FROM t1;
--echo # Their values should be OFF
SHOW SESSION VARIABLES LIKE "%_checks";
--echo # INSERT INTO t1 VALUES(2)
--echo # foreign_key_checks=1 and unique_checks=1
--echo # It should not change current session's variables, even error happens
--error 1062
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
';
SELECT * FROM t1;
--echo # Their values should be OFF
SHOW SESSION VARIABLES LIKE "%_checks";
DROP TABLE t1;
disconnect fresh; disconnect fresh;
...@@ -1330,3 +1330,62 @@ Log_name Pos Event_type Server_id End_log_pos Info ...@@ -1330,3 +1330,62 @@ Log_name Pos Event_type Server_id End_log_pos Info
# # Write_rows 1 # table_id: # flags: STMT_END_F # # Write_rows 1 # table_id: # flags: STMT_END_F
# # Query 1 # COMMIT # # Query 1 # COMMIT
DROP TABLE t1; DROP TABLE t1;
# BUG#54903 BINLOG statement toggles session variables
# ----------------------------------------------------------------------
# This test verify that BINLOG statement doesn't change current session's
# variables foreign_key_checks and unique_checks.
CREATE TABLE t1 (c1 INT KEY);
SET @@SESSION.foreign_key_checks= ON;
SET @@SESSION.unique_checks= ON;
# INSERT INTO t1 VALUES (1)
# foreign_key_checks=0 and unique_checks=0
BINLOG '
dfLtTBMBAAAAKQAAANcAAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAPkAAAAAABcAAAAAAAcAAf/+AQAAAA==
';
SELECT * FROM t1;
c1
1
# Their values should be ON
SHOW SESSION VARIABLES LIKE "%_checks";
Variable_name Value
foreign_key_checks ON
unique_checks ON
SET @@SESSION.foreign_key_checks= OFF;
SET @@SESSION.unique_checks= OFF;
# INSERT INTO t1 VALUES(2)
# foreign_key_checks=1 and unique_checks=1
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
';
SELECT * FROM t1;
c1
1
2
# Their values should be OFF
SHOW SESSION VARIABLES LIKE "%_checks";
Variable_name Value
foreign_key_checks OFF
unique_checks OFF
# INSERT INTO t1 VALUES(2)
# foreign_key_checks=1 and unique_checks=1
# It should not change current session's variables, even error happens
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
';
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
SELECT * FROM t1;
c1
1
2
# Their values should be OFF
SHOW SESSION VARIABLES LIKE "%_checks";
Variable_name Value
foreign_key_checks OFF
unique_checks OFF
DROP TABLE t1;
...@@ -820,3 +820,62 @@ Log_name Pos Event_type Server_id End_log_pos Info ...@@ -820,3 +820,62 @@ Log_name Pos Event_type Server_id End_log_pos Info
# # Write_rows 1 # table_id: # flags: STMT_END_F # # Write_rows 1 # table_id: # flags: STMT_END_F
# # Query 1 # COMMIT # # Query 1 # COMMIT
DROP TABLE t1; DROP TABLE t1;
# BUG#54903 BINLOG statement toggles session variables
# ----------------------------------------------------------------------
# This test verify that BINLOG statement doesn't change current session's
# variables foreign_key_checks and unique_checks.
CREATE TABLE t1 (c1 INT KEY);
SET @@SESSION.foreign_key_checks= ON;
SET @@SESSION.unique_checks= ON;
# INSERT INTO t1 VALUES (1)
# foreign_key_checks=0 and unique_checks=0
BINLOG '
dfLtTBMBAAAAKQAAANcAAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAPkAAAAAABcAAAAAAAcAAf/+AQAAAA==
';
SELECT * FROM t1;
c1
1
# Their values should be ON
SHOW SESSION VARIABLES LIKE "%_checks";
Variable_name Value
foreign_key_checks ON
unique_checks ON
SET @@SESSION.foreign_key_checks= OFF;
SET @@SESSION.unique_checks= OFF;
# INSERT INTO t1 VALUES(2)
# foreign_key_checks=1 and unique_checks=1
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
';
SELECT * FROM t1;
c1
1
2
# Their values should be OFF
SHOW SESSION VARIABLES LIKE "%_checks";
Variable_name Value
foreign_key_checks OFF
unique_checks OFF
# INSERT INTO t1 VALUES(2)
# foreign_key_checks=1 and unique_checks=1
# It should not change current session's variables, even error happens
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
';
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
SELECT * FROM t1;
c1
1
2
# Their values should be OFF
SHOW SESSION VARIABLES LIKE "%_checks";
Variable_name Value
foreign_key_checks OFF
unique_checks OFF
DROP TABLE t1;
...@@ -60,6 +60,13 @@ void mysql_client_binlog_statement(THD* thd) ...@@ -60,6 +60,13 @@ void mysql_client_binlog_statement(THD* thd)
} }
size_t decoded_len= base64_needed_decoded_length(coded_len); size_t decoded_len= base64_needed_decoded_length(coded_len);
/*
option_bits will be changed when applying the event. But we don't expect
it be changed permanently after BINLOG statement, so backup it first.
It will be restored at the end of this function.
*/
ulonglong thd_options= thd->variables.option_bits;
/* /*
Allocation Allocation
*/ */
...@@ -246,6 +253,7 @@ void mysql_client_binlog_statement(THD* thd) ...@@ -246,6 +253,7 @@ void mysql_client_binlog_statement(THD* thd)
my_ok(thd); my_ok(thd);
end: end:
thd->variables.option_bits= thd_options;
rli->slave_close_thread_tables(thd); rli->slave_close_thread_tables(thd);
my_free(buf); my_free(buf);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment