Commit 455f754e authored by He Zhenxing's avatar He Zhenxing

Bug#53189 Table map version unused and can be removed

MYSQL_BIN_LOG m_table_map_version member and it's associated 
functions were not used in the logic of binlogging and replication,
this patch removed all related code.
parent 31a79ec3
...@@ -1440,11 +1440,6 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, ...@@ -1440,11 +1440,6 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data,
trx_data->has_incident()); trx_data->has_incident());
trx_data->reset(); 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); statistic_increment(binlog_cache_use, &LOCK_status);
if (trans_log->disk_writes != 0) if (trans_log->disk_writes != 0)
{ {
...@@ -1470,13 +1465,6 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data, ...@@ -1470,13 +1465,6 @@ binlog_end_trans(THD *thd, binlog_trx_data *trx_data,
} }
else // ...statement else // ...statement
trx_data->truncate(trx_data->before_stmt_pos); 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_ASSERT(thd->binlog_get_pending_rows_event() == NULL);
...@@ -2437,7 +2425,7 @@ const char *MYSQL_LOG::generate_name(const char *log_name, ...@@ -2437,7 +2425,7 @@ const char *MYSQL_LOG::generate_name(const char *log_name,
MYSQL_BIN_LOG::MYSQL_BIN_LOG() MYSQL_BIN_LOG::MYSQL_BIN_LOG()
:bytes_written(0), prepared_xids(0), file_id(1), open_count(1), :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), is_relay_log(0),
description_event_for_exec(0), description_event_for_queue(0) description_event_for_exec(0), description_event_for_queue(0)
{ {
...@@ -4078,7 +4066,6 @@ int THD::binlog_write_table_map(TABLE *table, bool is_trans) ...@@ -4078,7 +4066,6 @@ int THD::binlog_write_table_map(TABLE *table, bool is_trans)
DBUG_RETURN(error); DBUG_RETURN(error);
binlog_table_maps++; binlog_table_maps++;
table->s->table_map_version= mysql_bin_log.table_map_version();
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -4169,10 +4156,8 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd, ...@@ -4169,10 +4156,8 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd,
file= &trx_data->trans_log; file= &trx_data->trans_log;
/* /*
If we are writing to the log file directly, we could avoid If we are not writing to the log file directly, we could avoid
locking the log. This does not work since we need to step the locking the log.
m_table_map_version below, and that change has to be protected
by the LOCK_log mutex.
*/ */
pthread_mutex_lock(&LOCK_log); pthread_mutex_lock(&LOCK_log);
...@@ -4186,24 +4171,6 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd, ...@@ -4186,24 +4171,6 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd,
DBUG_RETURN(1); 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; delete pending;
if (file == &log_file) if (file == &log_file)
...@@ -4417,9 +4384,6 @@ err: ...@@ -4417,9 +4384,6 @@ err:
set_write_error(thd); set_write_error(thd);
} }
if (event_info->flags & LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F)
++m_table_map_version;
pthread_mutex_unlock(&LOCK_log); pthread_mutex_unlock(&LOCK_log);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
...@@ -272,8 +272,6 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG ...@@ -272,8 +272,6 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
*/ */
bool no_auto_events; bool no_auto_events;
ulonglong m_table_map_version;
int write_to_file(IO_CACHE *cache); int write_to_file(IO_CACHE *cache);
/* /*
This is used to start writing to a new log file. The difference from This is used to start writing to a new log file. The difference from
...@@ -314,14 +312,6 @@ public: ...@@ -314,14 +312,6 @@ public:
void unlog(ulong cookie, my_xid xid); void unlog(ulong cookie, my_xid xid);
int recover(IO_CACHE *log, Format_description_log_event *fdle); int recover(IO_CACHE *log, Format_description_log_event *fdle);
#if !defined(MYSQL_CLIENT) #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 flush_and_set_pending_rows_event(THD *thd, Rows_log_event* event);
int remove_pending_rows_event(THD *thd); int remove_pending_rows_event(THD *thd);
......
...@@ -463,10 +463,10 @@ struct sql_ex_info ...@@ -463,10 +463,10 @@ struct sql_ex_info
#define LOG_EVENT_SUPPRESS_USE_F 0x8 #define LOG_EVENT_SUPPRESS_USE_F 0x8
/* /*
The table map version internal to the log should be increased after Note: this is a place holder for the flag
the event has been written to the binary log. LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F (0x10), which is not used any
more, please do not reused this value for other flags.
*/ */
#define LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F 0x10
/** /**
@def LOG_EVENT_ARTIFICIAL_F @def LOG_EVENT_ARTIFICIAL_F
......
...@@ -3825,7 +3825,6 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end) ...@@ -3825,7 +3825,6 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end)
if (stmt_end) if (stmt_end)
{ {
pending->set_flags(Rows_log_event::STMT_END_F); pending->set_flags(Rows_log_event::STMT_END_F);
pending->flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
binlog_table_maps= 0; binlog_table_maps= 0;
} }
...@@ -3953,7 +3952,6 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, ...@@ -3953,7 +3952,6 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
{ {
Query_log_event qinfo(this, query_arg, query_len, is_trans, suppress_use, Query_log_event qinfo(this, query_arg, query_len, is_trans, suppress_use,
errcode); errcode);
qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
/* /*
Binlog table maps will be irrelevant after a Query_log_event Binlog table maps will be irrelevant after a Query_log_event
(they are just removed on the slave side) so after the query (they are just removed on the slave side) so after the query
......
...@@ -511,7 +511,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -511,7 +511,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
else else
{ {
Delete_file_log_event d(thd, db, transactional_table); Delete_file_log_event d(thd, db, transactional_table);
d.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
(void) mysql_bin_log.write(&d); (void) mysql_bin_log.write(&d);
} }
} }
...@@ -691,7 +690,6 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex, ...@@ -691,7 +690,6 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex,
(duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE : (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE :
(ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR), (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR),
transactional_table, FALSE, errcode); transactional_table, FALSE, errcode);
e.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
return mysql_bin_log.write(&e); return mysql_bin_log.write(&e);
} }
......
...@@ -296,13 +296,6 @@ TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key, ...@@ -296,13 +296,6 @@ TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key,
share->version= refresh_version; 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 Since alloc_table_share() can be called without any locking (for
example, ha_create_table... functions), we do not assign a table example, ha_create_table... functions), we do not assign a table
...@@ -366,11 +359,6 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key, ...@@ -366,11 +359,6 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
share->path.length= share->normalized_path.length= strlen(path); share->path.length= share->normalized_path.length= strlen(path);
share->frm_version= FRM_VER_TRUE_VARCHAR; share->frm_version= FRM_VER_TRUE_VARCHAR;
/*
Temporary tables are not replicated, but we set up these fields
anyway to be able to catch errors.
*/
share->table_map_version= ~(ulonglong)0;
share->cached_row_logging_check= -1; share->cached_row_logging_check= -1;
/* /*
......
...@@ -430,7 +430,6 @@ typedef struct st_table_share ...@@ -430,7 +430,6 @@ typedef struct st_table_share
bool name_lock, replace_with_name_lock; bool name_lock, replace_with_name_lock;
bool waiting_on_cond; /* Protection against free */ bool waiting_on_cond; /* Protection against free */
ulong table_map_id; /* for row-based replication */ ulong table_map_id; /* for row-based replication */
ulonglong table_map_version;
/* /*
Cache for row-based replication table share checks that does not Cache for row-based replication table share checks that does not
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment