summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/check.result3
-rw-r--r--mysql-test/t/check.test3
-rw-r--r--mysql-test/t/func_misc.test2
-rw-r--r--sql/sql_class.cc38
4 files changed, 27 insertions, 19 deletions
diff --git a/mysql-test/r/check.result b/mysql-test/r/check.result
index 60806e7393e..739eab2ed76 100644
--- a/mysql-test/r/check.result
+++ b/mysql-test/r/check.result
@@ -1,4 +1,5 @@
-drop table if exists t1;
+drop table if exists t1,t2;
+drop view if exists v1;
create table t1(n int not null, key(n), key(n), key(n), key(n));
check table t1 extended;
insert into t1 values (200000);
diff --git a/mysql-test/t/check.test b/mysql-test/t/check.test
index 8d9d70bd29a..eb72d75da3c 100644
--- a/mysql-test/t/check.test
+++ b/mysql-test/t/check.test
@@ -2,7 +2,8 @@ connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
--disable_warnings
-drop table if exists t1;
+drop table if exists t1,t2;
+drop view if exists v1;
--enable_warnings
# Add a lot of keys to slow down check
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index 8ff62f68e45..23b8db607b8 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -89,7 +89,9 @@ select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
#
# Test for BUG#9535
#
+--disable_warnings
create table t1 as select uuid(), length(uuid());
+--enable_warnings
show create table t1;
drop table t1;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 3e8b43f638e..e71f5fc6297 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -2873,6 +2873,27 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype,
if (int error= binlog_flush_pending_rows_event(TRUE))
DBUG_RETURN(error);
+ /*
+ If we are in statement mode and trying to log an unsafe statement,
+ we should print a warning.
+ */
+ if (lex->is_stmt_unsafe() &&
+ variables.binlog_format == BINLOG_FORMAT_STMT)
+ {
+ DBUG_ASSERT(this->query != NULL);
+ push_warning(this, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_BINLOG_UNSAFE_STATEMENT,
+ ER(ER_BINLOG_UNSAFE_STATEMENT));
+ if (!(binlog_flags & BINLOG_FLAG_UNSAFE_STMT_PRINTED))
+ {
+ char warn_buf[MYSQL_ERRMSG_SIZE];
+ my_snprintf(warn_buf, MYSQL_ERRMSG_SIZE, "%s Statement: %s",
+ ER(ER_BINLOG_UNSAFE_STATEMENT), this->query);
+ sql_print_warning(warn_buf);
+ binlog_flags|= BINLOG_FLAG_UNSAFE_STMT_PRINTED;
+ }
+ }
+
switch (qtype) {
case THD::ROW_QUERY_TYPE:
if (current_stmt_binlog_row_based)
@@ -2888,23 +2909,6 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype,
to how you treat this.
*/
case THD::STMT_QUERY_TYPE:
- if (lex->is_stmt_unsafe())
- {
- DBUG_ASSERT(this->query != NULL);
- push_warning(this, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_BINLOG_UNSAFE_STATEMENT,
- ER(ER_BINLOG_UNSAFE_STATEMENT));
- if (!(binlog_flags & BINLOG_FLAG_UNSAFE_STMT_PRINTED))
- {
-
- char warn_buf[MYSQL_ERRMSG_SIZE];
- my_snprintf(warn_buf, MYSQL_ERRMSG_SIZE, "%s Statement: %s",
- ER(ER_BINLOG_UNSAFE_STATEMENT), this->query);
- sql_print_warning(warn_buf);
- binlog_flags|= BINLOG_FLAG_UNSAFE_STMT_PRINTED;
- }
- }
-
/*
The MYSQL_LOG::write() function will set the STMT_END_F flag and
flush the pending rows event if necessary.