Commit f11b030e authored by Alfranio Correia's avatar Alfranio Correia

auto-merge mysql-trunk-bugfixing (local) --> mysql-trunk-bugfixing

parents 46bc8970 29c7acd6
......@@ -412,13 +412,41 @@ master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS `t2` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS `t2` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS `t2` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE IF NOT EXISTS `t2` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
master-bin.000001 # Query # # use `test`; DROP TEMPORARY TABLE IF EXISTS `t2` /* generated by server */
reset master;
......
......@@ -418,6 +418,9 @@ master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t2 values (100,100)
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; INSERT INTO t2 values (101,101)
master-bin.000001 # Query # # ROLLBACK
master-bin.000001 # Query # # use `test`; DROP TABLE t1,t2
reset master;
create table t1 (a int) engine=innodb;
......
......@@ -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;
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;
......@@ -193,8 +193,6 @@ Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it accesses a non-transactional table after accessing a transactional table within the same transaction.
INSERT INTO t_innodb VALUES(1);
COMMIT;
DROP TABLE t_myisam;
DROP TABLE t_innodb;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam
......@@ -214,8 +212,29 @@ master-bin.000001 # Query # # use `test`; INSERT INTO tmp1 VALUES(1)
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
master-bin.000001 # Xid # # COMMIT /* XID */
master-bin.000001 # Query # # use `test`; DROP TABLE t_myisam
master-bin.000001 # Query # # use `test`; DROP TABLE t_innodb
########################################################################
# VERIFY ITEM 8
########################################################################
SET BINLOG_FORMAT=MIXED;
BEGIN;
CREATE TEMPORARY TABLE tmp2 SELECT * FROM t_innodb;
INSERT INTO t_innodb VALUES(1);
INSERT INTO t_innodb VALUES(1);
ROLLBACK;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # BEGIN
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp2 SELECT * FROM t_innodb
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
master-bin.000001 # Query # # ROLLBACK
###################################################################################
# CHECK CONSISTENCY
###################################################################################
###################################################################################
# CLEAN UP
###################################################################################
DROP TABLE t_myisam;
DROP TABLE t_innodb;
......@@ -34,10 +34,13 @@
# the CREATE TEMPORARY is not logged and the DROP TEMPORARY is extended with
# the IF EXISTS clause.
#
# 7 - It also verifies if the CONNECTION_ID along with a non-transactional
# 7 - It verifies if the CONNECTION_ID along with a non-transactional
# table is written outside the transaction boundaries and is not classified
# as unsafe. See BUG#53075.
#
# 8 - It verifies if OPTION_KEEP_LOG is set and thus forcing to write the
# trx-cache to the binary log when an rollback is issued and only trx-tables
# were updated. See BUG#53421.
################################################################################
source include/master-slave.inc;
......@@ -186,18 +189,40 @@ INSERT INTO t_innodb VALUES(1);
INSERT INTO t_myisam VALUES(CONNECTION_ID());
INSERT INTO t_innodb VALUES(1);
COMMIT;
DROP TABLE t_myisam;
DROP TABLE t_innodb;
source include/show_binlog_events.inc;
--echo ########################################################################
--echo # VERIFY ITEM 8
--echo ########################################################################
#
# Before the patch for BUG#53421, nothing were written to the binary log on
# behalf of the transaction presented below:
#
SET BINLOG_FORMAT=MIXED;
let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
BEGIN;
CREATE TEMPORARY TABLE tmp2 SELECT * FROM t_innodb;
INSERT INTO t_innodb VALUES(1);
INSERT INTO t_innodb VALUES(1);
ROLLBACK;
source include/show_binlog_events.inc;
--echo ###################################################################################
--echo # CHECK CONSISTENCY
--echo ###################################################################################
connection master;
sync_slave_with_master;
connection master;
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/test-nmt-master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/test-nmt-slave.sql
--diff_files $MYSQLTEST_VARDIR/tmp/test-nmt-master.sql $MYSQLTEST_VARDIR/tmp/test-nmt-slave.sql
--echo ###################################################################################
--echo # CLEAN UP
--echo ###################################################################################
connection master;
DROP TABLE t_myisam;
DROP TABLE t_innodb;
sync_slave_with_master;
......@@ -6336,3 +6336,11 @@ ER_BINLOG_UNSAFE_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE
ER_BINLOG_UNSAFE_MIXED_STATEMENT
eng "Statements that read from both transactional (or a temporary table of any engine type) and non-transactional tables and write to any of them are unsafe."
ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN
eng "Cannot modify @@session.sql_log_bin inside a transaction"
ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN
eng "Cannot change the sql_log_bin inside a stored function or trigger"
......@@ -4007,9 +4007,9 @@ thr_lock_type read_lock_type_for_table(THD *thd,
prelocked mode we can't rely on OPTION_BIN_LOG flag in THD::options
bitmap to determine that binary logging is turned on as this bit can
be cleared before executing sub-statement. So instead we have to look
at THD::sql_log_bin_toplevel member.
at THD::variables::sql_log_bin member.
*/
bool log_on= mysql_bin_log.is_open() && thd->sql_log_bin_toplevel;
bool log_on= mysql_bin_log.is_open() && thd->variables.sql_log_bin;
ulong binlog_format= thd->variables.binlog_format;
if ((log_on == FALSE) || (binlog_format == BINLOG_FORMAT_ROW) ||
(table_list->table->s->table_category == TABLE_CATEGORY_LOG) ||
......
......@@ -491,7 +491,6 @@ THD::THD()
rli_fake(0),
lock_id(&main_lock_id),
user_time(0), in_sub_stmt(0),
sql_log_bin_toplevel(false),
binlog_unsafe_warning_flags(0), binlog_table_maps(0),
table_map_for_update(0),
arg_of_last_insert_id_function(FALSE),
......@@ -960,7 +959,11 @@ void THD::init(void)
update_charset();
reset_current_stmt_binlog_format_row();
bzero((char *) &status_var, sizeof(status_var));
sql_log_bin_toplevel= variables.option_bits & OPTION_BIN_LOG;
if (variables.sql_log_bin)
variables.option_bits|= OPTION_BIN_LOG;
else
variables.option_bits&= ~OPTION_BIN_LOG;
#if defined(ENABLED_DEBUG_SYNC)
/* Initialize the Debug Sync Facility. See debug_sync.cc. */
......@@ -4608,8 +4611,13 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
because the warnings should be printed only if the statement is
actually logged. When executing decide_logging_format(), we cannot
know for sure if the statement will be logged.
Besides, we should not try to print these warnings if it is not
possible to write statements to the binary log as it happens when
the execution is inside a function, or generaly speaking, when
the variables.option_bits & OPTION_BIN_LOG is false.
*/
if (sql_log_bin_toplevel)
if (variables.option_bits & OPTION_BIN_LOG)
issue_unsafe_warnings();
switch (qtype) {
......
......@@ -428,6 +428,7 @@ typedef struct system_variables
uint binlog_format; ///< binlog format for this thd (see enum_binlog_format)
my_bool binlog_direct_non_trans_update;
my_bool sql_log_bin;
uint completion_type;
uint query_cache_type;
uint tx_isolation;
......@@ -1672,8 +1673,6 @@ class THD :public Statement,
/* <> 0 if we are inside of trigger or stored function. */
uint in_sub_stmt;
/* TRUE when the current top has SQL_LOG_BIN ON */
bool sql_log_bin_toplevel;
/* container for handler's private per-connection data */
Ha_data ha_data[MAX_HA];
......
......@@ -2670,6 +2670,10 @@ case SQLCOM_PREPARE:
*/
lex->unlink_first_table(&link_to_local);
/* So that CREATE TEMPORARY TABLE gets to binlog at commit/rollback */
if (create_info.options & HA_LEX_CREATE_TMP_TABLE)
thd->variables.option_bits|= OPTION_KEEP_LOG;
/*
select_create is currently not re-execution friendly and
needs to be created for every execution of a PS/SP.
......
......@@ -2243,17 +2243,69 @@ static Sys_var_bit Sys_log_off(
SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_LOG_OFF,
DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super));
static bool fix_sql_log_bin(sys_var *self, THD *thd, enum_var_type type)
/**
This function sets the session variable thd->variables.sql_log_bin
to reflect changes to @@session.sql_log_bin.
@param[IN] self A pointer to the sys_var, i.e. Sys_log_binlog.
@param[IN] type The type either session or global.
@return @c FALSE.
*/
static bool fix_sql_log_bin_after_update(sys_var *self, THD *thd,
enum_var_type type)
{
if (type != OPT_GLOBAL && !thd->in_sub_stmt)
thd->sql_log_bin_toplevel= thd->variables.option_bits & OPTION_BIN_LOG;
return false;
if (type == OPT_SESSION)
{
if (thd->variables.sql_log_bin)
thd->variables.option_bits |= OPTION_BIN_LOG;
else
thd->variables.option_bits &= ~OPTION_BIN_LOG;
}
return FALSE;
}
static Sys_var_bit Sys_log_binlog(
/**
This function checks if the sql_log_bin can be changed,
what is possible if:
- the user is a super user;
- the set is not called from within a function/trigger;
- there is no on-going transaction.
@param[IN] self A pointer to the sys_var, i.e. Sys_log_binlog.
@param[IN] var A pointer to the set_var created by the parser.
@return @c FALSE if the change is allowed, otherwise @c TRUE.
*/
static bool check_sql_log_bin(sys_var *self, THD *thd, set_var *var)
{
if (check_has_super(self, thd, var))
return TRUE;
if (var->type == OPT_GLOBAL)
return FALSE;
/* If in a stored function/trigger, it's too late to change sql_log_bin. */
if (thd->in_sub_stmt)
{
my_error(ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN, MYF(0));
return TRUE;
}
/* Make the session variable 'sql_log_bin' read-only inside a transaction. */
if (thd->in_active_multi_stmt_transaction())
{
my_error(ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN, MYF(0));
return TRUE;
}
return FALSE;
}
static Sys_var_mybool Sys_log_binlog(
"sql_log_bin", "sql_log_bin",
SESSION_VAR(option_bits), NO_CMD_LINE, OPTION_BIN_LOG,
DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_has_super),
ON_UPDATE(fix_sql_log_bin));
SESSION_VAR(sql_log_bin), NO_CMD_LINE,
DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_sql_log_bin),
ON_UPDATE(fix_sql_log_bin_after_update));
static Sys_var_bit Sys_sql_warnings(
"sql_warnings", "sql_warnings",
......
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