diff options
author | Bill Qu <bill.qu@Oracle.com> | 2013-04-27 16:04:54 +0800 |
---|---|---|
committer | Bill Qu <bill.qu@Oracle.com> | 2013-04-27 16:04:54 +0800 |
commit | 975968e245994b45b11ade869e51d7db39c1707f (patch) | |
tree | ebca14ab2f0888ea1aacc5f6f0c2aa130f1b68b8 | |
parent | 2557f2c4ca43b61c6f6653e41fc9e4bb68f7618a (diff) | |
download | mariadb-git-975968e245994b45b11ade869e51d7db39c1707f.tar.gz |
Bug #13004581 BLACKHOLE BINARY LOG WITH ROW IGNORES UPDATE AND DELETE STATEMENTS
When logging to the binary log in row, updates and deletes to a BLACKHOLE
engine table are skipped.
It is impossible to log binary log in row format for updates and deletes to
a BLACKHOLE engine table, as no row events can be generated in these cases.
After fix, generate a warning for UPDATE/DELETE statements that modify a
BLACKHOLE table, as row events are not logged in row format.
-rwxr-xr-x[-rw-r--r--] | sql-bench/example.bat | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | sql-bench/pwd.bat | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | sql-bench/uname.bat | 0 | ||||
-rw-r--r-- | sql/share/errmsg-utf8.txt | 2 | ||||
-rw-r--r-- | sql/sql_class.cc | 38 |
5 files changed, 40 insertions, 0 deletions
diff --git a/sql-bench/example.bat b/sql-bench/example.bat index 5bc1b458008..5bc1b458008 100644..100755 --- a/sql-bench/example.bat +++ b/sql-bench/example.bat diff --git a/sql-bench/pwd.bat b/sql-bench/pwd.bat index 104fd349d4e..104fd349d4e 100644..100755 --- a/sql-bench/pwd.bat +++ b/sql-bench/pwd.bat diff --git a/sql-bench/uname.bat b/sql-bench/uname.bat index dd9fe012a3d..dd9fe012a3d 100644..100755 --- a/sql-bench/uname.bat +++ b/sql-bench/uname.bat diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index e7ef0f74f1e..e3bdf3fc8ef 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6506,6 +6506,8 @@ ER_UNSUPPORTED_ENGINE ER_BINLOG_UNSAFE_AUTOINC_NOT_FIRST eng "INSERT into autoincrement field which is not the first part in the composed primary key is unsafe." +WARN_ON_BLOCKHOLE_IN_RBR + eng "Row events are not logged for %s statements that modify BLACKHOLE tables in row format. Table(s): '%-.192s'" # # End of 5.5 error messages. # diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 639127125ca..a2e30bda20a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4411,6 +4411,44 @@ int THD::decide_logging_format(TABLE_LIST *tables) DBUG_PRINT("info", ("decision: logging in %s format", is_current_stmt_binlog_format_row() ? "ROW" : "STATEMENT")); + + if (variables.binlog_format == BINLOG_FORMAT_ROW && + (lex->sql_command == SQLCOM_UPDATE || + lex->sql_command == SQLCOM_UPDATE_MULTI || + lex->sql_command == SQLCOM_DELETE || + lex->sql_command == SQLCOM_DELETE_MULTI)) + { + String table_names; + /* + Generate a warning for UPDATE/DELETE statements that modify a + BLACKHOLE table, as row events are not logged in row format. + */ + for (TABLE_LIST *table= tables; table; table= table->next_global) + { + if (table->placeholder()) + continue; + if (table->table->file->ht->db_type == DB_TYPE_BLACKHOLE_DB && + table->lock_type >= TL_WRITE_ALLOW_WRITE) + { + table_names.append(table->table_name); + table_names.append(","); + } + } + if (!table_names.is_empty()) + { + bool is_update= (lex->sql_command == SQLCOM_UPDATE || + lex->sql_command == SQLCOM_UPDATE_MULTI); + /* + Replace the last ',' with '.' for table_names + */ + table_names.replace(table_names.length()-1, 1, ".", 1); + push_warning_printf(this, MYSQL_ERROR::WARN_LEVEL_WARN, + WARN_ON_BLOCKHOLE_IN_RBR, + ER(WARN_ON_BLOCKHOLE_IN_RBR), + is_update ? "UPDATE" : "DELETE", + table_names.c_ptr()); + } + } } #ifndef DBUG_OFF else |