diff options
Diffstat (limited to 'sql/sql_class.cc')
| -rw-r--r-- | sql/sql_class.cc | 38 |
1 files changed, 38 insertions, 0 deletions
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 |
