diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-02-05 01:08:08 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-02-05 01:08:08 +0300 |
commit | e7b332ba83f7ecd5dbc518df5d5f4c84fc542552 (patch) | |
tree | a1d34e4650281143b62067088c8965f2cceacb2d /sql/handler.cc | |
parent | 00dc9a6e70512905ef441274b0574fd2503f15b1 (diff) | |
parent | 08bcd2d8f67dcacd36abd2592fa2a59321abe7c2 (diff) | |
download | mariadb-git-e7b332ba83f7ecd5dbc518df5d5f4c84fc542552.tar.gz |
Merge next-mr -> next-4284.
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 41e35a007cf..c29a6568c3f 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2450,7 +2450,7 @@ int handler::update_auto_increment() variables->auto_increment_increment); auto_inc_intervals_count++; /* Row-based replication does not need to store intervals in binlog */ - if (mysql_bin_log.is_open() && !thd->current_stmt_binlog_row_based) + if (mysql_bin_log.is_open() && !thd->is_current_stmt_binlog_format_row()) thd->auto_inc_intervals_in_cur_stmt_for_binlog.append(auto_inc_interval_for_cur_row.minimum(), auto_inc_interval_for_cur_row.values(), variables->auto_increment_increment); @@ -4434,7 +4434,7 @@ static bool check_table_binlog_row_based(THD *thd, TABLE *table) DBUG_ASSERT(table->s->cached_row_logging_check == 0 || table->s->cached_row_logging_check == 1); - return (thd->current_stmt_binlog_row_based && + return (thd->is_current_stmt_binlog_format_row() && table->s->cached_row_logging_check && (thd->variables.option_bits & OPTION_BIN_LOG) && mysql_bin_log.is_open()); @@ -4491,7 +4491,21 @@ static int write_locked_table_maps(THD *thd) if (table->current_lock == F_WRLCK && check_table_binlog_row_based(thd, table)) { - int const has_trans= table->file->has_transactions(); + /* + We need to have a transactional behavior for SQLCOM_CREATE_TABLE + (e.g. CREATE TABLE... SELECT * FROM TABLE) in order to keep a + compatible behavior with the STMT based replication even when + the table is not transactional. In other words, if the operation + fails while executing the insert phase nothing is written to the + binlog. + + Note that at this point, we check the type of a set of tables to + create the table map events. In the function binlog_log_row(), + which calls the current function, we check the type of the table + of the current row. + */ + bool const has_trans= thd->lex->sql_command == SQLCOM_CREATE_TABLE || + table->file->has_transactions(); int const error= thd->binlog_write_table_map(table, has_trans); /* If an error occurs, it is the responsibility of the caller to @@ -4540,10 +4554,20 @@ static int binlog_log_row(TABLE* table, { bitmap_set_all(&cols); if (likely(!(error= write_locked_table_maps(thd)))) - error= (*log_func)(thd, table, table->file->has_transactions(), - &cols, table->s->fields, + { + /* + We need to have a transactional behavior for SQLCOM_CREATE_TABLE + (i.e. CREATE TABLE... SELECT * FROM TABLE) in order to keep a + compatible behavior with the STMT based replication even when + the table is not transactional. In other words, if the operation + fails while executing the insert phase nothing is written to the + binlog. + */ + bool const has_trans= thd->lex->sql_command == SQLCOM_CREATE_TABLE || + table->file->has_transactions(); + error= (*log_func)(thd, table, has_trans, &cols, table->s->fields, before_record, after_record); - + } if (!use_bitbuf) bitmap_free(&cols); } |