summaryrefslogtreecommitdiff
path: root/mysql-test/suite
diff options
context:
space:
mode:
authorBill Qu <bill.qu@Oracle.com>2014-09-24 09:44:48 +0800
committerBill Qu <bill.qu@Oracle.com>2014-09-24 09:44:48 +0800
commitcdb8e6ed38ce641a6cb90a4a93bc5ff15f3ba9f2 (patch)
tree580df5c17362f12df9d702617a6bd301c28a44fe /mysql-test/suite
parent0e5fe8e4126a8692553bc316d426f9ab9273a477 (diff)
downloadmariadb-git-cdb8e6ed38ce641a6cb90a4a93bc5ff15f3ba9f2.tar.gz
Bug #15868071 USING SET GLOBAL SQL_LOG_BIN SHOULD NOT BE ALLOWED
Normally, SET SESSION SQL_LOG_BIN is used by DBAs to run a non-conflicting command locally only, ensuring it does not get replicated. Setting GLOBAL SQL_LOG_BIN would not require all sessions to disconnect. When SQL_LOG_BIN is changed globally, it does not immediately take effect for any sessions. It takes effect by becoming the session-level default inherited at the start of each new session, and this setting is kept and cached for the duration of that session. Setting it intentionally is unlikely to have a useful effect under any circumstance; setting it unintentionally, such as while intending to use SET [SESSION] is potentially disastrous. Accidentally using SET GLOBAL SQL_LOG_BIN will not show an immediate effect to the user, instead not having the desired session-level effect, and thus causing other potential problems with local-only maintenance being binlogged and executed on slaves; And transactions from new sessions (after SQL_LOG_BIN is changed globally) are not binlogged and replicated, which would result in irrecoverable or difficult data loss. This is the regular GLOBAL variables way to work, but in replication context it does not look right on a working server (with connected sessions) 'set global sql_log_bin' and none of that connections is affected. Unexperienced DBA after noticing that the command did "nothing" will change the session var and most probably won't unset the global var, causing new sessions to not be binlog. Setting GLOBAL SQL_LOG_BIN allows DBA to stop binlogging on all new sessions, which can be used to make a server "replication read-only" without restarting the server. But this has such big requirements, stop all existing connections, that it is more likely to make a mess, it is too risky to allow the GLOBAL variable. The statement 'SET GLOBAL SQL_LOG_BIN=N' will produce an error in 5.5, 5.6 and 5.7. Reading the GLOBAL SQL_LOG_BIN will produce a deprecation warning in 5.7.
Diffstat (limited to 'mysql-test/suite')
-rw-r--r--mysql-test/suite/binlog/r/binlog_switch_inside_trans.result8
-rw-r--r--mysql-test/suite/binlog/t/binlog_grant.test2
-rw-r--r--mysql-test/suite/binlog/t/binlog_switch_inside_trans.test6
-rw-r--r--mysql-test/suite/sys_vars/r/sql_log_bin_basic.result7
-rw-r--r--mysql-test/suite/sys_vars/t/sql_log_bin_basic.test6
5 files changed, 14 insertions, 15 deletions
diff --git a/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result b/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result
index 48b6dfa61d9..0819d4e778f 100644
--- a/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result
+++ b/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result
@@ -1,6 +1,5 @@
set @save_binlog_format= @@global.binlog_format;
set @save_binlog_dirct= @@global.binlog_direct_non_transactional_updates;
-set @save_sql_log_bin= @@global.sql_log_bin;
create table t1 (a int) engine= myisam;
create table t2 (a int) engine= innodb;
SELECT @@session.binlog_format;
@@ -129,7 +128,7 @@ commit;
begin;
insert into t2 values (5);
# Test that the global variable 'binlog_format' and
-# 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
+# 'binlog_direct_non_transactional_updates' are
# writable inside a transaction.
# Current session values are ROW, FALSE, TRUE respectively.
SELECT @@global.binlog_format;
@@ -137,20 +136,15 @@ SELECT @@global.binlog_format;
ROW
set @@global.binlog_format= statement;
set @@global.binlog_direct_non_transactional_updates= TRUE;
-set @@global.sql_log_bin= FALSE;
SELECT @@global.binlog_format;
@@global.binlog_format
STATEMENT
SELECT @@global.binlog_direct_non_transactional_updates;
@@global.binlog_direct_non_transactional_updates
1
-SELECT @@global.sql_log_bin;
-@@global.sql_log_bin
-0
commit;
set @@global.binlog_format= @save_binlog_format;
set @@global.binlog_direct_non_transactional_updates= @save_binlog_dirct;
-set @@global.sql_log_bin= @save_sql_log_bin;
create table t3(a int, b int) engine= innodb;
create table t4(a int) engine= innodb;
create table t5(a int) engine= innodb;
diff --git a/mysql-test/suite/binlog/t/binlog_grant.test b/mysql-test/suite/binlog/t/binlog_grant.test
index f0367b3aa79..0c9d9a45ec9 100644
--- a/mysql-test/suite/binlog/t/binlog_grant.test
+++ b/mysql-test/suite/binlog/t/binlog_grant.test
@@ -15,7 +15,7 @@ show grants for mysqltest_1@localhost;
connect (plain,localhost,mysqltest_1,,test);
connect (root,localhost,root,,test);
-# Testing setting both session and global SQL_LOG_BIN variable both as
+# Testing setting session SQL_LOG_BIN variable both as
# root and as plain user.
--echo **** Variable SQL_LOG_BIN ****
diff --git a/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test b/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test
index 06c5e78bd0e..a93cd44fa17 100644
--- a/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test
+++ b/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test
@@ -10,7 +10,6 @@ source include/have_binlog_format_row.inc;
set @save_binlog_format= @@global.binlog_format;
set @save_binlog_dirct= @@global.binlog_direct_non_transactional_updates;
-set @save_sql_log_bin= @@global.sql_log_bin;
create table t1 (a int) engine= myisam;
create table t2 (a int) engine= innodb;
@@ -117,21 +116,18 @@ commit;
begin;
insert into t2 values (5);
--echo # Test that the global variable 'binlog_format' and
---echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
+--echo # 'binlog_direct_non_transactional_updates' are
--echo # writable inside a transaction.
--echo # Current session values are ROW, FALSE, TRUE respectively.
SELECT @@global.binlog_format;
set @@global.binlog_format= statement;
set @@global.binlog_direct_non_transactional_updates= TRUE;
- set @@global.sql_log_bin= FALSE;
SELECT @@global.binlog_format;
SELECT @@global.binlog_direct_non_transactional_updates;
- SELECT @@global.sql_log_bin;
commit;
set @@global.binlog_format= @save_binlog_format;
set @@global.binlog_direct_non_transactional_updates= @save_binlog_dirct;
-set @@global.sql_log_bin= @save_sql_log_bin;
create table t3(a int, b int) engine= innodb;
create table t4(a int) engine= innodb;
diff --git a/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result b/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
index 5e8fe4e02f7..7d9ef4f76ed 100644
--- a/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
@@ -57,11 +57,16 @@ ERROR 42000: Variable 'sql_log_bin' can't be set to the value of '¹'
SET @@session.sql_log_bin = NO;
ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'NO'
'#-------------------FN_DYNVARS_156_05----------------------------#'
+SELECT @@global.sql_log_bin;
+@@global.sql_log_bin
+1
SET @@global.sql_log_bin = 0;
+ERROR 42000: Variable 'sql_log_bin' can't be set to the value of '0'
SELECT @@global.sql_log_bin;
@@global.sql_log_bin
-0
+1
SET @@global.sql_log_bin = 1;
+ERROR 42000: Variable 'sql_log_bin' can't be set to the value of '1'
'#----------------------FN_DYNVARS_156_06------------------------#'
SELECT count(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='sql_log_bin';
count(VARIABLE_VALUE)
diff --git a/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test b/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
index 153a0be0b8f..1e697e72221 100644
--- a/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
+++ b/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
@@ -109,11 +109,15 @@ SET @@session.sql_log_bin = NO;
--echo '#-------------------FN_DYNVARS_156_05----------------------------#'
###########################################################################
-# Test if accessing global sql_log_bin gives error #
+# Test if setting global sql_log_bin gives error, #
+# and there is no error on reading it. #
###########################################################################
+SELECT @@global.sql_log_bin;
+--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.sql_log_bin = 0;
SELECT @@global.sql_log_bin;
+--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.sql_log_bin = 1;
--echo '#----------------------FN_DYNVARS_156_06------------------------#'