Commit 735aac91 authored by Luis Soares's avatar Luis Soares

Manual merge from mysql-5.1-rep+2.

parents 87c0c9cf 32b6e904
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
MIXED
CREATE TABLE t1 (a VARCHAR(100));
CREATE TEMPORARY TABLE t2 (a VARCHAR(100));
# Test allow switching @@SESSION.binlog_format from MIXED to STATEMENT
# when there are open temp tables and we are logging in statement based format.
SET SESSION binlog_format = STATEMENT;
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
STATEMENT
# Test allow switching @@SESSION.binlog_format from STATEMENT to
# STATEMENT when there are open temp tables.
SET SESSION binlog_format = STATEMENT;
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
STATEMENT
INSERT INTO t1 VALUES ('statement based');
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
STATEMENT
# Test allow switching @@SESSION.binlog_format from STATEMENT to
# MIXED when there are open temp tables.
SET SESSION binlog_format = MIXED;
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
MIXED
# Test allow switching @@SESSION.binlog_format from MIXED to MIXED
# when there are open temp tables.
SET SESSION binlog_format = MIXED;
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
MIXED
INSERT INTO t2 VALUES (UUID());
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
MIXED
# Test forbit switching @@SESSION.binlog_format from MIXED to STATEMENT
# when there are open temp tables and we are logging in row based format.
SET SESSION binlog_format = STATEMENT;
ERROR HY000: Cannot switch out of the row-based binary log format when the session has open temporary tables
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
MIXED
SET SESSION binlog_format = ROW;
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
ROW
INSERT INTO t1 VALUES ('row based');
# Test allow switching @@SESSION.binlog_format from ROW to MIXED
# when there are open temp tables.
SET SESSION binlog_format = MIXED;
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
MIXED
INSERT INTO t1 VALUES ('row based');
# Test allow switching @@SESSION.binlog_format from MIXED to ROW
# when there are open temp tables.
SET SESSION binlog_format = ROW;
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
ROW
# Test allow switching @@SESSION.binlog_format from ROW to ROW
# when there are open temp tables.
SET SESSION binlog_format = ROW;
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
ROW
INSERT INTO t1 VALUES ('row based');
# Test forbit switching @@SESSION.binlog_format from ROW to STATEMENT
# when there are open temp tables.
SET SESSION binlog_format = STATEMENT;
ERROR HY000: Cannot switch out of the row-based binary log format when the session has open temporary tables
SELECT @@SESSION.binlog_format;
@@SESSION.binlog_format
ROW
DROP TEMPORARY TABLE t2;
DROP TABLE t1;
#
# Bug #45855 row events in binlog after switch from binlog_fmt=mix to stmt with open tmp tbl
# Bug #45856 can't switch from binlog_format=row to mix with open tmp tbl
# This test verfies if the program will generate ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
# error and forbid switching @@SESSION.binlog_format from MIXED or ROW to
# STATEMENT when there are open temp tables and we are logging in row format.
# There is no error in any other case.
#
source include/have_binlog_format_mixed.inc;
SELECT @@SESSION.binlog_format;
CREATE TABLE t1 (a VARCHAR(100));
CREATE TEMPORARY TABLE t2 (a VARCHAR(100));
--echo # Test allow switching @@SESSION.binlog_format from MIXED to STATEMENT
--echo # when there are open temp tables and we are logging in statement based format.
SET SESSION binlog_format = STATEMENT;
SELECT @@SESSION.binlog_format;
--echo # Test allow switching @@SESSION.binlog_format from STATEMENT to
--echo # STATEMENT when there are open temp tables.
SET SESSION binlog_format = STATEMENT;
SELECT @@SESSION.binlog_format;
INSERT INTO t1 VALUES ('statement based');
SELECT @@SESSION.binlog_format;
--echo # Test allow switching @@SESSION.binlog_format from STATEMENT to
--echo # MIXED when there are open temp tables.
SET SESSION binlog_format = MIXED;
SELECT @@SESSION.binlog_format;
--echo # Test allow switching @@SESSION.binlog_format from MIXED to MIXED
--echo # when there are open temp tables.
SET SESSION binlog_format = MIXED;
SELECT @@SESSION.binlog_format;
INSERT INTO t2 VALUES (UUID());
SELECT @@SESSION.binlog_format;
--echo # Test forbit switching @@SESSION.binlog_format from MIXED to STATEMENT
--echo # when there are open temp tables and we are logging in row based format.
--ERROR ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
SET SESSION binlog_format = STATEMENT;
SELECT @@SESSION.binlog_format;
SET SESSION binlog_format = ROW;
SELECT @@SESSION.binlog_format;
INSERT INTO t1 VALUES ('row based');
--echo # Test allow switching @@SESSION.binlog_format from ROW to MIXED
--echo # when there are open temp tables.
SET SESSION binlog_format = MIXED;
SELECT @@SESSION.binlog_format;
INSERT INTO t1 VALUES ('row based');
--echo # Test allow switching @@SESSION.binlog_format from MIXED to ROW
--echo # when there are open temp tables.
SET SESSION binlog_format = ROW;
SELECT @@SESSION.binlog_format;
--echo # Test allow switching @@SESSION.binlog_format from ROW to ROW
--echo # when there are open temp tables.
SET SESSION binlog_format = ROW;
SELECT @@SESSION.binlog_format;
INSERT INTO t1 VALUES ('row based');
--echo # Test forbit switching @@SESSION.binlog_format from ROW to STATEMENT
--echo # when there are open temp tables.
--ERROR ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
SET SESSION binlog_format = STATEMENT;
SELECT @@SESSION.binlog_format;
DROP TEMPORARY TABLE t2;
DROP TABLE t1;
...@@ -243,13 +243,23 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var) ...@@ -243,13 +243,23 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var)
/* /*
If RBR and open temporary tables, their CREATE TABLE may not be in the If RBR and open temporary tables, their CREATE TABLE may not be in the
binlog, so we can't toggle to SBR in this connection. binlog, so we can't toggle to SBR in this connection.
If binlog_format=MIXED, there are open temporary tables, and an unsafe
statement is executed, then subsequent statements are logged in row
format and hence changes to temporary tables may be lost. So we forbid
switching @@SESSION.binlog_format from MIXED to STATEMENT when there are
open temp tables and we are logging in row format.
*/ */
if ((thd->variables.binlog_format == BINLOG_FORMAT_ROW) && if (thd->temporary_tables && var->type == OPT_SESSION &&
thd->temporary_tables) var->save_result.ulonglong_value == BINLOG_FORMAT_STMT &&
((thd->variables.binlog_format == BINLOG_FORMAT_MIXED &&
thd->is_current_stmt_binlog_format_row()) ||
thd->variables.binlog_format == BINLOG_FORMAT_ROW))
{ {
my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0)); my_error(ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR, MYF(0));
return true; return true;
} }
/* /*
if in a stored function/trigger, it's too late to change mode if in a stored function/trigger, it's too late to change mode
*/ */
......
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