Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-03-26 12:08:18+02:00, tomas@stripped +11 -0
Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-new-ndb
into whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-new-rpl
MERGE: 1.2473.31.4
client/mysqlbinlog.cc@stripped, 2007-03-26 12:04:29+02:00, tomas@stripped +0
-0
Auto merged
MERGE: 1.149.1.1
sql/lock.cc@stripped, 2007-03-26 12:04:30+02:00, tomas@stripped +0 -0
Auto merged
MERGE: 1.104.1.1
sql/log.cc@stripped, 2007-03-26 12:08:15+02:00, tomas@stripped +1 -2
manual merge
MERGE: 1.267.3.1
sql/log_event.cc@stripped, 2007-03-26 12:08:15+02:00, tomas@stripped +0 -0
manual merge
MERGE: 1.266.4.3
sql/mysqld.cc@stripped, 2007-03-26 12:04:30+02:00, tomas@stripped +0 -0
Auto merged
MERGE: 1.619.2.1
sql/slave.cc@stripped, 2007-03-26 12:04:30+02:00, tomas@stripped +0 -0
Auto merged
MERGE: 1.293.1.18
sql/slave.h@stripped, 2007-03-26 12:04:30+02:00, tomas@stripped +0 -0
Auto merged
MERGE: 1.102.1.6
sql/sql_base.cc@stripped, 2007-03-26 12:04:30+02:00, tomas@stripped +0 -0
Auto merged
MERGE: 1.385.1.1
sql/sql_class.cc@stripped, 2007-03-26 12:04:31+02:00, tomas@stripped +0 -0
Auto merged
MERGE: 1.319.2.1
sql/sql_select.cc@stripped, 2007-03-26 12:04:31+02:00, tomas@stripped +0 -0
Auto merged
MERGE: 1.492.4.1
sql/table.h@stripped, 2007-03-26 12:04:31+02:00, tomas@stripped +0 -0
Auto merged
MERGE: 1.158.4.1
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: tomas
# Host: whalegate.ndb.mysql.com
# Root: /home/tomas/mysql-5.1-new-rpl/RESYNC
--- 1.105/sql/lock.cc 2007-03-09 11:15:44 +01:00
+++ 1.106/sql/lock.cc 2007-03-26 12:04:30 +02:00
@@ -582,7 +582,7 @@
goto end;
/* A temporary table does not have locks. */
- if (table->s->tmp_table == TMP_TABLE)
+ if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE)
goto end;
/* Get command lock or LOCK TABLES lock. Maybe empty for INSERT DELAYED. */
@@ -607,7 +607,7 @@
if (haystack->placeholder())
continue;
table2= haystack->table;
- if (table2->s->tmp_table == TMP_TABLE)
+ if (table2->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE)
continue;
/* All tables in list must be in lock. */
@@ -695,7 +695,7 @@
uint system_count= 0;
for (i=tables=lock_count=0 ; i < count ; i++)
{
- if (table_ptr[i]->s->tmp_table != TMP_TABLE)
+ if (table_ptr[i]->s->tmp_table != NON_TRANSACTIONAL_TMP_TABLE)
{
tables+=table_ptr[i]->file->lock_count();
lock_count++;
@@ -737,7 +737,7 @@
TABLE *table;
enum thr_lock_type lock_type;
- if ((table=table_ptr[i])->s->tmp_table == TMP_TABLE)
+ if ((table=table_ptr[i])->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE)
continue;
lock_type= table->reginfo.lock_type;
if (lock_type >= TL_WRITE_ALLOW_WRITE)
--- 1.270/sql/log.cc 2007-03-21 14:17:03 +01:00
+++ 1.271/sql/log.cc 2007-03-26 12:08:15 +02:00
@@ -1548,7 +1548,13 @@
(binlog_trx_data*) thd->ha_data[binlog_hton->slot];
DBUG_ASSERT(mysql_bin_log.is_open());
- if (trx_data->empty())
+ /*
+ The condition here has to be identical to the one inside
+ binlog_end_trans(), guarding the write of the transaction cache to
+ the binary log.
+ */
+ if (!(thd->options & (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT)) &&
+ trx_data->empty())
{
// we're here because trans_log was flushed in MYSQL_BIN_LOG::log_xid()
trx_data->reset();
@@ -2499,7 +2505,7 @@
/*
Set 'created' to 0, so that in next relay logs this event does not
trigger cleaning actions on the slave in
- Format_description_log_event::exec_event().
+ Format_description_log_event::apply_event_impl().
*/
description_event_for_queue->created= 0;
/* Don't set log_pos in event header */
@@ -3206,8 +3212,10 @@
{
tc_log_page_waits++;
pthread_mutex_lock(&LOCK_prep_xids);
- while (prepared_xids)
+ while (prepared_xids) {
+ DBUG_PRINT("info", ("prepared_xids=%lu", prepared_xids));
pthread_cond_wait(&COND_prep_xids, &LOCK_prep_xids);
+ }
pthread_mutex_unlock(&LOCK_prep_xids);
}
@@ -5061,8 +5069,10 @@
{
pthread_mutex_lock(&LOCK_prep_xids);
DBUG_ASSERT(prepared_xids > 0);
- if (--prepared_xids == 0)
+ if (--prepared_xids == 0) {
+ DBUG_PRINT("info", ("prepared_xids=%lu", prepared_xids));
pthread_cond_signal(&COND_prep_xids);
+ }
pthread_mutex_unlock(&LOCK_prep_xids);
rotate_and_purge(0); // as ::write() did not rotate
}
--- 1.271/sql/log_event.cc 2007-03-19 22:37:30 +01:00
+++ 1.272/sql/log_event.cc 2007-03-26 12:08:15 +02:00
@@ -75,8 +75,7 @@
~Write_on_release_cache()
{
- if (!my_b_copy_to_file(m_cache, m_file))
- reinit_io_cache(m_cache, WRITE_CACHE, 0L, FALSE, TRUE);
+ copy_event_cache_to_file_and_reinit(m_cache, m_file);
if (m_flags | FLUSH_F)
fflush(m_file);
}
@@ -88,9 +87,10 @@
operator&()
DESCRIPTION
- Function to return a pointer to the internal, so that the object
- can be treated as a IO_CACHE and used with the my_b_* IO_CACHE
- functions
+
+ Function to return a pointer to the internal cache, so that the
+ object can be treated as a IO_CACHE and used with the my_b_*
+ IO_CACHE functions
RETURN VALUE
A pointer to the internal IO_CACHE.
@@ -531,25 +531,19 @@
#ifndef MYSQL_CLIENT
#ifdef HAVE_REPLICATION
-/*
- Log_event::exec_event()
-*/
-
-int Log_event::exec_event(struct st_relay_log_info* rli)
+int Log_event::do_update_pos(RELAY_LOG_INFO *rli)
{
- DBUG_ENTER("Log_event::exec_event");
-
/*
- rli is null when (as far as I (Guilhem) know)
- the caller is
- Load_log_event::exec_event *and* that one is called from
- Execute_load_log_event::exec_event.
- In this case, we don't do anything here ;
- Execute_load_log_event::exec_event will call Log_event::exec_event
- again later with the proper rli.
- Strictly speaking, if we were sure that rli is null
- only in the case discussed above, 'if (rli)' is useless here.
- But as we are not 100% sure, keep it for now.
+ rli is null when (as far as I (Guilhem) know) the caller is
+ Load_log_event::do_apply_event *and* that one is called from
+ Execute_load_log_event::do_apply_event. In this case, we don't
+ do anything here ; Execute_load_log_event::do_apply_event will
+ call Log_event::do_apply_event again later with the proper rli.
+ Strictly speaking, if we were sure that rli is null only in the
+ case discussed above, 'if (rli)' is useless here. But as we are
+ not 100% sure, keep it for now.
+
+ Matz: I don't think we will need this check with this refactoring.
*/
if (rli)
{
@@ -584,18 +578,37 @@
{
rli->inc_group_relay_log_pos(log_pos);
flush_relay_log_info(rli);
- /*
- Note that Rotate_log_event::exec_event() does not call this
- function, so there is no chance that a fake rotate event resets
- last_master_timestamp.
- Note that we update without mutex (probably ok - except in some very
- rare cases, only consequence is that value may take some time to
- display in Seconds_Behind_Master - not critical).
+ /*
+ Note that Rotate_log_event::do_apply_event() does not call
+ this function, so there is no chance that a fake rotate event
+ resets last_master_timestamp. Note that we update without
+ mutex (probably ok - except in some very rare cases, only
+ consequence is that value may take some time to display in
+ Seconds_Behind_Master - not critical).
*/
rli->last_master_timestamp= when;
}
}
- DBUG_RETURN(0);
+
+ return 0; // Cannot fail currently
+}
+
+
+Log_event::enum_skip_reason
+Log_event::do_shall_skip(RELAY_LOG_INFO *rli)
+{
+ DBUG_PRINT("info", ("ev->server_id=%lu, ::server_id=%lu,"
+ " rli->replicate_same_server_id=%d,"
+ " rli->slave_skip_counter=%d",
+ (ulong) server_id, (ulong) ::server_id,
+ rli->replicate_same_server_id,
+ rli->slave_skip_counter));
+ if (server_id == ::server_id && !rli->replicate_same_server_id)
+ return EVENT_SKIP_IGNORE;
+ else if (rli->slave_skip_counter > 0)
+ return EVENT_SKIP_COUNT;
+ else
+ return EVENT_SKIP_NOT;
}
@@ -743,7 +756,7 @@
ulong data_len;
int result=0;
char buf[LOG_EVENT_MINIMAL_HEADER_LEN];
- DBUG_ENTER("read_log_event");
+ DBUG_ENTER("Log_event::read_log_event");
if (log_lock)
pthread_mutex_lock(log_lock);
@@ -818,7 +831,7 @@
const Format_description_log_event
*description_event)
#endif
{
- DBUG_ENTER("Log_event::read_log_event(IO_CACHE *, Format_description_log_event *");
+ DBUG_ENTER("Log_event::read_log_event");
DBUG_ASSERT(description_event != 0);
char head[LOG_EVENT_MINIMAL_HEADER_LEN];
/*
@@ -1888,27 +1901,28 @@
/*
- Query_log_event::exec_event()
+ Query_log_event::do_apply_event()
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-int Query_log_event::exec_event(struct st_relay_log_info* rli)
+int Query_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
- return exec_event(rli, query, q_len);
+ return do_apply_event(rli, query, q_len);
}
-int Query_log_event::exec_event(struct st_relay_log_info* rli,
- const char *query_arg, uint32 q_len_arg)
+int Query_log_event::do_apply_event(RELAY_LOG_INFO const *rli,
+ const char *query_arg, uint32 q_len_arg)
{
LEX_STRING new_db;
int expected_error,actual_error= 0;
/*
- Colleagues: please never free(thd->catalog) in MySQL. This would lead to
- bugs as here thd->catalog is a part of an alloced block, not an entire
- alloced block (see Query_log_event::exec_event()). Same for thd->db.
- Thank you.
+ Colleagues: please never free(thd->catalog) in MySQL. This would
+ lead to bugs as here thd->catalog is a part of an alloced block,
+ not an entire alloced block (see
+ Query_log_event::do_apply_event()). Same for thd->db. Thank
+ you.
*/
thd->catalog= catalog_len ? (char *) catalog : (char *)"";
new_db.length= db_len;
@@ -1927,11 +1941,11 @@
END of the current log event (COMMIT). We save it in rli so that InnoDB can
access it.
*/
- rli->future_group_master_log_pos= log_pos;
+ const_cast<RELAY_LOG_INFO*>(rli)->future_group_master_log_pos= log_pos;
DBUG_PRINT("info", ("log_pos: %lu", (ulong) log_pos));
- clear_all_errors(thd, rli);
- rli->clear_tables_to_lock();
+ clear_all_errors(thd, const_cast<RELAY_LOG_INFO*>(rli));
+ const_cast<RELAY_LOG_INFO*>(rli)->clear_tables_to_lock();
/*
Note: We do not need to execute reset_one_shot_variables() if this
@@ -1940,8 +1954,8 @@
its companion query. If the SET is ignored because of
db_ok(), the companion query will also be ignored, and if
the companion query is ignored in the db_ok() test of
- ::exec_event(), then the companion SET also have so we
- don't need to reset_one_shot_variables().
+ ::do_apply_event(), then the companion SET also have so
+ we don't need to reset_one_shot_variables().
*/
if (rpl_filter->db_ok(thd->db))
{
@@ -2056,7 +2070,7 @@
to check/fix it.
*/
if (mysql_test_parse_for_slave(thd, thd->query, thd->query_length))
- clear_all_errors(thd, rli); /* Can ignore query */
+ clear_all_errors(thd, const_cast<RELAY_LOG_INFO*>(rli)); /* Can ignore
query */
else
{
slave_print_msg(ERROR_LEVEL, rli, expected_error,
@@ -2107,7 +2121,7 @@
ignored_error_code(actual_error))
{
DBUG_PRINT("info",("error ignored"));
- clear_all_errors(thd, rli);
+ clear_all_errors(thd, const_cast<RELAY_LOG_INFO*>(rli));
}
/*
Other cases: mostly we expected no error and get one.
@@ -2174,16 +2188,26 @@
thd->first_successful_insert_id_in_prev_stmt= 0;
thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0;
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
+ return thd->query_error;
+}
+
+int Query_log_event::do_update_pos(RELAY_LOG_INFO *rli)
+{
/*
- If there was an error we stop. Otherwise we increment positions. Note that
- we will not increment group* positions if we are just after a SET
- ONE_SHOT, because SET ONE_SHOT should not be separated from its following
- updating query.
- */
- return (thd->query_error ? thd->query_error :
- (thd->one_shot_set ? (rli->inc_event_relay_log_pos(),0) :
- Log_event::exec_event(rli)));
+ Note that we will not increment group* positions if we are just
+ after a SET ONE_SHOT, because SET ONE_SHOT should not be separated
+ from its following updating query.
+ */
+ if (thd->one_shot_set)
+ {
+ rli->inc_event_relay_log_pos();
+ return 0;
+ }
+ else
+ return Log_event::do_update_pos(rli);
}
+
+
#endif
@@ -2312,7 +2336,7 @@
/*
- Start_log_event_v3::exec_event()
+ Start_log_event_v3::do_apply_event()
The master started
@@ -2331,9 +2355,9 @@
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-int Start_log_event_v3::exec_event(struct st_relay_log_info* rli)
+int Start_log_event_v3::do_apply_event(RELAY_LOG_INFO const *rli)
{
- DBUG_ENTER("Start_log_event_v3::exec_event");
+ DBUG_ENTER("Start_log_event_v3::do_apply_event");
switch (binlog_version)
{
case 3:
@@ -2375,7 +2399,7 @@
/* this case is impossible */
DBUG_RETURN(1);
}
- DBUG_RETURN(Log_event::exec_event(rli));
+ DBUG_RETURN(0);
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@@ -2566,24 +2590,10 @@
}
#endif
-/*
- SYNOPSIS
- Format_description_log_event::exec_event()
-
- IMPLEMENTATION
- Save the information which describes the binlog's format, to be able to
- read all coming events.
- Call Start_log_event_v3::exec_event().
-*/
-
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-int Format_description_log_event::exec_event(struct st_relay_log_info* rli)
+int Format_description_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
- DBUG_ENTER("Format_description_log_event::exec_event");
-
- /* save the information describing this binlog */
- delete rli->relay_log.description_event_for_exec;
- rli->relay_log.description_event_for_exec= this;
+ DBUG_ENTER("Format_description_log_event::do_apply_event");
#ifdef USING_TRANSACTIONS
/*
@@ -2605,14 +2615,36 @@
"or ROLLBACK in relay log). A probable cause is that "
"the master died while writing the transaction to "
"its binary log, thus rolled back too.");
- rli->cleanup_context(thd, 1);
+ const_cast<RELAY_LOG_INFO*>(rli)->cleanup_context(thd, 1);
}
#endif
/*
- If this event comes from ourselves, there is no cleaning task to perform,
- we don't call Start_log_event_v3::exec_event() (this was just to update the
- log's description event).
+ If this event comes from ourselves, there is no cleaning task to
+ perform, we don't call Start_log_event_v3::do_apply_event()
+ (this was just to update the log's description event).
*/
+ if (server_id != (uint32) ::server_id)
+ {
+ /*
+ If the event was not requested by the slave i.e. the master sent
+ it while the slave asked for a position >4, the event will make
+ rli->group_master_log_pos advance. Say that the slave asked for
+ position 1000, and the Format_desc event's end is 96. Then in
+ the beginning of replication rli->group_master_log_pos will be
+ 0, then 96, then jump to first really asked event (which is
+ >96). So this is ok.
+ */
+ DBUG_RETURN(Start_log_event_v3::do_apply_event(rli));
+ }
+ DBUG_RETURN(0);
+}
+
+int Format_description_log_event::do_update_pos(RELAY_LOG_INFO *rli)
+{
+ /* save the information describing this binlog */
+ delete rli->relay_log.description_event_for_exec;
+ rli->relay_log.description_event_for_exec= this;
+
if (server_id == (uint32) ::server_id)
{
/*
@@ -2629,19 +2661,20 @@
the Intvar_log_event respectively.
*/
rli->inc_event_relay_log_pos();
- DBUG_RETURN(0);
+ return 0;
}
+ else
+ {
+ return Log_event::do_update_pos(rli);
+ }
+}
- /*
- If the event was not requested by the slave i.e. the master sent it while
- the slave asked for a position >4, the event will make
- rli->group_master_log_pos advance. Say that the slave asked for position
- 1000, and the Format_desc event's end is 96. Then in the beginning of
- replication rli->group_master_log_pos will be 0, then 96, then jump to
- first really asked event (which is >96). So this is ok.
- */
- DBUG_RETURN(Start_log_event_v3::exec_event(rli));
+Log_event::enum_skip_reason
+Format_description_log_event::do_shall_skip(RELAY_LOG_INFO *rli)
+{
+ return Log_event::EVENT_SKIP_NOT;
}
+
#endif
@@ -3155,30 +3188,32 @@
Does the data loading job when executing a LOAD DATA on the slave
SYNOPSIS
- Load_log_event::exec_event
- net
- rli
- use_rli_only_for_errors - if set to 1, rli is provided to
- Load_log_event::exec_event only for this
- function to have RPL_LOG_NAME and
- rli->last_slave_error, both being used by
- error reports. rli's position advancing
- is skipped (done by the caller which is
- Execute_load_log_event::exec_event).
- - if set to 0, rli is provided for full use,
- i.e. for error reports and position
- advancing.
+ Load_log_event::do_apply_event
+ net
+ rli
+ use_rli_only_for_errors - if set to 1, rli is provided to
+ Load_log_event::do_apply_event
+ only for this function to have
+ RPL_LOG_NAME and
+ rli->last_slave_error, both being
+ used by error reports. rli's
+ position advancing is skipped (done
+ by the caller which is
+ Execute_load_log_event::do_apply_event).
+ - if set to 0, rli is provided for
+ full use, i.e. for error reports and
+ position advancing.
DESCRIPTION
Does the data loading job when executing a LOAD DATA on the slave
-
+
RETURN VALUE
- 0 Success
+ 0 Success
1 Failure
*/
-int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
- bool use_rli_only_for_errors)
+int Load_log_event::do_apply_event(NET* net, RELAY_LOG_INFO const *rli,
+ bool use_rli_only_for_errors)
{
LEX_STRING new_db;
new_db.length= db_len;
@@ -3187,9 +3222,9 @@
DBUG_ASSERT(thd->query == 0);
thd->query_length= 0; // Should not be needed
thd->query_error= 0;
- clear_all_errors(thd, rli);
+ clear_all_errors(thd, const_cast<RELAY_LOG_INFO*>(rli));
- /* see Query_log_event::exec_event() and BUG#13360 */
+ /* see Query_log_event::do_apply_event() and BUG#13360 */
DBUG_ASSERT(!rli->m_table_map.count());
/*
Usually mysql_init_query() is called by mysql_parse(), but we need it here
@@ -3198,22 +3233,26 @@
mysql_init_query(thd, 0, 0);
if (!use_rli_only_for_errors)
{
- /* Saved for InnoDB, see comment in Query_log_event::exec_event() */
- rli->future_group_master_log_pos= log_pos;
+ /*
+ Saved for InnoDB, see comment in
+ Query_log_event::do_apply_event()
+ */
+ const_cast<RELAY_LOG_INFO*>(rli)->future_group_master_log_pos= log_pos;
DBUG_PRINT("info", ("log_pos: %lu", (ulong) log_pos));
}
/*
- We test replicate_*_db rules. Note that we have already prepared the file
- to load, even if we are going to ignore and delete it now. So it is
- possible that we did a lot of disk writes for nothing. In other words, a
- big LOAD DATA INFILE on the master will still consume a lot of space on
- the slave (space in the relay log + space of temp files: twice the space
- of the file to load...) even if it will finally be ignored.
- TODO: fix this; this can be done by testing rules in
- Create_file_log_event::exec_event() and then discarding Append_block and
- al. Another way is do the filtering in the I/O thread (more efficient: no
- disk writes at all).
+ We test replicate_*_db rules. Note that we have already prepared
+ the file to load, even if we are going to ignore and delete it
+ now. So it is possible that we did a lot of disk writes for
+ nothing. In other words, a big LOAD DATA INFILE on the master will
+ still consume a lot of space on the slave (space in the relay log
+ + space of temp files: twice the space of the file to load...)
+ even if it will finally be ignored. TODO: fix this; this can be
+ done by testing rules in Create_file_log_event::do_apply_event()
+ and then discarding Append_block and al. Another way is do the
+ filtering in the I/O thread (more efficient: no disk writes at
+ all).
Note: We do not need to execute reset_one_shot_variables() if this
@@ -3222,8 +3261,8 @@
its companion query. If the SET is ignored because of
db_ok(), the companion query will also be ignored, and if
the companion query is ignored in the db_ok() test of
- ::exec_event(), then the companion SET also have so we
- don't need to reset_one_shot_variables().
+ ::do_apply_event(), then the companion SET also have so
+ we don't need to reset_one_shot_variables().
*/
if (rpl_filter->db_ok(thd->db))
{
@@ -3419,7 +3458,7 @@
return 1;
}
- return ( use_rli_only_for_errors ? 0 : Log_event::exec_event(rli) );
+ return ( use_rli_only_for_errors ? 0 : Log_event::do_apply_event(rli) );
}
#endif
@@ -3513,6 +3552,7 @@
ident_offset = post_header_len;
set_if_smaller(ident_len,FN_REFLEN-1);
new_log_ident= my_strndup(buf + ident_offset, (uint) ident_len, MYF(MY_WME));
+ DBUG_PRINT("debug", ("new_log_ident: '%s'", new_log_ident));
DBUG_VOID_RETURN;
}
@@ -3532,8 +3572,20 @@
}
#endif
+/**
+ Helper function to detect if the event is inside a group.
+ */
+#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
+static bool is_in_group(THD *const thd, RELAY_LOG_INFO *const rli)
+{
+ return (thd->options & OPTION_BEGIN) != 0 ||
+ (rli->last_event_start_time > 0);
+}
+#endif
+
+
/*
- Rotate_log_event::exec_event()
+ Rotate_log_event::do_apply_event()
Got a rotate log event from the master
@@ -3550,34 +3602,49 @@
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
+int Rotate_log_event::do_update_pos(RELAY_LOG_INFO *rli)
{
- DBUG_ENTER("Rotate_log_event::exec_event");
+ DBUG_ENTER("Rotate_log_event::do_update_pos");
+#ifndef DBUG_OFF
+ char buf[32];
+#endif
+
+ DBUG_PRINT("info", ("server_id=%lu; ::server_id=%lu",
+ (ulong) this->server_id, (ulong) ::server_id));
+ DBUG_PRINT("info", ("new_log_ident: %s", this->new_log_ident));
+ DBUG_PRINT("info", ("pos: %s", llstr(this->pos, buf)));
pthread_mutex_lock(&rli->data_lock);
rli->event_relay_log_pos= my_b_tell(rli->cur_log);
/*
- If we are in a transaction: the only normal case is when the I/O thread was
- copying a big transaction, then it was stopped and restarted: we have this
- in the relay log:
+ If we are in a transaction or in a group: the only normal case is
+ when the I/O thread was copying a big transaction, then it was
+ stopped and restarted: we have this in the relay log:
+
BEGIN
...
ROTATE (a fake one)
...
COMMIT or ROLLBACK
- In that case, we don't want to touch the coordinates which correspond to
- the beginning of the transaction.
- Starting from 5.0.0, there also are some rotates from the slave itself, in
- the relay log.
+
+ In that case, we don't want to touch the coordinates which
+ correspond to the beginning of the transaction. Starting from
+ 5.0.0, there also are some rotates from the slave itself, in the
+ relay log, which shall not change the group positions.
*/
- if (!(thd->options & OPTION_BEGIN))
+ if ((server_id != ::server_id || rli->replicate_same_server_id) &&
+ !is_in_group(thd, rli))
{
+ DBUG_PRINT("info", ("old group_master_log_name: '%s' "
+ "old group_master_log_pos: %lu",
+ rli->group_master_log_name,
+ (ulong) rli->group_master_log_pos));
memcpy(rli->group_master_log_name, new_log_ident, ident_len+1);
rli->notify_group_master_log_name_update();
rli->group_master_log_pos= pos;
rli->group_relay_log_pos= rli->event_relay_log_pos;
- DBUG_PRINT("info", ("group_master_log_name: '%s' "
- "group_master_log_pos: %lu",
+ DBUG_PRINT("info", ("new group_master_log_name: '%s' "
+ "new group_master_log_pos: %lu",
rli->group_master_log_name,
(ulong) rli->group_master_log_pos));
/*
@@ -3596,8 +3663,27 @@
pthread_mutex_unlock(&rli->data_lock);
pthread_cond_broadcast(&rli->data_cond);
flush_relay_log_info(rli);
+
DBUG_RETURN(0);
}
+
+
+Log_event::enum_skip_reason
+Rotate_log_event::do_shall_skip(RELAY_LOG_INFO *rli)
+{
+ enum_skip_reason reason= Log_event::do_shall_skip(rli);
+
+ switch (reason) {
+ case Log_event::EVENT_SKIP_NOT:
+ case Log_event::EVENT_SKIP_COUNT:
+ return Log_event::EVENT_SKIP_NOT;
+
+ case Log_event::EVENT_SKIP_IGNORE:
+ return Log_event::EVENT_SKIP_IGNORE;
+ }
+ DBUG_ASSERT(0);
+}
+
#endif
@@ -3704,11 +3790,11 @@
/*
- Intvar_log_event::exec_event()
+ Intvar_log_event::do_apply_event()
*/
#if defined(HAVE_REPLICATION)&& !defined(MYSQL_CLIENT)
-int Intvar_log_event::exec_event(struct st_relay_log_info* rli)
+int Intvar_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
switch (type) {
case LAST_INSERT_ID_EVENT:
@@ -3719,9 +3805,33 @@
thd->force_one_auto_inc_interval(val);
break;
}
+ return 0;
+}
+
+int Intvar_log_event::do_update_pos(RELAY_LOG_INFO *rli)
+{
rli->inc_event_relay_log_pos();
return 0;
}
+
+
+Log_event::enum_skip_reason
+Intvar_log_event::do_shall_skip(RELAY_LOG_INFO *rli)
+{
+ /*
+ It is a common error to set the slave skip counter to 1 instead of
+ 2 when recovering from an insert which used a auto increment,
+ rand, or user var. Therefore, if the slave skip counter is 1, we
+ just say that this event should be skipped by ignoring it, meaning
+ that we do not change the value of the slave skip counter since it
+ will be decreased by the following insert event.
+ */
+ if (rli->slave_skip_counter == 1)
+ return Log_event::EVENT_SKIP_IGNORE;
+ else
+ return Log_event::do_shall_skip(rli);
+}
+
#endif
@@ -3784,13 +3894,37 @@
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-int Rand_log_event::exec_event(struct st_relay_log_info* rli)
+int Rand_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
thd->rand.seed1= (ulong) seed1;
thd->rand.seed2= (ulong) seed2;
+ return 0;
+}
+
+int Rand_log_event::do_update_pos(RELAY_LOG_INFO *rli)
+{
rli->inc_event_relay_log_pos();
return 0;
}
+
+
+Log_event::enum_skip_reason
+Rand_log_event::do_shall_skip(RELAY_LOG_INFO *rli)
+{
+ /*
+ It is a common error to set the slave skip counter to 1 instead of
+ 2 when recovering from an insert which used a auto increment,
+ rand, or user var. Therefore, if the slave skip counter is 1, we
+ just say that this event should be skipped by ignoring it, meaning
+ that we do not change the value of the slave skip counter since it
+ will be decreased by the following insert event.
+ */
+ if (rli->slave_skip_counter == 1)
+ return Log_event::EVENT_SKIP_IGNORE;
+ else
+ return Log_event::do_shall_skip(rli);
+}
+
#endif /* !MYSQL_CLIENT */
@@ -3857,12 +3991,12 @@
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-int Xid_log_event::exec_event(struct st_relay_log_info* rli)
+int Xid_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
/* For a slave Xid_log_event is COMMIT */
general_log_print(thd, COM_QUERY,
"COMMIT /* implicit, from Xid_log_event */");
- return end_trans(thd, COMMIT) || Log_event::exec_event(rli);
+ return end_trans(thd, COMMIT);
}
#endif /* !MYSQL_CLIENT */
@@ -4140,11 +4274,11 @@
/*
- User_var_log_event::exec_event()
+ User_var_log_event::do_apply_event()
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-int User_var_log_event::exec_event(struct st_relay_log_info* rli)
+int User_var_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
Item *it= 0;
CHARSET_INFO *charset;
@@ -4206,9 +4340,31 @@
e.update_hash(val, val_len, type, charset, DERIVATION_IMPLICIT, 0);
free_root(thd->mem_root,0);
+ return 0;
+}
+
+int User_var_log_event::do_update_pos(RELAY_LOG_INFO *rli)
+{
rli->inc_event_relay_log_pos();
return 0;
}
+
+Log_event::enum_skip_reason
+User_var_log_event::do_shall_skip(RELAY_LOG_INFO *rli)
+{
+ /*
+ It is a common error to set the slave skip counter to 1 instead
+ of 2 when recovering from an insert which used a auto increment,
+ rand, or user var. Therefore, if the slave skip counter is 1, we
+ just say that this event should be skipped by ignoring it, meaning
+ that we do not change the value of the slave skip counter since it
+ will be decreased by the following insert event.
+ */
+ if (rli->slave_skip_counter == 1)
+ return Log_event::EVENT_SKIP_IGNORE;
+ else
+ return Log_event::do_shall_skip(rli);
+}
#endif /* !MYSQL_CLIENT */
@@ -4248,7 +4404,7 @@
#ifndef MYSQL_CLIENT
Slave_log_event::Slave_log_event(THD* thd_arg,
- struct st_relay_log_info* rli)
+ RELAY_LOG_INFO* rli)
:Log_event(thd_arg, 0, 0) , mem_pool(0), master_host(0)
{
DBUG_ENTER("Slave_log_event");
@@ -4358,11 +4514,11 @@
#ifndef MYSQL_CLIENT
-int Slave_log_event::exec_event(struct st_relay_log_info* rli)
+int Slave_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
if (mysql_bin_log.is_open())
mysql_bin_log.write(this);
- return Log_event::exec_event(rli);
+ return 0;
}
#endif /* !MYSQL_CLIENT */
@@ -4391,21 +4547,21 @@
/*
- Stop_log_event::exec_event()
+ Stop_log_event::do_apply_event()
- The master stopped.
- We used to clean up all temporary tables but this is useless as, as the
- master has shut down properly, it has written all DROP TEMPORARY TABLE
- (prepared statements' deletion is TODO only when we binlog prep stmts).
- We used to clean up slave_load_tmpdir, but this is useless as it has been
- cleared at the end of LOAD DATA INFILE.
- So we have nothing to do here.
- The place were we must do this cleaning is in Start_log_event_v3::exec_event(),
- not here. Because if we come here, the master was sane.
+ The master stopped. We used to clean up all temporary tables but
+ this is useless as, as the master has shut down properly, it has
+ written all DROP TEMPORARY TABLE (prepared statements' deletion is
+ TODO only when we binlog prep stmts). We used to clean up
+ slave_load_tmpdir, but this is useless as it has been cleared at the
+ end of LOAD DATA INFILE. So we have nothing to do here. The place
+ were we must do this cleaning is in
+ Start_log_event_v3::do_apply_event(), not here. Because if we come
+ here, the master was sane.
*/
#ifndef MYSQL_CLIENT
-int Stop_log_event::exec_event(struct st_relay_log_info* rli)
+int Stop_log_event::do_update_pos(RELAY_LOG_INFO *rli)
{
/*
We do not want to update master_log pos because we get a rotate event
@@ -4423,6 +4579,7 @@
}
return 0;
}
+
#endif /* !MYSQL_CLIENT */
#endif /* HAVE_REPLICATION */
@@ -4613,11 +4770,11 @@
/*
- Create_file_log_event::exec_event()
+ Create_file_log_event::do_apply_event()
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
+int Create_file_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
char proc_info[17+FN_REFLEN+10], *fname_buf;
char *ext;
@@ -4679,7 +4836,7 @@
if (fd >= 0)
my_close(fd, MYF(0));
thd->proc_info= 0;
- return error ? 1 : Log_event::exec_event(rli);
+ return error == 0;
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@@ -4787,15 +4944,15 @@
}
/*
- Append_block_log_event::exec_event()
+ Append_block_log_event::do_apply_event()
*/
-int Append_block_log_event::exec_event(struct st_relay_log_info* rli)
+int Append_block_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
char proc_info[17+FN_REFLEN+10], *fname= proc_info+17;
int fd;
int error = 1;
- DBUG_ENTER("Append_block_log_event::exec_event");
+ DBUG_ENTER("Append_block_log_event::do_apply_event");
fname= strmov(proc_info, "Making temp file ");
slave_load_file_stem(fname, file_id, server_id, ".data");
@@ -4834,7 +4991,7 @@
if (fd >= 0)
my_close(fd, MYF(0));
thd->proc_info= 0;
- DBUG_RETURN(error ? error : Log_event::exec_event(rli));
+ DBUG_RETURN(error);
}
#endif
@@ -4918,18 +5075,18 @@
#endif
/*
- Delete_file_log_event::exec_event()
+ Delete_file_log_event::do_apply_event()
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
-int Delete_file_log_event::exec_event(struct st_relay_log_info* rli)
+int Delete_file_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
char fname[FN_REFLEN+10];
char *ext= slave_load_file_stem(fname, file_id, server_id, ".data");
(void) my_delete(fname, MYF(MY_WME));
strmov(ext, ".info");
(void) my_delete(fname, MYF(MY_WME));
- return Log_event::exec_event(rli);
+ return 0;
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@@ -5015,10 +5172,10 @@
/*
- Execute_load_log_event::exec_event()
+ Execute_load_log_event::do_apply_event()
*/
-int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
+int Execute_load_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
char fname[FN_REFLEN+10];
char *ext;
@@ -5049,14 +5206,15 @@
lev->thd = thd;
/*
- lev->exec_event should use rli only for errors
- i.e. should not advance rli's position.
- lev->exec_event is the place where the table is loaded (it calls
- mysql_load()).
+ lev->do_apply_event should use rli only for errors i.e. should
+ not advance rli's position.
+
+ lev->do_apply_event is the place where the table is loaded (it
+ calls mysql_load()).
*/
- rli->future_group_master_log_pos= log_pos;
- if (lev->exec_event(0,rli,1))
+ const_cast<RELAY_LOG_INFO*>(rli)->future_group_master_log_pos= log_pos;
+ if (lev->do_apply_event(0,rli,1))
{
/*
We want to indicate the name of the file that could not be loaded
@@ -5099,7 +5257,7 @@
my_close(fd, MYF(0));
end_io_cache(&file);
}
- return error ? error : Log_event::exec_event(rli);
+ return error;
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
@@ -5267,7 +5425,7 @@
int
-Execute_load_query_log_event::exec_event(struct st_relay_log_info* rli)
+Execute_load_query_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
char *p;
char *buf;
@@ -5304,7 +5462,7 @@
p= strmake(p, STRING_WITH_LEN(" INTO"));
p= strmake(p, query+fn_pos_end, q_len-fn_pos_end);
- error= Query_log_event::exec_event(rli, buf, p-buf);
+ error= Query_log_event::do_apply_event(rli, buf, p-buf);
/* Forging file name for deletion in same buffer */
*fname_end= 0;
@@ -5624,7 +5782,7 @@
the master does not have a default value (and isn't nullable)
*/
static int
-unpack_row(RELAY_LOG_INFO *rli,
+unpack_row(RELAY_LOG_INFO const *rli,
TABLE *table, uint const colcnt,
char const *row, MY_BITMAP const *cols,
char const **row_end, ulong *master_reclength,
@@ -5730,17 +5888,17 @@
DBUG_RETURN(error);
}
-int Rows_log_event::exec_event(st_relay_log_info *rli)
+int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
- DBUG_ENTER("Rows_log_event::exec_event(st_relay_log_info*)");
+ DBUG_ENTER("Rows_log_event::do_apply_event(st_relay_log_info*)");
int error= 0;
char const *row_start= (char const *)m_rows_buf;
/*
- If m_table_id == ~0UL, then we have a dummy event that does
- not contain any data. In that case, we just remove all tables in
- the tables_to_lock list, close the thread tables, step the relay
- log position, and return with success.
+ If m_table_id == ~0UL, then we have a dummy event that does not
+ contain any data. In that case, we just remove all tables in the
+ tables_to_lock list, close the thread tables, and return with
+ success. The relay log position will be stepped in
*/
if (m_table_id == ~0UL)
{
@@ -5750,16 +5908,16 @@
*/
DBUG_ASSERT(get_flags(STMT_END_F));
- rli->clear_tables_to_lock();
+ const_cast<RELAY_LOG_INFO*>(rli)->clear_tables_to_lock();
close_thread_tables(thd);
thd->clear_error();
- rli->inc_event_relay_log_pos();
DBUG_RETURN(0);
}
/*
'thd' has been set by exec_relay_log_event(), just before calling
- exec_event(). We still check here to prevent future coding errors.
+ do_apply_event(). We still check here to prevent future coding
+ errors.
*/
DBUG_ASSERT(rli->sql_thd == thd);
@@ -5775,8 +5933,9 @@
/*
lock_tables() reads the contents of thd->lex, so they must be
- initialized. Contrary to in Table_map_log_event::exec_event() we don't
- call mysql_init_query() as that may reset the binlog format.
+ initialized. Contrary to in
+ Table_map_log_event::do_apply_event() we don't call
+ mysql_init_query() as that may reset the binlog format.
*/
lex_start(thd, NULL, 0);
@@ -5805,7 +5964,7 @@
"Error in %s event: when locking tables",
get_type_str());
}
- rli->clear_tables_to_lock();
+ const_cast<RELAY_LOG_INFO*>(rli)->clear_tables_to_lock();
DBUG_RETURN(error);
}
@@ -5826,7 +5985,8 @@
TABLE_LIST *tables= rli->tables_to_lock;
close_tables_for_reopen(thd, &tables);
- if ((error= open_tables(thd, &tables, &rli->tables_to_lock_count, 0)))
+ uint tables_count= rli->tables_to_lock_count;
+ if ((error= open_tables(thd, &tables, &tables_count, 0)))
{
if (thd->query_error || thd->is_fatal_error)
{
@@ -5841,7 +6001,7 @@
"unexpected success or fatal error"));
thd->query_error= 1;
}
- rli->clear_tables_to_lock();
+ const_cast<RELAY_LOG_INFO*>(rli)->clear_tables_to_lock();
DBUG_RETURN(error);
}
}
@@ -5863,7 +6023,7 @@
mysql_unlock_tables(thd, thd->lock);
thd->lock= 0;
thd->query_error= 1;
- rli->clear_tables_to_lock();
+ const_cast<RELAY_LOG_INFO*>(rli)->clear_tables_to_lock();
DBUG_RETURN(ERR_BAD_TABLE_DEF);
}
}
@@ -5885,24 +6045,24 @@
*/
for (TABLE_LIST *ptr= rli->tables_to_lock ; ptr ; ptr= ptr->next_global)
{
- rli->m_table_map.set_table(ptr->table_id, ptr->table);
+ const_cast<RELAY_LOG_INFO*>(rli)->m_table_map.set_table(ptr->table_id,
ptr->table);
}
#ifdef HAVE_QUERY_CACHE
query_cache.invalidate_locked_for_write(rli->tables_to_lock);
#endif
- rli->clear_tables_to_lock();
+ const_cast<RELAY_LOG_INFO*>(rli)->clear_tables_to_lock();
}
DBUG_ASSERT(rli->tables_to_lock == NULL && rli->tables_to_lock_count ==
0);
- TABLE* table= rli->m_table_map.get_table(m_table_id);
+ TABLE* table=
const_cast<RELAY_LOG_INFO*>(rli)->m_table_map.get_table(m_table_id);
if (table)
{
/*
table == NULL means that this table should not be replicated
- (this was set up by Table_map_log_event::exec_event() which
- tested replicate-* rules).
+ (this was set up by Table_map_log_event::do_apply_event()
+ which tested replicate-* rules).
*/
/*
@@ -5959,7 +6119,7 @@
break;
default:
- slave_print_msg(ERROR_LEVEL, rli, error,
+ slave_print_msg(ERROR_LEVEL, rli, thd->net.last_errno,
"Error in %s event: row application failed",
get_type_str());
thd->query_error= 1;
@@ -5969,7 +6129,7 @@
row_start= row_end;
}
DBUG_EXECUTE_IF("STOP_SLAVE_after_first_Rows_event",
- rli->abort_slave=1;);
+ const_cast<RELAY_LOG_INFO*>(rli)->abort_slave= 1;);
error= do_after_row_operations(table, error);
if (!cache_stmt)
{
@@ -5980,11 +6140,12 @@
if (error)
{ /* error has occured during the transaction */
- slave_print_msg(ERROR_LEVEL, rli, error,
+ slave_print_msg(ERROR_LEVEL, rli, thd->net.last_errno,
"Error in %s event: error during transaction execution "
"on table %s.%s",
get_type_str(), table->s->db.str,
table->s->table_name.str);
+
/*
If one day we honour --skip-slave-errors in row-based replication, and
the error should be skipped, then we would clear mappings, rollback,
@@ -5997,7 +6158,7 @@
rollback at the caller along with sbr.
*/
thd->reset_current_stmt_binlog_row_based();
- rli->cleanup_context(thd, 0); /* rollback at caller in step with sbr */
+ const_cast<RELAY_LOG_INFO*>(rli)->cleanup_context(thd, error);
thd->query_error= 1;
DBUG_RETURN(error);
}
@@ -6041,8 +6202,7 @@
*/
thd->reset_current_stmt_binlog_row_based();
- rli->cleanup_context(thd, 0);
- rli->transaction_end(thd);
+ const_cast<RELAY_LOG_INFO*>(rli)->cleanup_context(thd, 0);
if (error == 0)
{
@@ -6055,7 +6215,6 @@
do not become visible. We still prefer to wipe them out.
*/
thd->clear_error();
- error= Log_event::exec_event(rli);
}
else
slave_print_msg(ERROR_LEVEL, rli, error,
@@ -6082,17 +6241,17 @@
wait (reached end of last relay log and nothing gets appended
there), we timeout after one minute, and notify DBA about the
problem. When WL#2975 is implemented, just remove the member
- st_relay_log_info::unsafe_to_stop_at and all its occurences.
+ st_relay_log_info::last_event_start_time and all its occurences.
*/
- rli->unsafe_to_stop_at= time(0);
+ const_cast<RELAY_LOG_INFO*>(rli)->last_event_start_time= time(0);
}
DBUG_ASSERT(error == 0);
thd->clear_error();
- rli->inc_event_relay_log_pos();
-
+
DBUG_RETURN(0);
}
+
#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */
#ifndef MYSQL_CLIENT
@@ -6160,10 +6319,8 @@
if (get_flags(STMT_END_F))
{
- my_b_copy_to_file(head, file);
- my_b_copy_to_file(body, file);
- reinit_io_cache(head, WRITE_CACHE, 0, FALSE, TRUE);
- reinit_io_cache(body, WRITE_CACHE, 0, FALSE, TRUE);
+ copy_event_cache_to_file_and_reinit(head, file);
+ copy_event_cache_to_file_and_reinit(body, file);
}
}
#endif
@@ -6272,15 +6429,15 @@
const char *const vpart= buf + common_header_len + post_header_len;
/* Extract the length of the various parts from the buffer */
- byte const* const ptr_dblen= (byte const*)vpart + 0;
+ byte const *const ptr_dblen= (byte const*)vpart + 0;
m_dblen= *(uchar*) ptr_dblen;
/* Length of database name + counter + terminating null */
- byte const* const ptr_tbllen= ptr_dblen + m_dblen + 2;
+ byte const *const ptr_tbllen= ptr_dblen + m_dblen + 2;
m_tbllen= *(uchar*) ptr_tbllen;
/* Length of table name + counter + terminating null */
- byte const* const ptr_colcnt= ptr_tbllen + m_tbllen + 2;
+ byte const *const ptr_colcnt= ptr_tbllen + m_tbllen + 2;
uchar *ptr_after_colcnt= (uchar*) ptr_colcnt;
m_colcnt= net_field_length(&ptr_after_colcnt);
@@ -6325,9 +6482,9 @@
*/
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
-int Table_map_log_event::exec_event(st_relay_log_info *rli)
+int Table_map_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
- DBUG_ENTER("Table_map_log_event::exec_event(st_relay_log_info*)");
+ DBUG_ENTER("Table_map_log_event::do_apply_event(st_relay_log_info*)");
DBUG_ASSERT(rli->sql_thd == thd);
@@ -6450,29 +6607,24 @@
locked by linking the table into the list of tables to lock.
*/
table_list->next_global= table_list->next_local= rli->tables_to_lock;
- rli->tables_to_lock= table_list;
- rli->tables_to_lock_count++;
+ const_cast<RELAY_LOG_INFO*>(rli)->tables_to_lock= table_list;
+ const_cast<RELAY_LOG_INFO*>(rli)->tables_to_lock_count++;
/* 'memory' is freed in clear_tables_to_lock */
}
- /*
- We explicitly do not call Log_event::exec_event() here since we do not
- want the relay log position to be flushed to disk. The flushing will be
- done by the last Rows_log_event that either ends a statement (outside a
- transaction) or a transaction.
-
- A table map event can *never* end a transaction or a statement, so we
- just step the relay log position.
- */
-
- if (likely(!error))
- rli->inc_event_relay_log_pos();
DBUG_RETURN(error);
err:
my_free((gptr) memory, MYF(MY_WME));
DBUG_RETURN(error);
}
+
+int Table_map_log_event::do_update_pos(RELAY_LOG_INFO *rli)
+{
+ rli->inc_event_relay_log_pos();
+ return 0;
+}
+
#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */
#ifndef MYSQL_CLIENT
@@ -6637,7 +6789,7 @@
return error;
}
-int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli,
+int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
TABLE *table,
char const *const row_start,
char const **const row_end)
@@ -6778,6 +6930,32 @@
return 0; // All OK
}
+/**
+ Check if an error is a duplicate key error.
+
+ This function is used to check if an error code is one of the
+ duplicate key error, i.e., and error code for which it is sensible
+ to do a <code>get_dup_key()</code> to retrieve the duplicate key.
+
+ @param errcode The error code to check.
+
+ @return <code>true</code> if the error code is such that
+ <code>get_dup_key()</code> will return true,
<code>false</code>
+ otherwise.
+ */
+bool
+is_duplicate_key_error(int errcode)
+{
+ switch (errcode)
+ {
+ case HA_ERR_FOUND_DUPP_KEY:
+ case HA_ERR_FOUND_DUPP_UNIQUE:
+ return true;
+ }
+ return false;
+}
+
+
/*
Replace the provided record in the database.
@@ -6820,7 +6998,7 @@
if ((keynum= table->file->get_dup_key(error)) < 0)
{
/* We failed to retrieve the duplicate key */
- DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY);
+ DBUG_RETURN(error);
}
/*
@@ -6837,7 +7015,10 @@
{
error= table->file->rnd_pos(table->record[1], table->file->dup_ref);
if (error)
+ {
+ table->file->print_error(error, MYF(0));
DBUG_RETURN(error);
+ }
}
else
{
@@ -6858,7 +7039,10 @@
(const byte*)key.get(), HA_WHOLE_KEY,
HA_READ_KEY_EXACT);
if (error)
+ {
+ table->file->print_error(error, MYF(0));
DBUG_RETURN(error);
+ }
}
/*
@@ -6891,15 +7075,21 @@
{
error=table->file->ha_update_row(table->record[1],
table->record[0]);
+ if (error)
+ table->file->print_error(error, MYF(0));
DBUG_RETURN(error);
}
else
{
if ((error= table->file->ha_delete_row(table->record[1])))
+ {
+ table->file->print_error(error, MYF(0));
DBUG_RETURN(error);
+ }
/* Will retry ha_write_row() with the offending row removed. */
}
}
+
DBUG_RETURN(error);
}
@@ -7237,7 +7427,7 @@
return error;
}
-int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli,
+int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
TABLE *table,
char const *const row_start,
char const **const row_end)
@@ -7372,7 +7562,7 @@
return error;
}
-int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli,
+int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
TABLE *table,
char const *const row_start,
char const **const row_end)
--- 1.150/client/mysqlbinlog.cc 2007-03-20 15:50:44 +01:00
+++ 1.151/client/mysqlbinlog.cc 2007-03-26 12:04:29 +02:00
@@ -481,19 +481,17 @@
write_event_header_and_base64(Log_event *ev, FILE *result_file,
PRINT_EVENT_INFO *print_event_info)
{
+ IO_CACHE *head= &print_event_info->head_cache;
+ IO_CACHE *body= &print_event_info->body_cache;
DBUG_ENTER("write_event_header_and_base64");
- /* Write header and base64 output to cache */
- IO_CACHE result_cache;
- if (open_cached_file(&result_cache, NULL, NULL, 0, MYF(MY_WME | MY_NABP)))
- return 1;
- ev->print_header(&result_cache, print_event_info, FALSE);
- ev->print_base64(&result_cache, print_event_info, FALSE);
+ /* Write header and base64 output to cache */
+ ev->print_header(head, print_event_info, FALSE);
+ ev->print_base64(body, print_event_info, FALSE);
/* Read data from cache and write to result file */
- my_b_copy_to_file(&result_cache, result_file);
- close_cached_file(&result_cache);
- DBUG_RETURN(0);
+ DBUG_RETURN(copy_event_cache_to_file_and_reinit(head, result_file) ||
+ copy_event_cache_to_file_and_reinit(body, result_file));
}
--- 1.622/sql/mysqld.cc 2007-03-19 22:37:31 +01:00
+++ 1.623/sql/mysqld.cc 2007-03-26 12:04:30 +02:00
@@ -6451,12 +6451,12 @@
(gptr*) &max_system_variables.tmp_table_size, 0, GET_ULL,
REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0},
{"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE,
- "Allocation block size for transactions to be stored in binary log",
+ "Allocation block size for various transaction-related structures",
(gptr*) &global_system_variables.trans_alloc_block_size,
(gptr*) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG,
REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0},
{"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE,
- "Persistent buffer for transactions to be stored in binary log",
+ "Persistent buffer for various transaction-related structures",
(gptr*) &global_system_variables.trans_prealloc_size,
(gptr*) &max_system_variables.trans_prealloc_size, 0, GET_ULONG,
REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0},
--- 1.297/sql/slave.cc 2007-03-22 09:05:06 +01:00
+++ 1.298/sql/slave.cc 2007-03-26 12:04:30 +02:00
@@ -25,12 +25,15 @@
#include <thr_alarm.h>
#include <my_dir.h>
#include <sql_common.h>
+#include <errmsg.h>
#ifdef HAVE_REPLICATION
#include "rpl_tblmap.h"
int queue_event(MASTER_INFO* mi,const char* buf,ulong event_len);
+static Log_event* next_event(RELAY_LOG_INFO* rli);
+
#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
@@ -2089,7 +2092,7 @@
if (event_len == packet_error)
{
uint mysql_error_number= mysql_errno(mysql);
- if (mysql_error_number == ER_NET_PACKET_TOO_LARGE)
+ if (mysql_error_number == CR_NET_PACKET_TOO_LARGE)
{
sql_print_error("\
Log entry on master is longer than max_allowed_packet (%ld) on \
--- 1.388/sql/sql_base.cc 2007-03-19 22:44:13 +01:00
+++ 1.389/sql/sql_base.cc 2007-03-26 12:04:30 +02:00
@@ -3746,7 +3746,7 @@
tmp_table->reginfo.lock_type= TL_WRITE; // Simulate locked
share->tmp_table= (tmp_table->file->has_transactions() ?
- TRANSACTIONAL_TMP_TABLE : TMP_TABLE);
+ TRANSACTIONAL_TMP_TABLE : NON_TRANSACTIONAL_TMP_TABLE);
if (link_in_list)
{
--- 1.321/sql/sql_class.cc 2007-03-22 01:04:27 +01:00
+++ 1.322/sql/sql_class.cc 2007-03-26 12:04:31 +02:00
@@ -679,11 +679,22 @@
void THD::cleanup_after_query()
{
+ /*
+ Reset rand_used so that detection of calls to rand() will save random
+ seeds if needed by the slave.
+
+ Do not reset rand_used if inside a stored function or trigger because
+ only the call to these operations is logged. Thus only the calling
+ statement needs to detect rand() calls made by its substatements. These
+ substatements must not set rand_used to 0 because it would remove the
+ detection of rand() by the calling statement.
+ */
if (!in_sub_stmt) /* stored functions and triggers are a special case */
{
/* Forget those values, for next binlogger: */
stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0;
auto_inc_intervals_in_cur_stmt_for_binlog.empty();
+ rand_used= 0;
}
if (first_successful_insert_id_in_cur_stmt > 0)
{
--- 1.163/sql/table.h 2007-03-17 00:13:19 +01:00
+++ 1.164/sql/table.h 2007-03-26 12:04:31 +02:00
@@ -58,7 +58,7 @@
enum tmp_table_type
{
- NO_TMP_TABLE, TMP_TABLE, TRANSACTIONAL_TMP_TABLE,
+ NO_TMP_TABLE, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE,
INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE
};
| Thread |
|---|
| • bk commit into 5.1 tree (tomas:1.2520) | tomas | 26 Mar |