diff options
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r-- | sql/log_event.cc | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc index 82d29322b4a..f31a7452e56 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -112,14 +112,14 @@ static void inline slave_rows_error_report(enum loglevel level, int ha_error, const char *log_name, ulong pos) { const char *handler_error= HA_ERR(ha_error); - rli->report(level, thd->net.last_errno, + rli->report(level, thd->net.client_last_errno, "Could not execute %s event on table %s.%s;" "%s%s handler error %s; " "the event's master log %s, end_log_pos %lu", type, table->s->db.str, table->s->table_name.str, - thd->net.last_error[0] != 0 ? thd->net.last_error : "", - thd->net.last_error[0] != 0 ? ";" : "", + thd->net.client_last_error[0] != 0 ? thd->net.client_last_error : "", + thd->net.client_last_error[0] != 0 ? ";" : "", handler_error == NULL? "<unknown>" : handler_error, log_name, pos); } @@ -1692,7 +1692,8 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, if (killed_status_arg == THD::KILLED_NO_VALUE) killed_status_arg= thd_arg->killed; error_code= - (killed_status_arg == THD::NOT_KILLED) ? thd_arg->net.last_errno : + (killed_status_arg == THD::NOT_KILLED) ? + (thd_arg->is_error() ? thd_arg->main_da.sql_errno() : 0) : ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 : thd_arg->killed_errno()); @@ -2414,7 +2415,7 @@ START SLAVE; . Query: '%s'", expected_error, thd->query); } /* If the query was not ignored, it is printed to the general log */ - if (thd->net.last_errno != ER_SLAVE_IGNORED_TABLE) + if (!thd->is_error() || thd->main_da.sql_errno() != ER_SLAVE_IGNORED_TABLE) general_log_write(thd, COM_QUERY, thd->query, thd->query_length); compare_errors: @@ -2423,9 +2424,10 @@ compare_errors: If we expected a non-zero error code, and we don't get the same error code, and none of them should be ignored. */ - DBUG_PRINT("info",("expected_error: %d last_errno: %d", - expected_error, thd->net.last_errno)); - if ((expected_error != (actual_error= thd->net.last_errno)) && + actual_error= thd->is_error() ? thd->main_da.sql_errno() : 0; + DBUG_PRINT("info",("expected_error: %d sql_errno: %d", + expected_error, actual_error)); + if ((expected_error != actual_error) && expected_error && !ignored_error_code(actual_error) && !ignored_error_code(expected_error)) @@ -2437,7 +2439,7 @@ Error on master: '%s' (%d), Error on slave: '%s' (%d). \ Default database: '%s'. Query: '%s'", ER_SAFE(expected_error), expected_error, - actual_error ? thd->net.last_error: "no error", + actual_error ? thd->main_da.message() : "no error", actual_error, print_slave_db_safe(db), query_arg); thd->is_slave_error= 1; @@ -2459,7 +2461,7 @@ Default database: '%s'. Query: '%s'", { rli->report(ERROR_LEVEL, actual_error, "Error '%s' on query. Default database: '%s'. Query: '%s'", - (actual_error ? thd->net.last_error : + (actual_error ? thd->main_da.message() : "unexpected success or fatal error"), print_slave_db_safe(thd->db), query_arg); thd->is_slave_error= 1; @@ -3869,8 +3871,11 @@ error: /* this err/sql_errno code is copy-paste from net_send_error() */ const char *err; int sql_errno; - if ((err=thd->net.last_error)[0]) - sql_errno=thd->net.last_errno; + if (thd->is_error()) + { + err= thd->main_da.message(); + sql_errno= thd->main_da.sql_errno(); + } else { sql_errno=ER_UNKNOWN_ERROR; @@ -6391,10 +6396,10 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) Error reporting borrowed from Query_log_event with many excessive simplifications (we don't honour --slave-skip-errors) */ - uint actual_error= thd->net.last_errno; + uint actual_error= thd->main_da.sql_errno(); rli->report(ERROR_LEVEL, actual_error, "Error '%s' in %s event: when locking tables", - (actual_error ? thd->net.last_error : + (actual_error ? thd->main_da.message(): "unexpected success or fatal error"), get_type_str()); thd->is_fatal_error= 1; @@ -6435,10 +6440,10 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli) Error reporting borrowed from Query_log_event with many excessive simplifications (we don't honour --slave-skip-errors) */ - uint actual_error= thd->net.last_errno; + uint actual_error= thd->main_da.sql_errno(); rli->report(ERROR_LEVEL, actual_error, "Error '%s' on reopening tables", - (actual_error ? thd->net.last_error : + (actual_error ? thd->main_da.message() : "unexpected success or fatal error")); thd->is_slave_error= 1; } @@ -7266,10 +7271,10 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli) Error reporting borrowed from Query_log_event with many excessive simplifications (we don't honour --slave-skip-errors) */ - uint actual_error= thd->net.last_errno; + uint actual_error= thd->main_da.sql_errno(); rli->report(ERROR_LEVEL, actual_error, "Error '%s' on opening table `%s`.`%s`", - (actual_error ? thd->net.last_error : + (actual_error ? thd->main_da.message() : "unexpected success or fatal error"), table_list->db, table_list->table_name); thd->is_slave_error= 1; @@ -7810,8 +7815,11 @@ Write_rows_log_event::do_exec_row(const Relay_log_info *const rli) write_row(rli, /* if 1 then overwrite */ bit_is_set(slave_exec_mode, SLAVE_EXEC_MODE_IDEMPOTENT) == 1); - if (error && !thd->net.last_errno) - thd->net.last_errno= error; + if (error && !thd->is_error()) + { + DBUG_ASSERT(0); + my_error(ER_UNKNOWN_ERROR, MYF(0)); + } return error; } |