|
|
|
@ -1,7 +1,8 @@ |
|
|
|
# |
|
|
|
# BUG#47863 |
|
|
|
# This test verifies if the session variable 'binlog_format' |
|
|
|
# is read-only inside a transaction and in sub-statements. |
|
|
|
# This test verifies if the session variable 'binlog_format' and |
|
|
|
# 'binlog_direct_non_transactional_updates' are read-only inside |
|
|
|
# a transaction and in sub-statements. |
|
|
|
# |
|
|
|
|
|
|
|
source include/have_innodb.inc; |
|
|
|
@ -13,25 +14,32 @@ create table t1 (a int) engine= myisam; |
|
|
|
create table t2 (a int) engine= innodb; |
|
|
|
|
|
|
|
SELECT @@session.binlog_format; |
|
|
|
SELECT @@session.binlog_direct_non_transactional_updates; |
|
|
|
SET AUTOCOMMIT=1; |
|
|
|
--echo # Test that the session variable 'binlog_format' |
|
|
|
--echo # is writable outside a transaction. |
|
|
|
--echo # Test that the session variable 'binlog_format' and |
|
|
|
--echo # 'binlog_direct_non_transactional_updates' are |
|
|
|
--echo # writable outside a transaction. |
|
|
|
--echo # Current session values are ROW and FALSE, respectively. |
|
|
|
set @@session.binlog_format= statement; |
|
|
|
set @@session.binlog_direct_non_transactional_updates= TRUE; |
|
|
|
SELECT @@session.binlog_format; |
|
|
|
SELECT @@session.binlog_direct_non_transactional_updates; |
|
|
|
|
|
|
|
begin; |
|
|
|
--echo # Test that the session variable 'binlog_format' is read-only |
|
|
|
--echo # inside a transaction with no preceding updates. |
|
|
|
--echo # Test that the session variable 'binlog_format' and |
|
|
|
--echo # 'binlog_direct_non_transactional_updates' are |
|
|
|
--echo # read-only inside a transaction with no preceding updates. |
|
|
|
--echo # Current session values are STATEMENT and TRUE, respectively. |
|
|
|
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT |
|
|
|
set @@session.binlog_format= mixed; |
|
|
|
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT |
|
|
|
set @@session.binlog_direct_non_transactional_updates= FALSE; |
|
|
|
|
|
|
|
insert into t2 values (1); |
|
|
|
--echo # Test that the session variable 'binlog_format' is read-only |
|
|
|
--echo # inside a transaction with preceding transactional updates. |
|
|
|
--echo # Test that the session variable 'binlog_format' and |
|
|
|
--echo # 'binlog_direct_non_transactional_updates' are |
|
|
|
--echo # read-only inside a transaction with preceding transactional updates. |
|
|
|
--echo # Current session values are STATEMENT and TRUE, respectively. |
|
|
|
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT |
|
|
|
set @@session.binlog_format= row; |
|
|
|
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT |
|
|
|
@ -40,25 +48,32 @@ commit; |
|
|
|
|
|
|
|
begin; |
|
|
|
insert into t1 values (2); |
|
|
|
--echo # Test that the session variable 'binlog_format' is read-only |
|
|
|
--echo # inside a transaction with preceding non-transactional updates. |
|
|
|
--echo # Test that the session variable 'binlog_format' and |
|
|
|
--echo # 'binlog_direct_non_transactional_updates' are |
|
|
|
--echo # read-only inside a transaction with preceding non-transactional updates. |
|
|
|
--echo # Current session values are STATEMENT and TRUE, respectively. |
|
|
|
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT |
|
|
|
set @@session.binlog_format= statement; |
|
|
|
set @@session.binlog_format= mixed; |
|
|
|
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT |
|
|
|
set @@session.binlog_direct_non_transactional_updates= FALSE; |
|
|
|
commit; |
|
|
|
|
|
|
|
--echo # Test that the session variable 'binlog_format' is writable |
|
|
|
--echo # when AUTOCOMMIT=0, before a transaction has started. |
|
|
|
--echo # Test that the session variable 'binlog_format' and |
|
|
|
--echo # 'binlog_direct_non_transactional_updates' are |
|
|
|
--echo # writable when AUTOCOMMIT=0, before a transaction has started. |
|
|
|
--echo # Current session values are STATEMENT and TRUE, respectively. |
|
|
|
set AUTOCOMMIT=0; |
|
|
|
set @@session.binlog_format= row; |
|
|
|
set @@session.binlog_direct_non_transactional_updates= FALSE; |
|
|
|
SELECT @@session.binlog_format; |
|
|
|
SELECT @@session.binlog_direct_non_transactional_updates; |
|
|
|
|
|
|
|
insert into t1 values (4); |
|
|
|
--echo # Test that the session variable 'binlog_format' is read-only inside an |
|
|
|
--echo # AUTOCOMMIT=0 transaction with preceding non-transactional updates. |
|
|
|
insert into t1 values (3); |
|
|
|
--echo # Test that the session variable 'binlog_format' and |
|
|
|
--echo # 'binlog_direct_non_transactional_updates' are |
|
|
|
--echo # read-only inside an AUTOCOMMIT=0 transaction |
|
|
|
--echo # with preceding non-transactional updates. |
|
|
|
--echo # Current session values are ROW and FALSE, respectively. |
|
|
|
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT |
|
|
|
set @@session.binlog_format= statement; |
|
|
|
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT |
|
|
|
@ -67,11 +82,14 @@ SELECT @@session.binlog_format; |
|
|
|
SELECT @@session.binlog_direct_non_transactional_updates; |
|
|
|
commit; |
|
|
|
|
|
|
|
insert into t2 values (5); |
|
|
|
--echo # Test that the session variable 'binlog_format' is read-only inside an |
|
|
|
--echo # AUTOCOMMIT=0 transaction with preceding transactional updates. |
|
|
|
insert into t2 values (4); |
|
|
|
--echo # Test that the session variable 'binlog_format' and |
|
|
|
--echo # 'binlog_direct_non_transactional_updates' are |
|
|
|
--echo # read-only inside an AUTOCOMMIT=0 transaction with |
|
|
|
--echo # preceding transactional updates. |
|
|
|
--echo # Current session values are ROW and FALSE, respectively. |
|
|
|
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT |
|
|
|
set @@session.binlog_format= row; |
|
|
|
set @@session.binlog_format= statement; |
|
|
|
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT |
|
|
|
set @@session.binlog_direct_non_transactional_updates= TRUE; |
|
|
|
SELECT @@session.binlog_format; |
|
|
|
@ -79,9 +97,11 @@ SELECT @@session.binlog_direct_non_transactional_updates; |
|
|
|
commit; |
|
|
|
|
|
|
|
begin; |
|
|
|
insert into t2 values (6); |
|
|
|
--echo # Test that the global variable 'binlog_format' is writable |
|
|
|
--echo # inside a transaction. |
|
|
|
insert into t2 values (5); |
|
|
|
--echo # Test that the global variable 'binlog_format' and |
|
|
|
--echo # 'binlog_direct_non_transactional_updates' are |
|
|
|
--echo # writable inside a transaction. |
|
|
|
--echo # Current session values are ROW and FALSE, respectively. |
|
|
|
SELECT @@global.binlog_format; |
|
|
|
set @@global.binlog_format= statement; |
|
|
|
set @@global.binlog_direct_non_transactional_updates= TRUE; |
|
|
|
@ -90,7 +110,7 @@ begin; |
|
|
|
commit; |
|
|
|
|
|
|
|
set @@global.binlog_format= @save_binlog_format; |
|
|
|
set @@global.binlog_direct_non_transactional_updates= @save_binlog_dirct; |
|
|
|
set @@global.binlog_direct_non_transactional_updates= @save_binlog_dirct; |
|
|
|
|
|
|
|
create table t3(a int, b int) engine= innodb; |
|
|
|
create table t4(a int) engine= innodb; |
|
|
|
@ -98,7 +118,7 @@ create table t5(a int) engine= innodb; |
|
|
|
delimiter |; |
|
|
|
eval create trigger tr1 after insert on t3 for each row begin |
|
|
|
insert into t4(a) values(1); |
|
|
|
set @@session.binlog_format= statement; |
|
|
|
set @@session.binlog_format= statement; |
|
|
|
insert into t4(a) values(2); |
|
|
|
insert into t5(a) values(3); |
|
|
|
end | |
|
|
|
@ -106,6 +126,7 @@ delimiter ;| |
|
|
|
|
|
|
|
--echo # Test that the session variable 'binlog_format' is read-only |
|
|
|
--echo # in sub-statements. |
|
|
|
--echo # Current session value is ROW. |
|
|
|
--error ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT |
|
|
|
insert into t3(a,b) values(1,1); |
|
|
|
SELECT @@session.binlog_format; |
|
|
|
@ -116,14 +137,16 @@ create table t8(a int) engine= innodb; |
|
|
|
delimiter |; |
|
|
|
eval create trigger tr2 after insert on t6 for each row begin |
|
|
|
insert into t7(a) values(1); |
|
|
|
set @@global.binlog_direct_non_transactional_updates= FALSE; |
|
|
|
set @@session.binlog_direct_non_transactional_updates= TRUE; |
|
|
|
insert into t7(a) values(2); |
|
|
|
insert into t8(a) values(3); |
|
|
|
end | |
|
|
|
delimiter ;| |
|
|
|
|
|
|
|
--echo # Test that the session variable 'binlog_format' is read-only |
|
|
|
--echo # in sub-statements. |
|
|
|
--echo # Test that the session variable |
|
|
|
--echo # 'binlog_direct_non_transactional_updates' is |
|
|
|
--echo # read-only in sub-statements. |
|
|
|
--echo # Current session value is FALSE. |
|
|
|
--error ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_DIRECT |
|
|
|
insert into t6(a,b) values(1,1); |
|
|
|
SELECT @@session.binlog_direct_non_transactional_updates; |
|
|
|
|