mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
auto-merge mysql-trunk-bugfixing (local) --> mysql-trunk-bugfixing.merge
This commit is contained in:
@ -67,11 +67,8 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc
|
||||
SELECT sf_bug50192();
|
||||
sf_bug50192()
|
||||
1
|
||||
Warnings:
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly.
|
||||
DROP FUNCTION sf_bug50192;
|
||||
DROP TRIGGER tr_bug50192;
|
||||
DROP TABLE t1, t2;
|
||||
|
@ -1,5 +1,6 @@
|
||||
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;
|
||||
@ -8,116 +9,148 @@ ROW
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
@@session.binlog_direct_non_transactional_updates
|
||||
1
|
||||
SELECT @@session.sql_log_bin;
|
||||
@@session.sql_log_bin
|
||||
1
|
||||
SET AUTOCOMMIT=1;
|
||||
# Test that the session variable 'binlog_format' and
|
||||
# 'binlog_direct_non_transactional_updates' are
|
||||
# writable outside a transaction.
|
||||
# Current session values are ROW and FALSE, respectively.
|
||||
# Test that the session variable 'binlog_format',
|
||||
# 'binlog_direct_non_transactional_updates' and 'sql_log_bin'
|
||||
# are writable outside a transaction.
|
||||
# Current session values are ROW, FALSE, TRUE, respectively.
|
||||
set @@session.binlog_format= statement;
|
||||
set @@session.binlog_direct_non_transactional_updates= TRUE;
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
SELECT @@session.binlog_format;
|
||||
@@session.binlog_format
|
||||
STATEMENT
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
@@session.binlog_direct_non_transactional_updates
|
||||
1
|
||||
SELECT @@session.sql_log_bin;
|
||||
@@session.sql_log_bin
|
||||
0
|
||||
begin;
|
||||
# Test that the session variable 'binlog_format' and
|
||||
# 'binlog_direct_non_transactional_updates' are
|
||||
# Test that the session variable 'binlog_format',
|
||||
# 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
# read-only inside a transaction with no preceding updates.
|
||||
# Current session values are STATEMENT and TRUE, respectively.
|
||||
# Current session values are STATEMENT, TRUE, FALSE, respectively.
|
||||
set @@session.binlog_format= mixed;
|
||||
ERROR HY000: Cannot modify @@session.binlog_format inside a transaction
|
||||
set @@session.binlog_direct_non_transactional_updates= FALSE;
|
||||
ERROR HY000: Cannot modify @@session.binlog_direct_non_transactional_updates inside a transaction
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
ERROR HY000: Cannot modify @@session.sql_log_bin inside a transaction
|
||||
insert into t2 values (1);
|
||||
# Test that the session variable 'binlog_format' and
|
||||
# 'binlog_direct_non_transactional_updates' are
|
||||
# Test that the session variable 'binlog_format',
|
||||
# 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
# read-only inside a transaction with preceding transactional updates.
|
||||
# Current session values are STATEMENT and TRUE, respectively.
|
||||
# Current session values are STATEMENT, TRUE and FALSE, respectively.
|
||||
set @@session.binlog_format= row;
|
||||
ERROR HY000: Cannot modify @@session.binlog_format inside a transaction
|
||||
set @@session.binlog_direct_non_transactional_updates= FALSE;
|
||||
ERROR HY000: Cannot modify @@session.binlog_direct_non_transactional_updates inside a transaction
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
ERROR HY000: Cannot modify @@session.sql_log_bin inside a transaction
|
||||
commit;
|
||||
begin;
|
||||
insert into t1 values (2);
|
||||
# Test that the session variable 'binlog_format' and
|
||||
# 'binlog_direct_non_transactional_updates' are
|
||||
# Test that the session variable 'binlog_format'
|
||||
# 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
# read-only inside a transaction with preceding non-transactional updates.
|
||||
# Current session values are STATEMENT and TRUE, respectively.
|
||||
# Current session values are STATEMENT, TRUE, FALSE, respectively.
|
||||
set @@session.binlog_format= mixed;
|
||||
ERROR HY000: Cannot modify @@session.binlog_format inside a transaction
|
||||
set @@session.binlog_direct_non_transactional_updates= FALSE;
|
||||
ERROR HY000: Cannot modify @@session.binlog_direct_non_transactional_updates inside a transaction
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
ERROR HY000: Cannot modify @@session.sql_log_bin inside a transaction
|
||||
commit;
|
||||
# Test that the session variable 'binlog_format' and
|
||||
# 'binlog_direct_non_transactional_updates' are
|
||||
# Test that the session variable 'binlog_format',
|
||||
# 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
# writable when AUTOCOMMIT=0, before a transaction has started.
|
||||
# Current session values are STATEMENT and TRUE, respectively.
|
||||
# Current session values are STATEMENT, TRUE, FALSE, respectively.
|
||||
set AUTOCOMMIT=0;
|
||||
set @@session.binlog_format= row;
|
||||
set @@session.binlog_direct_non_transactional_updates= FALSE;
|
||||
set @@session.sql_log_bin= TRUE;
|
||||
SELECT @@session.binlog_format;
|
||||
@@session.binlog_format
|
||||
ROW
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
@@session.binlog_direct_non_transactional_updates
|
||||
0
|
||||
SELECT @@session.sql_log_bin;
|
||||
@@session.sql_log_bin
|
||||
1
|
||||
insert into t1 values (3);
|
||||
# Test that the session variable 'binlog_format' and
|
||||
# 'binlog_direct_non_transactional_updates' are
|
||||
# Test that the session variable 'binlog_format',
|
||||
# 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
# read-only inside an AUTOCOMMIT=0 transaction
|
||||
# with preceding non-transactional updates.
|
||||
# Current session values are ROW and FALSE, respectively.
|
||||
# Current session values are ROW, FALSE, TRUE, respectively.
|
||||
set @@session.binlog_format= statement;
|
||||
ERROR HY000: Cannot modify @@session.binlog_format inside a transaction
|
||||
set @@session.binlog_direct_non_transactional_updates= TRUE;
|
||||
ERROR HY000: Cannot modify @@session.binlog_direct_non_transactional_updates inside a transaction
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
ERROR HY000: Cannot modify @@session.sql_log_bin inside a transaction
|
||||
SELECT @@session.binlog_format;
|
||||
@@session.binlog_format
|
||||
ROW
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
@@session.binlog_direct_non_transactional_updates
|
||||
0
|
||||
SELECT @@session.sql_log_bin;
|
||||
@@session.sql_log_bin
|
||||
1
|
||||
commit;
|
||||
insert into t2 values (4);
|
||||
# Test that the session variable 'binlog_format' and
|
||||
# 'binlog_direct_non_transactional_updates' are
|
||||
# Test that the session variable 'binlog_format',
|
||||
# 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
# read-only inside an AUTOCOMMIT=0 transaction with
|
||||
# preceding transactional updates.
|
||||
# Current session values are ROW and FALSE, respectively.
|
||||
# Current session values are ROW, FALSE, TRUE, respectively.
|
||||
set @@session.binlog_format= statement;
|
||||
ERROR HY000: Cannot modify @@session.binlog_format inside a transaction
|
||||
set @@session.binlog_direct_non_transactional_updates= TRUE;
|
||||
ERROR HY000: Cannot modify @@session.binlog_direct_non_transactional_updates inside a transaction
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
ERROR HY000: Cannot modify @@session.sql_log_bin inside a transaction
|
||||
SELECT @@session.binlog_format;
|
||||
@@session.binlog_format
|
||||
ROW
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
@@session.binlog_direct_non_transactional_updates
|
||||
0
|
||||
SELECT @@session.sql_log_bin;
|
||||
@@session.sql_log_bin
|
||||
1
|
||||
commit;
|
||||
begin;
|
||||
insert into t2 values (5);
|
||||
# Test that the global variable 'binlog_format' and
|
||||
# 'binlog_direct_non_transactional_updates' are
|
||||
# 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
# writable inside a transaction.
|
||||
# Current session values are ROW and FALSE, respectively.
|
||||
# Current session values are ROW, FALSE, TRUE respectively.
|
||||
SELECT @@global.binlog_format;
|
||||
@@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;
|
||||
@ -153,6 +186,23 @@ ERROR HY000: Cannot change the binlog direct flag inside a stored function or tr
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
@@session.binlog_direct_non_transactional_updates
|
||||
0
|
||||
create table t9(a int, b int) engine= innodb;
|
||||
create table t10(a int) engine= innodb;
|
||||
create table t11(a int) engine= innodb;
|
||||
create trigger tr3 after insert on t9 for each row begin
|
||||
insert into t10(a) values(1);
|
||||
set @@session.sql_log_bin= TRUE;
|
||||
insert into t10(a) values(2);
|
||||
insert into t11(a) values(3);
|
||||
end |
|
||||
# Test that the session variable 'sql_log_bin' is
|
||||
# read-only in sub-statements.
|
||||
# Current session value is FALSE.
|
||||
insert into t9(a,b) values(1,1);
|
||||
ERROR HY000: Cannot change the sql_log_bin inside a stored function or trigger
|
||||
SELECT @@session.sql_log_bin;
|
||||
@@session.sql_log_bin
|
||||
1
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t3;
|
||||
@ -161,3 +211,6 @@ drop table t5;
|
||||
drop table t6;
|
||||
drop table t7;
|
||||
drop table t8;
|
||||
drop table t9;
|
||||
drop table t10;
|
||||
drop table t11;
|
||||
|
@ -10,107 +10,128 @@ 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;
|
||||
|
||||
SELECT @@session.binlog_format;
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
SELECT @@session.sql_log_bin;
|
||||
SET AUTOCOMMIT=1;
|
||||
--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.
|
||||
--echo # Test that the session variable 'binlog_format',
|
||||
--echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin'
|
||||
--echo # are writable outside a transaction.
|
||||
--echo # Current session values are ROW, FALSE, TRUE, respectively.
|
||||
set @@session.binlog_format= statement;
|
||||
set @@session.binlog_direct_non_transactional_updates= TRUE;
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
SELECT @@session.binlog_format;
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
SELECT @@session.sql_log_bin;
|
||||
|
||||
begin;
|
||||
--echo # Test that the session variable 'binlog_format' and
|
||||
--echo # 'binlog_direct_non_transactional_updates' are
|
||||
--echo # Test that the session variable 'binlog_format',
|
||||
--echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
--echo # read-only inside a transaction with no preceding updates.
|
||||
--echo # Current session values are STATEMENT and TRUE, respectively.
|
||||
--echo # Current session values are STATEMENT, TRUE, FALSE, 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;
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
|
||||
insert into t2 values (1);
|
||||
--echo # Test that the session variable 'binlog_format' and
|
||||
--echo # 'binlog_direct_non_transactional_updates' are
|
||||
--echo # Test that the session variable 'binlog_format',
|
||||
--echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
--echo # read-only inside a transaction with preceding transactional updates.
|
||||
--echo # Current session values are STATEMENT and TRUE, respectively.
|
||||
--echo # Current session values are STATEMENT, TRUE and FALSE, respectively.
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT
|
||||
set @@session.binlog_format= row;
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT
|
||||
set @@session.binlog_direct_non_transactional_updates= FALSE;
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
commit;
|
||||
|
||||
begin;
|
||||
insert into t1 values (2);
|
||||
--echo # Test that the session variable 'binlog_format' and
|
||||
--echo # 'binlog_direct_non_transactional_updates' are
|
||||
--echo # Test that the session variable 'binlog_format'
|
||||
--echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
--echo # read-only inside a transaction with preceding non-transactional updates.
|
||||
--echo # Current session values are STATEMENT and TRUE, respectively.
|
||||
--echo # Current session values are STATEMENT, TRUE, FALSE, 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;
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
commit;
|
||||
|
||||
--echo # Test that the session variable 'binlog_format' and
|
||||
--echo # 'binlog_direct_non_transactional_updates' are
|
||||
--echo # Test that the session variable 'binlog_format',
|
||||
--echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
--echo # writable when AUTOCOMMIT=0, before a transaction has started.
|
||||
--echo # Current session values are STATEMENT and TRUE, respectively.
|
||||
--echo # Current session values are STATEMENT, TRUE, FALSE, respectively.
|
||||
set AUTOCOMMIT=0;
|
||||
set @@session.binlog_format= row;
|
||||
set @@session.binlog_direct_non_transactional_updates= FALSE;
|
||||
set @@session.sql_log_bin= TRUE;
|
||||
SELECT @@session.binlog_format;
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
SELECT @@session.sql_log_bin;
|
||||
|
||||
insert into t1 values (3);
|
||||
--echo # Test that the session variable 'binlog_format' and
|
||||
--echo # 'binlog_direct_non_transactional_updates' are
|
||||
--echo # Test that the session variable 'binlog_format',
|
||||
--echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
--echo # read-only inside an AUTOCOMMIT=0 transaction
|
||||
--echo # with preceding non-transactional updates.
|
||||
--echo # Current session values are ROW and FALSE, respectively.
|
||||
--echo # Current session values are ROW, FALSE, TRUE, respectively.
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT
|
||||
set @@session.binlog_format= statement;
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT
|
||||
set @@session.binlog_direct_non_transactional_updates= TRUE;
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
SELECT @@session.binlog_format;
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
SELECT @@session.sql_log_bin;
|
||||
commit;
|
||||
|
||||
insert into t2 values (4);
|
||||
--echo # Test that the session variable 'binlog_format' and
|
||||
--echo # 'binlog_direct_non_transactional_updates' are
|
||||
--echo # Test that the session variable 'binlog_format',
|
||||
--echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
--echo # read-only inside an AUTOCOMMIT=0 transaction with
|
||||
--echo # preceding transactional updates.
|
||||
--echo # Current session values are ROW and FALSE, respectively.
|
||||
--echo # Current session values are ROW, FALSE, TRUE, respectively.
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT
|
||||
set @@session.binlog_format= statement;
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_DIRECT
|
||||
set @@session.binlog_direct_non_transactional_updates= TRUE;
|
||||
--error ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN
|
||||
set @@session.sql_log_bin= FALSE;
|
||||
SELECT @@session.binlog_format;
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
SELECT @@session.sql_log_bin;
|
||||
commit;
|
||||
|
||||
begin;
|
||||
insert into t2 values (5);
|
||||
--echo # Test that the global variable 'binlog_format' and
|
||||
--echo # 'binlog_direct_non_transactional_updates' are
|
||||
--echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
|
||||
--echo # writable inside a transaction.
|
||||
--echo # Current session values are ROW and FALSE, respectively.
|
||||
--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;
|
||||
@ -151,6 +172,25 @@ delimiter ;|
|
||||
insert into t6(a,b) values(1,1);
|
||||
SELECT @@session.binlog_direct_non_transactional_updates;
|
||||
|
||||
create table t9(a int, b int) engine= innodb;
|
||||
create table t10(a int) engine= innodb;
|
||||
create table t11(a int) engine= innodb;
|
||||
delimiter |;
|
||||
eval create trigger tr3 after insert on t9 for each row begin
|
||||
insert into t10(a) values(1);
|
||||
set @@session.sql_log_bin= TRUE;
|
||||
insert into t10(a) values(2);
|
||||
insert into t11(a) values(3);
|
||||
end |
|
||||
delimiter ;|
|
||||
|
||||
--echo # Test that the session variable 'sql_log_bin' is
|
||||
--echo # read-only in sub-statements.
|
||||
--echo # Current session value is FALSE.
|
||||
--error ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN
|
||||
insert into t9(a,b) values(1,1);
|
||||
SELECT @@session.sql_log_bin;
|
||||
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
drop table t3;
|
||||
@ -159,3 +199,6 @@ drop table t5;
|
||||
drop table t6;
|
||||
drop table t7;
|
||||
drop table t8;
|
||||
drop table t9;
|
||||
drop table t10;
|
||||
drop table t11;
|
||||
|
Reference in New Issue
Block a user