Remove the table_map_version code, as it is completely unused. --- sql/log.cc | 40 ++-------------------------------------- sql/log.h | 10 ---------- sql/log_event.h | 5 ++--- sql/sql_class.cc | 2 -- sql/sql_load.cc | 2 -- sql/table.cc | 10 +--------- sql/table.h | 1 - 7 files changed, 5 insertions(+), 65 deletions(-) Index: work-5.1-groupcommit/sql/log.cc =================================================================== --- work-5.1-groupcommit.orig/sql/log.cc 2010-04-30 06:37:36.000000000 +0200 +++ work-5.1-groupcommit/sql/log.cc 2010-04-30 06:42:20.000000000 +0200 @@ -1438,11 +1438,6 @@ binlog_flush_trx_cache(THD *thd, binlog_ error= mysql_bin_log.write_transaction_to_binlog(thd, trx_data, end_ev); trx_data->reset(); - /* - We need to step the table map version after writing the - transaction cache to disk. - */ - mysql_bin_log.update_table_map_version(); statistic_increment(binlog_cache_use, &LOCK_status); if (trans_log->disk_writes != 0) { @@ -1507,13 +1502,6 @@ binlog_truncate_trx_cache(THD *thd, binl else // ...statement trx_data->truncate(trx_data->before_stmt_pos); - /* - We need to step the table map version on a rollback to ensure - that a new table map event is generated instead of the one that - was written to the thrown-away transaction cache. - */ - mysql_bin_log.update_table_map_version(); - DBUG_ASSERT(thd->binlog_get_pending_rows_event() == NULL); DBUG_RETURN(error); } @@ -2488,7 +2476,7 @@ const char *MYSQL_LOG::generate_name(con MYSQL_BIN_LOG::MYSQL_BIN_LOG() :bytes_written(0), prepared_xids(0), file_id(1), open_count(1), - need_start_event(TRUE), m_table_map_version(0), + need_start_event(TRUE), is_relay_log(0), description_event_for_exec(0), description_event_for_queue(0) { @@ -4137,7 +4125,6 @@ int THD::binlog_write_table_map(TABLE *t DBUG_RETURN(error); binlog_table_maps++; - table->s->table_map_version= mysql_bin_log.table_map_version(); DBUG_RETURN(0); } @@ -4229,9 +4216,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_row /* If we are writing to the log file directly, we could avoid - locking the log. This does not work since we need to step the - m_table_map_version below, and that change has to be protected - by the LOCK_log mutex. + locking the log. */ pthread_mutex_lock(&LOCK_log); @@ -4245,24 +4230,6 @@ MYSQL_BIN_LOG::flush_and_set_pending_row DBUG_RETURN(1); } - /* - We step the table map version if we are writing an event - representing the end of a statement. We do this regardless of - wheather we write to the transaction cache or to directly to the - file. - - In an ideal world, we could avoid stepping the table map version - if we were writing to a transaction cache, since we could then - reuse the table map that was written earlier in the transaction - cache. This does not work since STMT_END_F implies closing all - table mappings on the slave side. - - TODO: Find a solution so that table maps does not have to be - written several times within a transaction. - */ - if (pending->get_flags(Rows_log_event::STMT_END_F)) - ++m_table_map_version; - delete pending; if (file == &log_file) @@ -4474,9 +4441,6 @@ err: set_write_error(thd); } - if (event_info->flags & LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F) - ++m_table_map_version; - pthread_mutex_unlock(&LOCK_log); DBUG_RETURN(error); } Index: work-5.1-groupcommit/sql/log.h =================================================================== --- work-5.1-groupcommit.orig/sql/log.h 2010-04-30 06:30:10.000000000 +0200 +++ work-5.1-groupcommit/sql/log.h 2010-04-30 06:42:20.000000000 +0200 @@ -273,8 +273,6 @@ class MYSQL_BIN_LOG: public TC_LOG, priv */ bool no_auto_events; - ulonglong m_table_map_version; - int write_to_file(IO_CACHE *cache); /* This is used to start writing to a new log file. The difference from @@ -315,14 +313,6 @@ public: void unlog(ulong cookie, my_xid xid); int recover(IO_CACHE *log, Format_description_log_event *fdle); #if !defined(MYSQL_CLIENT) - bool is_table_mapped(TABLE *table) const - { - return table->s->table_map_version == table_map_version(); - } - - ulonglong table_map_version() const { return m_table_map_version; } - void update_table_map_version() { ++m_table_map_version; } - int flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event); int remove_pending_rows_event(THD *thd); Index: work-5.1-groupcommit/sql/log_event.h =================================================================== --- work-5.1-groupcommit.orig/sql/log_event.h 2010-04-30 06:30:10.000000000 +0200 +++ work-5.1-groupcommit/sql/log_event.h 2010-04-30 06:42:20.000000000 +0200 @@ -463,10 +463,9 @@ struct sql_ex_info #define LOG_EVENT_SUPPRESS_USE_F 0x8 /* - The table map version internal to the log should be increased after - the event has been written to the binary log. + This used to be LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F, but is now unused. */ -#define LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F 0x10 +#define LOG_EVENT_UNUSED1_F 0x10 /** @def LOG_EVENT_ARTIFICIAL_F Index: work-5.1-groupcommit/sql/sql_class.cc =================================================================== --- work-5.1-groupcommit.orig/sql/sql_class.cc 2010-04-30 06:30:10.000000000 +0200 +++ work-5.1-groupcommit/sql/sql_class.cc 2010-04-30 06:42:20.000000000 +0200 @@ -3773,7 +3773,6 @@ int THD::binlog_flush_pending_rows_event if (stmt_end) { pending->set_flags(Rows_log_event::STMT_END_F); - pending->flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F; binlog_table_maps= 0; } @@ -3901,7 +3900,6 @@ int THD::binlog_query(THD::enum_binlog_q { Query_log_event qinfo(this, query_arg, query_len, is_trans, suppress_use, errcode); - qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F; /* Binlog table maps will be irrelevant after a Query_log_event (they are just removed on the slave side) so after the query Index: work-5.1-groupcommit/sql/sql_load.cc =================================================================== --- work-5.1-groupcommit.orig/sql/sql_load.cc 2010-04-30 06:30:10.000000000 +0200 +++ work-5.1-groupcommit/sql/sql_load.cc 2010-04-30 06:42:20.000000000 +0200 @@ -516,7 +516,6 @@ int mysql_load(THD *thd,sql_exchange *ex else { Delete_file_log_event d(thd, db, transactional_table); - d.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F; (void) mysql_bin_log.write(&d); } } @@ -698,7 +697,6 @@ static bool write_execute_load_query_log (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE : (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR), transactional_table, FALSE, errcode); - e.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F; return mysql_bin_log.write(&e); } Index: work-5.1-groupcommit/sql/table.cc =================================================================== --- work-5.1-groupcommit.orig/sql/table.cc 2010-04-30 06:30:10.000000000 +0200 +++ work-5.1-groupcommit/sql/table.cc 2010-04-30 06:42:20.000000000 +0200 @@ -297,13 +297,6 @@ TABLE_SHARE *alloc_table_share(TABLE_LIS share->version= refresh_version; /* - This constant is used to mark that no table map version has been - assigned. No arithmetic is done on the value: it will be - overwritten with a value taken from MYSQL_BIN_LOG. - */ - share->table_map_version= ~(ulonglong)0; - - /* Since alloc_table_share() can be called without any locking (for example, ha_create_table... functions), we do not assign a table map id here. Instead we assign a value that is not used @@ -367,10 +360,9 @@ void init_tmp_table_share(THD *thd, TABL share->frm_version= FRM_VER_TRUE_VARCHAR; /* - Temporary tables are not replicated, but we set up these fields + Temporary tables are not replicated, but we set up this fields anyway to be able to catch errors. */ - share->table_map_version= ~(ulonglong)0; share->cached_row_logging_check= -1; /* Index: work-5.1-groupcommit/sql/table.h =================================================================== --- work-5.1-groupcommit.orig/sql/table.h 2010-04-30 06:30:10.000000000 +0200 +++ work-5.1-groupcommit/sql/table.h 2010-04-30 06:42:20.000000000 +0200 @@ -433,7 +433,6 @@ typedef struct st_table_share bool waiting_on_cond; /* Protection against free */ bool deleting; /* going to delete this table */ ulong table_map_id; /* for row-based replication */ - ulonglong table_map_version; /* Cache for row-based replication table share checks that does not