summaryrefslogtreecommitdiff
path: root/sql/sys_vars.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sys_vars.cc')
-rw-r--r--sql/sys_vars.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 085e8b8ee1e..9f8914ac3fe 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -242,15 +242,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
*/
@@ -325,7 +335,7 @@ static bool binlog_direct_check(sys_var *self, THD *thd, set_var *var)
return true;
if (var->type == OPT_GLOBAL ||
(thd->variables.binlog_direct_non_trans_update ==
- var->save_result.ulonglong_value))
+ static_cast<my_bool>(var->save_result.ulonglong_value)))
return false;
return false;
@@ -2965,14 +2975,14 @@ static bool check_locale(sys_var *self, THD *thd, set_var *var)
static Sys_var_struct Sys_lc_messages(
"lc_messages", "Set the language used for the error messages",
SESSION_VAR(lc_messages), NO_CMD_LINE,
- offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_messages),
+ my_offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_messages),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_locale));
static Sys_var_struct Sys_lc_time_names(
"lc_time_names", "Set the language used for the month "
"names and the days of the week",
SESSION_VAR(lc_time_names), NO_CMD_LINE,
- offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_time_names),
+ my_offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_time_names),
NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_locale));
static Sys_var_tz Sys_time_zone(