Commit 9b277235 authored by unknown's avatar unknown

WL#3339 (Issue warnings when statement-based replication may fail):

Fixing case where a false warning could be printed in mixed mode.
Also fixing some test cases that generated different result files as
a consequence of the patch.


mysql-test/r/check.result:
  Result change.
mysql-test/t/check.test:
  Dropping all views created in the test before trying to execute test.
mysql-test/t/func_misc.test:
  Disabling warning for unsafe statement since test is not concerned with
  this and there are tests that test this.
sql/sql_class.cc:
  Moving code to print warning for unsafe statement to look at logging
  *mode* instead of logging *format*. The latter one can print a false
  warning when executing in mixed mode and part of the statement is
  written in statement format (i.e., CREATE-SELECT).
parent 9d0549b3
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)); create table t1(n int not null, key(n), key(n), key(n), key(n));
check table t1 extended; check table t1 extended;
insert into t1 values (200000); insert into t1 values (200000);
......
...@@ -2,7 +2,8 @@ connect (con1,localhost,root,,); ...@@ -2,7 +2,8 @@ connect (con1,localhost,root,,);
connect (con2,localhost,root,,); connect (con2,localhost,root,,);
connection con1; connection con1;
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1,t2;
drop view if exists v1;
--enable_warnings --enable_warnings
# Add a lot of keys to slow down check # Add a lot of keys to slow down check
......
...@@ -89,7 +89,9 @@ select export_set(3, _latin1'foo', _utf8'bar', ',', 4); ...@@ -89,7 +89,9 @@ select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
# #
# Test for BUG#9535 # Test for BUG#9535
# #
--disable_warnings
create table t1 as select uuid(), length(uuid()); create table t1 as select uuid(), length(uuid());
--enable_warnings
show create table t1; show create table t1;
drop table t1; drop table t1;
......
...@@ -2873,22 +2873,12 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, ...@@ -2873,22 +2873,12 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype,
if (int error= binlog_flush_pending_rows_event(TRUE)) if (int error= binlog_flush_pending_rows_event(TRUE))
DBUG_RETURN(error); DBUG_RETURN(error);
switch (qtype) {
case THD::ROW_QUERY_TYPE:
if (current_stmt_binlog_row_based)
DBUG_RETURN(0);
/* Otherwise, we fall through */
case THD::MYSQL_QUERY_TYPE:
/* /*
Using this query type is a conveniece hack, since we have been If we are in statement mode and trying to log an unsafe statement,
moving back and forth between using RBR for replication of we should print a warning.
system tables and not using it.
Make sure to change in check_table_binlog_row_based() according
to how you treat this.
*/ */
case THD::STMT_QUERY_TYPE: if (lex->is_stmt_unsafe() &&
if (lex->is_stmt_unsafe()) variables.binlog_format == BINLOG_FORMAT_STMT)
{ {
DBUG_ASSERT(this->query != NULL); DBUG_ASSERT(this->query != NULL);
push_warning(this, MYSQL_ERROR::WARN_LEVEL_WARN, push_warning(this, MYSQL_ERROR::WARN_LEVEL_WARN,
...@@ -2896,7 +2886,6 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, ...@@ -2896,7 +2886,6 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype,
ER(ER_BINLOG_UNSAFE_STATEMENT)); ER(ER_BINLOG_UNSAFE_STATEMENT));
if (!(binlog_flags & BINLOG_FLAG_UNSAFE_STMT_PRINTED)) if (!(binlog_flags & BINLOG_FLAG_UNSAFE_STMT_PRINTED))
{ {
char warn_buf[MYSQL_ERRMSG_SIZE]; char warn_buf[MYSQL_ERRMSG_SIZE];
my_snprintf(warn_buf, MYSQL_ERRMSG_SIZE, "%s Statement: %s", my_snprintf(warn_buf, MYSQL_ERRMSG_SIZE, "%s Statement: %s",
ER(ER_BINLOG_UNSAFE_STATEMENT), this->query); ER(ER_BINLOG_UNSAFE_STATEMENT), this->query);
...@@ -2905,6 +2894,21 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, ...@@ -2905,6 +2894,21 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype,
} }
} }
switch (qtype) {
case THD::ROW_QUERY_TYPE:
if (current_stmt_binlog_row_based)
DBUG_RETURN(0);
/* Otherwise, we fall through */
case THD::MYSQL_QUERY_TYPE:
/*
Using this query type is a conveniece hack, since we have been
moving back and forth between using RBR for replication of
system tables and not using it.
Make sure to change in check_table_binlog_row_based() according
to how you treat this.
*/
case THD::STMT_QUERY_TYPE:
/* /*
The MYSQL_LOG::write() function will set the STMT_END_F flag and The MYSQL_LOG::write() function will set the STMT_END_F flag and
flush the pending rows event if necessary. flush the pending rows event if necessary.
......
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