diff --git a/sql/log.cc b/sql/log.cc index 8af463440be..8f22e9accd1 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2607,6 +2607,13 @@ int THD::binlog_setup_trx_data() DBUG_RETURN(0); } +/* + Write a table map to the binary log. + + This function is called from ha_external_lock() after the storage + engine has registered for the transaction. + */ + int THD::binlog_write_table_map(TABLE *table, bool is_trans) { DBUG_ENTER("THD::binlog_write_table_map"); @@ -2623,10 +2630,6 @@ int THD::binlog_write_table_map(TABLE *table, bool is_trans) Table_map_log_event the_event(this, table, table->s->table_map_id, is_trans, flags); - /* - This function is called from ha_external_lock() after the storage - engine has registered for the transaction. - */ if (is_trans) trans_register_ha(this, options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN), &binlog_hton); diff --git a/sql/log_event.cc b/sql/log_event.cc index 4ed7fc463cc..1b21bee1635 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5073,7 +5073,9 @@ Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid, { /* We allow a special form of dummy event when the table, and cols - are null and the table id is ULONG_MAX. + are null and the table id is ULONG_MAX. This is a temporary + solution, to be able to terminate a started statement in the + binary log: the extreneous events will be removed in the future. */ DBUG_ASSERT(tbl_arg && tbl_arg->s && tid != ULONG_MAX || !tbl_arg && !cols && tid == ULONG_MAX); diff --git a/sql/log_event.h b/sql/log_event.h index 9a5fb7cd73b..d6ce354fbdf 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1833,36 +1833,6 @@ public: return m_rows_buf && m_cols.bitmap; } - /* - If there is no table map active for the event, write one to the - binary log. - - LOCK_log has to be aquired before calling this function. - - PARAMETERS - thd - Thread to use when writing the table map - - RETURN VALUE - Error code, or zero if write succeeded. - */ -#if !defined(MYSQL_CLIENT) && defined(HAVE_ROW_BASED_REPLICATION) -#if 0 - int maybe_write_table_map(THD *thd, IO_CACHE *file, MYSQL_LOG *log) const - { - /* - N.B., get_cache_stmt() returns the value of 'using_trans' that - was provided to the constructor, i.e., get_cache_stmt() == true - if and only if the table is transactional. - */ - - int result= 0; - if (!log->is_table_mapped(m_table)) - result= log->write_table_map(thd, file, m_table, get_cache_stmt()); - return result; - } -#endif -#endif - uint m_row_count; /* The number of rows added to the event */ protected: diff --git a/sql/sql_class.cc b/sql/sql_class.cc index d185216d84a..8ff36536743 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2532,12 +2532,14 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end) table maps written this far will be included in the table maps for the following statement. - See if we can replace this with a dummy, maybe constant, event. + TODO: Remove the need for a dummy event altogether. It can be + fixed if we can write table maps to a memory buffer before + writing the first binrow event. We can then flush and clear the + memory buffer with table map events before writing the first + binrow event. In the event of a crash, nothing is lost since + the table maps are only needed if there are binrow events. */ -#if 0 - static unsigned char memory[sizeof(Write_rows_log_event)]; - void *const ptr= &memory; -#endif + Rows_log_event *ev= new Write_rows_log_event(this, 0, ULONG_MAX, 0, FALSE); ev->set_flags(Rows_log_event::STMT_END_F);