diff options
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index 0421c567c65..b1f25ee58da 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -981,17 +981,24 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, } thd->query= query; thd->is_slave_error = 0; - thd->net.no_send_ok = 1; bzero((char*) &tables,sizeof(tables)); tables.db = (char*)db; tables.alias= tables.table_name= (char*)table_name; /* Drop the table if 'overwrite' is true */ - if (overwrite && mysql_rm_table(thd,&tables,1,0)) /* drop if exists */ + if (overwrite) { - sql_print_error("create_table_from_dump: failed to drop the table"); - goto err; + if (mysql_rm_table(thd,&tables,1,0)) /* drop if exists */ + { + sql_print_error("create_table_from_dump: failed to drop the table"); + goto err; + } + else + { + /* Clear the OK result of mysql_rm_table(). */ + thd->main_da.reset_diagnostics_area(); + } } /* Create the table. We do not want to log the "create table" statement */ @@ -1012,6 +1019,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, if (thd->is_slave_error) goto err; // mysql_parse took care of the error send + thd->main_da.reset_diagnostics_area(); /* cleanup from CREATE_TABLE */ thd->proc_info = "Opening master dump table"; /* Note: If this function starts to fail for MERGE tables, @@ -1055,7 +1063,6 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, err: close_thread_tables(thd); - thd->net.no_send_ok = 0; DBUG_RETURN(error); } @@ -1107,7 +1114,6 @@ int fetch_master_table(THD *thd, const char *db_name, const char *table_name, error = 0; err: - thd->net.no_send_ok = 0; // Clear up garbage after create_table_from_dump if (!called_connected) mysql_close(mysql); if (errmsg && thd->vio_ok()) @@ -1721,26 +1727,31 @@ static int has_temporary_error(THD *thd) DBUG_ENTER("has_temporary_error"); if (thd->is_fatal_error) - { - DBUG_PRINT("info", ("thd->net.last_errno: %s", ER(thd->net.last_errno))); DBUG_RETURN(0); - } DBUG_EXECUTE_IF("all_errors_are_temporary_errors", - if (thd->net.last_errno) - thd->net.last_errno= ER_LOCK_DEADLOCK;); + if (thd->main_da.is_error()) + { + thd->clear_error(); + my_error(ER_LOCK_DEADLOCK, MYF(0)); + }); + + /* + If there is no message in THD, we can't say if it's a temporary + error or not. This is currently the case for Incident_log_event, + which sets no message. Return FALSE. + */ + if (!thd->is_error()) + DBUG_RETURN(0); /* Temporary error codes: currently, InnoDB deadlock detected by InnoDB or lock wait timeout (innodb_lock_wait_timeout exceeded */ - if (thd->net.last_errno == ER_LOCK_DEADLOCK || - thd->net.last_errno == ER_LOCK_WAIT_TIMEOUT) - { - DBUG_PRINT("info", ("thd->net.last_errno: %s", ER(thd->net.last_errno))); + if (thd->main_da.sql_errno() == ER_LOCK_DEADLOCK || + thd->main_da.sql_errno() == ER_LOCK_WAIT_TIMEOUT) DBUG_RETURN(1); - } #ifdef HAVE_NDB_BINLOG /* @@ -2551,20 +2562,21 @@ Slave SQL thread aborted. Can't execute init_slave query"); */ 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)); - if (thd->net.last_errno != 0) + if (thd->is_error()) { - char const *const errmsg= - thd->net.last_error ? thd->net.last_error : "<no message>"; + char const *const errmsg= thd->main_da.message(); + + DBUG_PRINT("info", + ("thd->main_da.sql_errno()=%d; rli->last_error.number=%d", + thd->main_da.sql_errno(), last_errno)); if (last_errno == 0) { - rli->report(ERROR_LEVEL, thd->net.last_errno, errmsg); + rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), errmsg); } - else if (last_errno != thd->net.last_errno) + else if (last_errno != thd->main_da.sql_errno()) { sql_print_error("Slave (additional info): %s Error_code: %d", - errmsg, thd->net.last_errno); + errmsg, thd->main_da.sql_errno()); } } |