summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <mats@kindahl-laptop.dnsalias.net>2007-06-11 22:15:39 +0200
committerunknown <mats@kindahl-laptop.dnsalias.net>2007-06-11 22:15:39 +0200
commitabbf5941d950e3a857987785991b72f1040d0721 (patch)
treea5aeb5e654946367a567da821efa7b17263f59d2 /sql
parent9fea6f4775c64b12b0cc65375f523c02b7b03457 (diff)
downloadmariadb-git-abbf5941d950e3a857987785991b72f1040d0721.tar.gz
BUG#24954 (Last_errno and Last_error not set after master_retry_count has
been reached): Post-merge patch to handle all the changes to the tree since the tree was cloned. mysql-test/extra/rpl_tests/rpl_log.test: Replacing SHOW SLAVE STATUS with include file. mysql-test/extra/rpl_tests/rpl_max_relay_size.test: Replacing SHOW SLAVE STATUS with include file. mysql-test/extra/rpl_tests/rpl_reset_slave.test: Replacing SHOW SLAVE STATUS with include file. mysql-test/include/show_slave_status.inc: Column change. mysql-test/r/rpl_000015.result: Result file change. mysql-test/r/rpl_change_master.result: Result file change. mysql-test/r/rpl_empty_master_crash.result: Result file change. mysql-test/r/rpl_extraCol_innodb.result: Result file change. mysql-test/r/rpl_extraCol_myisam.result: Result file change. mysql-test/r/rpl_flushlog_loop.result: Result file change. mysql-test/r/rpl_incident.result: Result file change. mysql-test/r/rpl_known_bugs_detection.result: Result file change. mysql-test/r/rpl_loaddata.result: Result file change. mysql-test/r/rpl_loaddata_fatal.result: Result file change. mysql-test/r/rpl_log_pos.result: Result file change. mysql-test/r/rpl_ndb_basic.result: Result file change. mysql-test/r/rpl_ndb_circular.result: Result file change. mysql-test/r/rpl_ndb_extraCol.result: Result file change. mysql-test/r/rpl_ndb_idempotent.result: Result file change. mysql-test/r/rpl_ndb_log.result: Result file change. mysql-test/r/rpl_ndb_sync.result: Result file change. mysql-test/r/rpl_rbr_to_sbr.result: Result file change. mysql-test/r/rpl_redirect.result: Result file change. mysql-test/r/rpl_replicate_do.result: Result file change. mysql-test/r/rpl_rotate_logs.result: Result file change. mysql-test/r/rpl_row_inexist_tbl.result: Result file change. mysql-test/r/rpl_row_log.result: Result file change. mysql-test/r/rpl_row_log_innodb.result: Result file change. mysql-test/r/rpl_row_max_relay_size.result: Result file change. mysql-test/r/rpl_row_reset_slave.result: Result file change. mysql-test/r/rpl_row_tabledefs_2myisam.result: Result file change. mysql-test/r/rpl_row_tabledefs_3innodb.result: Result file change. mysql-test/r/rpl_row_until.result: Result file change. mysql-test/r/rpl_server_id1.result: Result file change. mysql-test/r/rpl_server_id2.result: Result file change. mysql-test/r/rpl_slave_skip.result: Result file change. mysql-test/r/rpl_ssl.result: Result file change. mysql-test/r/rpl_ssl1.result: Result file change. mysql-test/r/rpl_stm_log.result: Result file change. mysql-test/r/rpl_stm_max_relay_size.result: Result file change. mysql-test/r/rpl_stm_reset_slave.result: Result file change. mysql-test/r/rpl_stm_until.result: Result file change. mysql-test/t/rpl_000015.test: Replacing SHOW SLAVE STATUS with include file. mysql-test/t/rpl_change_master.test: Column position change. Making result of SHOW SLAVE STATUS vertical. mysql-test/t/rpl_empty_master_crash.test: Replacing SHOW SLAVE STATUS with include file. mysql-test/t/rpl_log_pos.test: Replacing SHOW SLAVE STATUS with include file. mysql-test/t/rpl_ndb_basic.test: Column position change. mysql-test/t/rpl_ndb_idempotent.test: Column position change. mysql-test/t/rpl_ndb_sync.test: Column position change. Making result of SHOW SLAVE STATUS vertical. mysql-test/t/rpl_redirect.test: Replacing SHOW SLAVE STATUS with include file. mysql-test/t/rpl_replicate_do.test: Column position change. Making result of SHOW SLAVE STATUS vertical. mysql-test/t/rpl_rotate_logs.test: Replacing SHOW SLAVE STATUS with include file. mysql-test/t/rpl_row_inexist_tbl.test: Replacing SHOW SLAVE STATUS with include file. mysql-test/t/rpl_row_until.test: Replacing SHOW SLAVE STATUS with include file. mysql-test/t/rpl_server_id1.test: Column position change. Making result of SHOW SLAVE STATUS vertical. mysql-test/t/rpl_server_id2.test: Column position change. Making result of SHOW SLAVE STATUS vertical. mysql-test/t/rpl_slave_status.test: Column position change. mysql-test/t/rpl_ssl.test: Column position change. mysql-test/t/rpl_ssl1.test: Column position change. mysql-test/t/rpl_stm_until.test: Replacing SHOW SLAVE STATUS with include file. sql/log_event.cc: Using member function last_error() instead of member variable. Replacing use of 'table' with 'm_table'. Suppressing warnings in debug printout. Setting thd->net.last_error on error return from unpack_row() to get a non-zero error message. The error codes for are being harmonized in another worklog. Replacing use of slave_print_msg() with RELAY_LOG_INFO::report(). sql/rpl_mi.h: Moving order of include files since they are dependent (!). sql/rpl_record.cc: Adding missing include file. Replacing use of slave_print_msg() with RELAY_LOG_INFO::report(). sql/rpl_record_old.cc: Adding missing include file. Replacing use of slave_print_msg() with RELAY_LOG_INFO::report(). sql/rpl_reporting.cc: Adding const modifier to member function. Using renamed member variable m_last_error. sql/rpl_reporting.h: Adding missing constant MAX_SLAVE_ERRMSG. Adding const modifier to Slave_reporting_capability::report(). Hiding and renaming member variable last_error and incorporating member function for access in order to make it mutable. sql/rpl_rli.h: Moving constant MAX_SLAVE_ERRMSG. sql/rpl_utility.cc: Adding missing include file rpl_rli.h. sql/slave.cc: Replacing use of member variable last_error with call to member function last_error(). Replacing use of slave_print_msg() with RELAY_LOG_INFO::report().
Diffstat (limited to 'sql')
-rw-r--r--sql/log_event.cc65
-rw-r--r--sql/rpl_mi.h2
-rw-r--r--sql/rpl_record.cc11
-rw-r--r--sql/rpl_record_old.cc11
-rw-r--r--sql/rpl_reporting.cc9
-rw-r--r--sql/rpl_reporting.h15
-rw-r--r--sql/rpl_rli.h2
-rw-r--r--sql/rpl_utility.cc1
-rw-r--r--sql/slave.cc34
9 files changed, 88 insertions, 62 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index eae87b75724..ac5e5a86cb2 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -5279,10 +5279,10 @@ int Execute_load_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
don't want to overwrite it with the filename.
What we want instead is add the filename to the current error message.
*/
- char *tmp= my_strdup(rli->last_error.message, MYF(MY_WME));
+ char *tmp= my_strdup(rli->last_error().message, MYF(MY_WME));
if (tmp)
{
- rli->report(ERROR_LEVEL, rli->last_error.number,
+ rli->report(ERROR_LEVEL, rli->last_error().number,
"%s. Failed executing load from '%s'", tmp, fname);
my_free(tmp,MYF(0));
}
@@ -5757,7 +5757,7 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len,
size_t const data_size= event_len - (ptr_rows_data - (const uchar *) buf);
DBUG_PRINT("info",("m_table_id: %lu m_flags: %d m_width: %lu data_size: %lu",
- m_table_id, m_flags, m_width, data_size));
+ m_table_id, m_flags, m_width, (ulong) data_size));
m_rows_buf= (uchar*) my_malloc(data_size, MYF(MY_WME));
if (likely((bool)m_rows_buf))
@@ -6131,7 +6131,7 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
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,
close tables, but the slave SQL thread would not stop and then may
@@ -6266,8 +6266,8 @@ Rows_log_event::do_update_pos(RELAY_LOG_INFO *rli)
rli->report(ERROR_LEVEL, error,
"Error in %s event: commit of row events failed, "
"table `%s`.`%s`",
- get_type_str(), table->s->db.str,
- table->s->table_name.str);
+ get_type_str(), m_table->s->db.str,
+ m_table->s->table_name.str);
}
else
{
@@ -6485,8 +6485,8 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
m_colcnt= net_field_length(&ptr_after_colcnt);
DBUG_PRINT("info",("m_dblen: %lu off: %ld m_tbllen: %lu off: %ld m_colcnt: %lu off: %ld",
- m_dblen, (long) (ptr_dblen-(const uchar*)vpart),
- m_tbllen, (long) (ptr_tbllen-(const uchar*)vpart),
+ (ulong) m_dblen, (long) (ptr_dblen-(const uchar*)vpart),
+ (ulong) m_tbllen, (long) (ptr_tbllen-(const uchar*)vpart),
m_colcnt, (long) (ptr_colcnt-(const uchar*)vpart)));
/* Allocate mem for all fields in one go. If fails, catched in is_valid() */
@@ -6874,11 +6874,14 @@ int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
DBUG_ASSERT(table != NULL);
DBUG_ASSERT(row_start && row_end);
- int error;
- error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
- &m_master_reclength, table->write_set, WRITE_ROWS_EVENT);
+ if (int error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
+ &m_master_reclength, table->write_set, WRITE_ROWS_EVENT))
+ {
+ thd->net.last_errno= error;
+ return error;
+ }
bitmap_copy(table->read_set, table->write_set);
- return error;
+ return 0;
}
/*
@@ -7586,7 +7589,6 @@ int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
uchar const *const row_start,
uchar const **const row_end)
{
- int error;
DBUG_ASSERT(row_start && row_end);
/*
This assertion actually checks that there is at least as many
@@ -7594,8 +7596,13 @@ int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
*/
DBUG_ASSERT(table->s->fields >= m_width);
- error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
- &m_master_reclength, table->read_set, DELETE_ROWS_EVENT);
+ if (int error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
+ &m_master_reclength, table->read_set, DELETE_ROWS_EVENT))
+ {
+ thd->net.last_errno= error;
+ return error;
+ }
+
/*
If we will access rows using the random access method, m_key will
be set to NULL, so we do not need to make a key copy in that case.
@@ -7607,7 +7614,7 @@ int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
key_copy(m_key, table->record[0], key_info, 0);
}
- return error;
+ return 0;
}
int Delete_rows_log_event::do_exec_row(TABLE *table)
@@ -7776,13 +7783,23 @@ int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli,
*/
/* record[0] is the before image for the update */
- error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
- &m_master_reclength, table->read_set, UPDATE_ROWS_EVENT);
+ if ((error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
+ &m_master_reclength, table->read_set, UPDATE_ROWS_EVENT)))
+ {
+ thd->net.last_errno= error;
+ return error;
+ }
+
store_record(table, record[1]);
uchar const *next_start = *row_end;
/* m_after_image is the after image for the update */
- error= unpack_row(rli, table, m_width, next_start, &m_cols_ai, row_end,
- &m_master_reclength, table->write_set, UPDATE_ROWS_EVENT);
+ if ((error= unpack_row(rli, table, m_width, next_start, &m_cols_ai, row_end,
+ &m_master_reclength, table->write_set, UPDATE_ROWS_EVENT)))
+ {
+ thd->net.last_errno= error;
+ return error;
+ }
+
bmove_align(m_after_image, table->record[0], table->s->reclength);
restore_record(table, record[1]);
@@ -7937,10 +7954,10 @@ int
Incident_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
{
DBUG_ENTER("Incident_log_event::do_apply_event");
- slave_print_msg(ERROR_LEVEL, rli, ER_SLAVE_INCIDENT,
- ER(ER_SLAVE_INCIDENT),
- description(),
- m_message.length > 0 ? m_message.str : "<none>");
+ rli->report(ERROR_LEVEL, ER_SLAVE_INCIDENT,
+ ER(ER_SLAVE_INCIDENT),
+ description(),
+ m_message.length > 0 ? m_message.str : "<none>");
DBUG_RETURN(1);
}
#endif
diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h
index 054356935de..44ab0d1dc15 100644
--- a/sql/rpl_mi.h
+++ b/sql/rpl_mi.h
@@ -18,8 +18,8 @@
#ifdef HAVE_REPLICATION
-#include "rpl_reporting.h"
#include "rpl_rli.h"
+#include "rpl_reporting.h"
/*****************************************************************************
diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc
index 45edb42374b..94778948bf9 100644
--- a/sql/rpl_record.cc
+++ b/sql/rpl_record.cc
@@ -14,6 +14,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysql_priv.h"
+#include "rpl_rli.h"
#include "rpl_record.h"
#include "slave.h" // Need to pull in slave_print_msg
@@ -263,11 +264,11 @@ unpack_row(RELAY_LOG_INFO const *rli,
if (event_type == WRITE_ROWS_EVENT &&
((*field_ptr)->flags & mask) == mask)
{
- slave_print_msg(ERROR_LEVEL, rli, ER_NO_DEFAULT_FOR_FIELD,
- "Field `%s` of table `%s`.`%s` "
- "has no default value and cannot be NULL",
- (*field_ptr)->field_name, table->s->db.str,
- table->s->table_name.str);
+ rli->report(ERROR_LEVEL, ER_NO_DEFAULT_FOR_FIELD,
+ "Field `%s` of table `%s`.`%s` "
+ "has no default value and cannot be NULL",
+ (*field_ptr)->field_name, table->s->db.str,
+ table->s->table_name.str);
error = ER_NO_DEFAULT_FOR_FIELD;
}
else
diff --git a/sql/rpl_record_old.cc b/sql/rpl_record_old.cc
index b6f170082fe..377aec49113 100644
--- a/sql/rpl_record_old.cc
+++ b/sql/rpl_record_old.cc
@@ -1,5 +1,6 @@
#include "mysql_priv.h"
+#include "rpl_rli.h"
#include "rpl_record_old.h"
size_t
@@ -157,11 +158,11 @@ unpack_row_old(RELAY_LOG_INFO *rli,
if (event_type == WRITE_ROWS_EVENT &&
((*field_ptr)->flags & mask) == mask)
{
- slave_print_msg(ERROR_LEVEL, rli, ER_NO_DEFAULT_FOR_FIELD,
- "Field `%s` of table `%s`.`%s` "
- "has no default value and cannot be NULL",
- (*field_ptr)->field_name, table->s->db.str,
- table->s->table_name.str);
+ rli->report(ERROR_LEVEL, ER_NO_DEFAULT_FOR_FIELD,
+ "Field `%s` of table `%s`.`%s` "
+ "has no default value and cannot be NULL",
+ (*field_ptr)->field_name, table->s->db.str,
+ table->s->table_name.str);
error = ER_NO_DEFAULT_FOR_FIELD;
}
else
diff --git a/sql/rpl_reporting.cc b/sql/rpl_reporting.cc
index d14dbdcc930..28f257790c7 100644
--- a/sql/rpl_reporting.cc
+++ b/sql/rpl_reporting.cc
@@ -3,7 +3,8 @@
#include "rpl_reporting.h"
void
-Slave_reporting_capability::report(loglevel level, int err_code, const char *msg, ...)
+Slave_reporting_capability::report(loglevel level, int err_code,
+ const char *msg, ...) const
{
void (*report_function)(const char *, ...);
char buff[MAX_SLAVE_ERRMSG];
@@ -19,9 +20,9 @@ Slave_reporting_capability::report(loglevel level, int err_code, const char *msg
It's an error, it must be reported in Last_error and Last_errno in SHOW
SLAVE STATUS.
*/
- pbuff= last_error.message;
- pbuffsize= sizeof(last_error.message);
- last_error.number = err_code;
+ pbuff= m_last_error.message;
+ pbuffsize= sizeof(m_last_error.message);
+ m_last_error.number = err_code;
report_function= sql_print_error;
break;
case WARNING_LEVEL:
diff --git a/sql/rpl_reporting.h b/sql/rpl_reporting.h
index e3cd44d16c6..2e3fa3cea83 100644
--- a/sql/rpl_reporting.h
+++ b/sql/rpl_reporting.h
@@ -2,6 +2,11 @@
#define RPL_REPORTING_H
/**
+ Maximum size of an error message from a slave thread.
+ */
+#define MAX_SLAVE_ERRMSG 1024
+
+/**
Mix-in to handle the message logging and reporting for relay log
info and master log info structures.
@@ -31,7 +36,7 @@ public:
code, but can contain more information), in
printf() format.
*/
- void report(loglevel level, int err_code, const char *msg, ...)
+ void report(loglevel level, int err_code, const char *msg, ...) const
ATTRIBUTE_FORMAT(printf, 4, 5);
/**
@@ -39,7 +44,7 @@ public:
STATUS</code>.
*/
void clear_error() {
- last_error.clear();
+ m_last_error.clear();
}
/**
@@ -65,12 +70,14 @@ public:
char message[MAX_SLAVE_ERRMSG];
};
+ Error const& last_error() const { return m_last_error; }
+
+private:
/**
Last error produced by the I/O or SQL thread respectively.
*/
- Error last_error;
+ mutable Error m_last_error;
-private:
char const *const m_thread_name;
};
diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h
index b4c6a4bf7c5..c458318594a 100644
--- a/sql/rpl_rli.h
+++ b/sql/rpl_rli.h
@@ -16,8 +16,6 @@
#ifndef RPL_RLI_H
#define RPL_RLI_H
-#define MAX_SLAVE_ERRMSG 1024
-
#include "rpl_tblmap.h"
#include "rpl_reporting.h"
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index e56cb4f2730..a04bcd1fab9 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -14,6 +14,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include "rpl_utility.h"
+#include "rpl_rli.h"
uint32
field_length_from_packed(enum_field_types const field_type,
diff --git a/sql/slave.cc b/sql/slave.cc
index f8b81ad8833..6c7968c2b3f 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1253,8 +1253,8 @@ bool show_master_info(THD* thd, MASTER_INFO* mi)
rpl_filter->get_wild_ignore_table(&tmp);
protocol->store(&tmp);
- protocol->store(mi->rli.last_error.number);
- protocol->store(mi->rli.last_error.message, &my_charset_bin);
+ protocol->store(mi->rli.last_error().number);
+ protocol->store(mi->rli.last_error().message, &my_charset_bin);
protocol->store((uint32) mi->rli.slave_skip_counter);
protocol->store((ulonglong) mi->rli.group_master_log_pos);
protocol->store((ulonglong) mi->rli.log_space_total);
@@ -1316,13 +1316,13 @@ bool show_master_info(THD* thd, MASTER_INFO* mi)
protocol->store(mi->ssl_verify_server_cert? "Yes":"No", &my_charset_bin);
// Last_IO_Errno
- protocol->store(mi->last_error.number);
+ protocol->store(mi->last_error().number);
// Last_IO_Error
- protocol->store(mi->last_error.message, &my_charset_bin);
+ protocol->store(mi->last_error().message, &my_charset_bin);
// Last_SQL_Errno
- protocol->store(mi->rli.last_error.number);
+ protocol->store(mi->rli.last_error().number);
// Last_SQL_Error
- protocol->store(mi->rli.last_error.message, &my_charset_bin);
+ protocol->store(mi->rli.last_error().message, &my_charset_bin);
pthread_mutex_unlock(&mi->rli.data_lock);
pthread_mutex_unlock(&mi->data_lock);
@@ -1780,13 +1780,13 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
*/
if (error)
{
- slave_print_msg(ERROR_LEVEL, rli, ER_UNKNOWN_ERROR,
- "It was not possible to update the positions"
- " of the relay log information: the slave may"
- " be in an inconsistent state."
- " Stopped in %s position %s",
- rli->group_relay_log_name,
- llstr(rli->group_relay_log_pos, buf));
+ rli->report(ERROR_LEVEL, ER_UNKNOWN_ERROR,
+ "It was not possible to update the positions"
+ " of the relay log information: the slave may"
+ " be in an inconsistent state."
+ " Stopped in %s position %s",
+ rli->group_relay_log_name,
+ llstr(rli->group_relay_log_pos, buf));
DBUG_RETURN(1);
}
}
@@ -2377,7 +2377,7 @@ Slave SQL thread aborted. Can't execute init_slave query");
codes and warnings and print this to the error log as to
allow the user to locate the error
*/
- uint32 const last_errno= rli->last_error.number;
+ uint32 const last_errno= rli->last_error().number;
DBUG_PRINT("info", ("thd->net.last_errno=%d; rli->last_error.number=%d",
thd->net.last_errno, last_errno));
@@ -3732,9 +3732,9 @@ bool rpl_master_has_bug(RELAY_LOG_INFO *rli, uint bug_id)
" so slave stops; check error log on slave"
" for more info", MYF(0), bug_id);
// a verbose message for the error log
- slave_print_msg(ERROR_LEVEL, rli, ER_UNKNOWN_ERROR,
- "According to the master's version ('%s'),"
- " it is probable that master suffers from this bug:"
+ rli->report(ERROR_LEVEL, ER_UNKNOWN_ERROR,
+ "According to the master's version ('%s'),"
+ " it is probable that master suffers from this bug:"
" http://bugs.mysql.com/bug.php?id=%u"
" and thus replicating the current binary log event"
" may make the slave's data become different from the"