Commit 64dbfdd7 authored by unknown's avatar unknown

Merge mysql1000.(none):/mnt/nb/home/elkin/MySQL/TEAM/FIXES/5.1/bug32971-error_propag_slave

into  mysql1000.(none):/home/andrei/MySQL/FIXES/5.1/bug32971-rbr_error_prop


mysql-test/extra/rpl_tests/rpl_row_tabledefs.test:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/log_event.h:
  Auto merged
mysql-test/suite/rpl/r/rpl_row_tabledefs_2myisam.result:
  manual merge use local
mysql-test/suite/rpl/r/rpl_row_tabledefs_3innodb.result:
  manual merge use local
parents 6a873248 b6ec38ce
...@@ -411,7 +411,9 @@ enum ha_base_keytype { ...@@ -411,7 +411,9 @@ enum ha_base_keytype {
statement */ statement */
#define HA_ERR_CORRUPT_EVENT 171 /* The event was corrupt, leading to #define HA_ERR_CORRUPT_EVENT 171 /* The event was corrupt, leading to
illegal data being read */ illegal data being read */
#define HA_ERR_LAST 171 /*Copy last error nr.*/ #define HA_ERR_ROWS_EVENT_APPLY 172 /* The event could not be processed
no other hanlder error happened */
#define HA_ERR_LAST 172 /*Copy last error nr.*/
/* Add error numbers before HA_ERR_LAST and change it accordingly. */ /* Add error numbers before HA_ERR_LAST and change it accordingly. */
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1) #define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
......
...@@ -46,7 +46,7 @@ ALTER TABLE t1_bit ...@@ -46,7 +46,7 @@ ALTER TABLE t1_bit
ALTER TABLE t1_char ADD x CHAR(20) DEFAULT 'Just a test'; ALTER TABLE t1_char ADD x CHAR(20) DEFAULT 'Just a test';
# ... and add one non-nullable INT column last in table 't1_text' # ... and add one non-nullable INT column last in table 't1_text'
# with no default, # with no default,
ALTER TABLE t1_nodef ADD x INT NOT NULL; ALTER TABLE t1_nodef ADD x INT NOT NULL, ADD y INT NOT NULL, ADD z INT NOT NULL;
# ... and remove the last column in t2 # ... and remove the last column in t2
ALTER TABLE t2 DROP b; ALTER TABLE t2 DROP b;
# ... change the type of the single column in table 't4' # ... change the type of the single column in table 't4'
...@@ -222,8 +222,8 @@ sync_slave_with_master; ...@@ -222,8 +222,8 @@ sync_slave_with_master;
--echo **** On Slave **** --echo **** On Slave ****
connection slave; connection slave;
INSERT INTO t1_nodef VALUES (1,2,3); INSERT INTO t1_nodef VALUES (1,2,3,4,5);
INSERT INTO t1_nodef VALUES (2,4,6); INSERT INTO t1_nodef VALUES (2,4,6,8,10);
--echo **** On Master **** --echo **** On Master ****
connection master; connection master;
......
...@@ -99,12 +99,23 @@ static const char *HA_ERR(int i) ...@@ -99,12 +99,23 @@ static const char *HA_ERR(int i)
case HA_ERR_RECORD_IS_THE_SAME: return "HA_ERR_RECORD_IS_THE_SAME"; case HA_ERR_RECORD_IS_THE_SAME: return "HA_ERR_RECORD_IS_THE_SAME";
case HA_ERR_LOGGING_IMPOSSIBLE: return "HA_ERR_LOGGING_IMPOSSIBLE"; case HA_ERR_LOGGING_IMPOSSIBLE: return "HA_ERR_LOGGING_IMPOSSIBLE";
case HA_ERR_CORRUPT_EVENT: return "HA_ERR_CORRUPT_EVENT"; case HA_ERR_CORRUPT_EVENT: return "HA_ERR_CORRUPT_EVENT";
case HA_ERR_ROWS_EVENT_APPLY : return "HA_ERR_ROWS_EVENT_APPLY";
} }
return 0; return 0;
} }
/** /**
macro to call from different branches of Rows_log_event::do_apply_event Error reporting facility for Rows_log_event::do_apply_event
@param level error, warning or info
@param ha_error HA_ERR_ code
@param rli pointer to the active Relay_log_info instance
@param thd pointer to the slave thread's thd
@param table pointer to the event's table object
@param type the type of the event
@param log_name the master binlog file name
@param pos the master binlog file pos (the next after the event)
*/ */
static void inline slave_rows_error_report(enum loglevel level, int ha_error, static void inline slave_rows_error_report(enum loglevel level, int ha_error,
Relay_log_info const *rli, THD *thd, Relay_log_info const *rli, THD *thd,
...@@ -112,14 +123,27 @@ static void inline slave_rows_error_report(enum loglevel level, int ha_error, ...@@ -112,14 +123,27 @@ static void inline slave_rows_error_report(enum loglevel level, int ha_error,
const char *log_name, ulong pos) const char *log_name, ulong pos)
{ {
const char *handler_error= HA_ERR(ha_error); const char *handler_error= HA_ERR(ha_error);
char buff[MAX_SLAVE_ERRMSG], *slider;
const char *buff_end= buff + sizeof(buff);
uint len;
List_iterator_fast<MYSQL_ERROR> it(thd->warn_list);
MYSQL_ERROR *err;
buff[0]= 0;
for (err= it++, slider= buff; err && slider < buff_end - 1;
slider += len, err= it++)
{
len= my_snprintf(slider, buff_end - slider,
" %s, Error_code: %d;", err->msg, err->code);
}
rli->report(level, thd->net.last_errno, rli->report(level, thd->net.last_errno,
"Could not execute %s event on table %s.%s;" "Could not execute %s event on table %s.%s;"
"%s%s handler error %s; " "%s handler error %s; "
"the event's master log %s, end_log_pos %lu", "the event's master log %s, end_log_pos %lu",
type, table->s->db.str, type, table->s->db.str,
table->s->table_name.str, table->s->table_name.str,
thd->net.last_error[0] != 0 ? thd->net.last_error : "", buff,
thd->net.last_error[0] != 0 ? ";" : "",
handler_error == NULL? "<unknown>" : handler_error, handler_error == NULL? "<unknown>" : handler_error,
log_name, pos); log_name, pos);
} }
...@@ -7675,7 +7699,7 @@ Rows_log_event::write_row(const Relay_log_info *const rli, ...@@ -7675,7 +7699,7 @@ Rows_log_event::write_row(const Relay_log_info *const rli,
/* fill table->record[0] with default values */ /* fill table->record[0] with default values */
if ((error= prepare_record(rli, table, m_width, if ((error= prepare_record(table, m_width,
TRUE /* check if columns have def. values */))) TRUE /* check if columns have def. values */)))
DBUG_RETURN(error); DBUG_RETURN(error);
...@@ -7990,12 +8014,16 @@ int Rows_log_event::find_row(const Relay_log_info *rli) ...@@ -7990,12 +8014,16 @@ int Rows_log_event::find_row(const Relay_log_info *rli)
DBUG_ASSERT(m_table && m_table->in_use != NULL); DBUG_ASSERT(m_table && m_table->in_use != NULL);
TABLE *table= m_table; TABLE *table= m_table;
int error; int error= 0;
/* unpack row - missing fields get default values */ /*
rpl_row_tabledefs.test specifies that
if the extra field on the slave does not have a default value
and this is okay with Delete or Update events.
Todo: fix wl3228 hld that requires defauls for all types of events
*/
// TODO: shall we check and report errors here? prepare_record(table, m_width, FALSE);
prepare_record(NULL,table,m_width,FALSE /* don't check errors */);
error= unpack_current_row(rli); error= unpack_current_row(rli);
#ifndef DBUG_OFF #ifndef DBUG_OFF
......
...@@ -3131,6 +3131,8 @@ protected: ...@@ -3131,6 +3131,8 @@ protected:
ASSERT_OR_RETURN_ERROR(m_curr_row < m_rows_end, HA_ERR_CORRUPT_EVENT); ASSERT_OR_RETURN_ERROR(m_curr_row < m_rows_end, HA_ERR_CORRUPT_EVENT);
int const result= ::unpack_row(rli, m_table, m_width, m_curr_row, &m_cols, int const result= ::unpack_row(rli, m_table, m_width, m_curr_row, &m_cols,
&m_curr_row_end, &m_master_reclength); &m_curr_row_end, &m_master_reclength);
if (m_curr_row_end > m_rows_end)
my_error(ER_SLAVE_CORRUPT_EVENT, MYF(0));
ASSERT_OR_RETURN_ERROR(m_curr_row_end <= m_rows_end, HA_ERR_CORRUPT_EVENT); ASSERT_OR_RETURN_ERROR(m_curr_row_end <= m_rows_end, HA_ERR_CORRUPT_EVENT);
return result; return result;
} }
......
...@@ -2077,7 +2077,7 @@ Old_rows_log_event::write_row(const Relay_log_info *const rli, ...@@ -2077,7 +2077,7 @@ Old_rows_log_event::write_row(const Relay_log_info *const rli,
/* fill table->record[0] with default values */ /* fill table->record[0] with default values */
if ((error= prepare_record(rli, table, m_width, if ((error= prepare_record(table, m_width,
TRUE /* check if columns have def. values */))) TRUE /* check if columns have def. values */)))
DBUG_RETURN(error); DBUG_RETURN(error);
...@@ -2288,7 +2288,7 @@ int Old_rows_log_event::find_row(const Relay_log_info *rli) ...@@ -2288,7 +2288,7 @@ int Old_rows_log_event::find_row(const Relay_log_info *rli)
/* unpack row - missing fields get default values */ /* unpack row - missing fields get default values */
// TODO: shall we check and report errors here? // TODO: shall we check and report errors here?
prepare_record(NULL,table,m_width,FALSE /* don't check errors */); prepare_record(table, m_width, FALSE /* don't check errors */);
error= unpack_current_row(rli); error= unpack_current_row(rli);
#ifndef DBUG_OFF #ifndef DBUG_OFF
......
...@@ -307,17 +307,15 @@ unpack_row(Relay_log_info const *rli, ...@@ -307,17 +307,15 @@ unpack_row(Relay_log_info const *rli,
If @c check is true, fields are explicitly initialized only if they have If @c check is true, fields are explicitly initialized only if they have
default value or can be NULL. Otherwise error is reported. default value or can be NULL. Otherwise error is reported.
@param log Used to report errors.
@param table Table whose record[0] buffer is prepared. @param table Table whose record[0] buffer is prepared.
@param skip Number of columns for which default value initialization @param skip Number of columns for which default value initialization
should be skipped. should be skipped.
@param check Indicates if errors should be checked when setting default @param check Indicates if errors should be checked when setting default
values. values.
@returns 0 on success. @returns 0 on success or a handler level error code
*/ */
int prepare_record(const Slave_reporting_capability *const log, int prepare_record(TABLE *const table,
TABLE *const table,
const uint skip, const bool check) const uint skip, const bool check)
{ {
DBUG_ENTER("prepare_record"); DBUG_ENTER("prepare_record");
...@@ -337,13 +335,8 @@ int prepare_record(const Slave_reporting_capability *const log, ...@@ -337,13 +335,8 @@ int prepare_record(const Slave_reporting_capability *const log,
if (check && ((f->flags & mask) == mask)) if (check && ((f->flags & mask) == mask))
{ {
DBUG_ASSERT(log); my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), f->field_name);
log->report(ERROR_LEVEL, ER_NO_DEFAULT_FOR_FIELD, error = HA_ERR_ROWS_EVENT_APPLY;
"Field `%s` of table `%s`.`%s` "
"has no default value and cannot be NULL",
f->field_name, table->s->db.str,
table->s->table_name.str);
error = ER_NO_DEFAULT_FOR_FIELD;
} }
else else
f->set_default(); f->set_default();
......
...@@ -30,8 +30,7 @@ int unpack_row(Relay_log_info const *rli, ...@@ -30,8 +30,7 @@ int unpack_row(Relay_log_info const *rli,
uchar const **const row_end, ulong *const master_reclength); uchar const **const row_end, ulong *const master_reclength);
// Fill table's record[0] with default values. // Fill table's record[0] with default values.
int prepare_record(const Slave_reporting_capability *const, TABLE *const, int prepare_record(TABLE *const, const uint =0, const bool =FALSE);
const uint =0, const bool =FALSE);
#endif #endif
#endif #endif
...@@ -6119,3 +6119,5 @@ ER_SLAVE_AMBIGOUS_EXEC_MODE ...@@ -6119,3 +6119,5 @@ ER_SLAVE_AMBIGOUS_EXEC_MODE
ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT
eng "The BINLOG statement of type `%s` was not preceded by a format description BINLOG statement." eng "The BINLOG statement of type `%s` was not preceded by a format description BINLOG statement."
ER_SLAVE_CORRUPT_EVENT
eng "Corrupted replication event was detected"
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