summaryrefslogtreecommitdiff
path: root/sql/sql_binlog.cc
diff options
context:
space:
mode:
authorunknown <Li-Bing.Song@sun.com>2010-11-28 17:43:36 +0800
committerunknown <Li-Bing.Song@sun.com>2010-11-28 17:43:36 +0800
commitf225470b3904a93fdec6966c9c093f545bf260b2 (patch)
treee2c18432d8e8890623628e2e9b7a6e6624f56e7b /sql/sql_binlog.cc
parent7197f142ccc0a867db0ced09c4dab2c1ae17c4ea (diff)
downloadmariadb-git-f225470b3904a93fdec6966c9c093f545bf260b2.tar.gz
BUG#54903 BINLOG statement toggles session variables
When using BINLOG statement to execute rows log events, session variables foreign_key_checks and unique_checks are changed temporarily. As each rows log event has their own special session environment and its own foreign_key_checks and unique_checks can be different from current session which executing the BINLOG statement. But these variables are not restored correctly after BINLOG statement. This problem will cause that the following statements fail or generate unexpected data. In this patch, code is added to backup and restore these two variables. So BINLOG statement will not affect current session's variables again. mysql-test/extra/binlog_tests/binlog.test: Add test to verify this patch. mysql-test/suite/binlog/r/binlog_row_binlog.result: Add test to verify this patch. mysql-test/suite/binlog/r/binlog_stm_binlog.result: Add test to verify this patch. sql/sql_binlog.cc: Add code to backup and restore thd->options.
Diffstat (limited to 'sql/sql_binlog.cc')
-rw-r--r--sql/sql_binlog.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc
index 82de6feb1a9..31fd2de3722 100644
--- a/sql/sql_binlog.cc
+++ b/sql/sql_binlog.cc
@@ -51,6 +51,13 @@ void mysql_client_binlog_statement(THD* thd)
size_t decoded_len= base64_needed_decoded_length(coded_len);
/*
+ thd->options 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->options;
+
+ /*
Allocation
*/
@@ -236,6 +243,7 @@ void mysql_client_binlog_statement(THD* thd)
my_ok(thd);
end:
+ thd->options= thd_options;
rli->clear_tables_to_lock();
my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
DBUG_VOID_RETURN;