Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
4a261c0f
Commit
4a261c0f
authored
Feb 09, 2010
by
Luis Soares
Browse files
Options
Browse Files
Download
Plain Diff
Manual merge from mysql-5.1-rep+2.
parents
0d566b3e
34b87425
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
168 additions
and
4 deletions
+168
-4
mysql-test/suite/binlog/r/binlog_format_switch_in_tmp_table.result
...t/suite/binlog/r/binlog_format_switch_in_tmp_table.result
+78
-0
mysql-test/suite/binlog/t/binlog_format_switch_in_tmp_table.test
...est/suite/binlog/t/binlog_format_switch_in_tmp_table.test
+76
-0
sql/sys_vars.cc
sql/sys_vars.cc
+14
-4
No files found.
mysql-test/suite/binlog/r/binlog_format_switch_in_tmp_table.result
0 → 100644
View file @
4a261c0f
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;
mysql-test/suite/binlog/t/binlog_format_switch_in_tmp_table.test
0 → 100644
View file @
4a261c0f
#
# 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
;
sql/sys_vars.cc
View file @
4a261c0f
...
...
@@ -241,15 +241,25 @@ static bool check_has_super(sys_var *self, THD *thd, set_var *var)
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
binlog, so we can't toggle to SBR in this connection.
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.
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
)
&&
thd
->
temporary_tables
)
if
(
thd
->
temporary_tables
&&
var
->
type
==
OPT_SESSION
&&
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
));
return
true
;
}
/*
if in a stored function/trigger, it's too late to change mode
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment