Commit 6b658b9f authored by unknown's avatar unknown

Rename: query_error -> is_slave_error.

Add comments.


sql/ha_ndbcluster_binlog.cc:
  query_error -> slave_error
sql/handler.cc:
  query_error -> slave_error
sql/log.cc:
  query_error -> slave_error
sql/log_event.cc:
  query_error -> slave_error
sql/log_event_old.cc:
  query_error -> slave_error
sql/mysqld.cc:
  query_error -> slave_error
sql/protocol.cc:
  query_error -> slave_error
sql/slave.cc:
  query_error -> slave_error
sql/sp_head.cc:
  query_error -> slave_error
sql/sql_class.cc:
  query_error -> slave_error
sql/sql_class.h:
  Rename: query_error -> is_slave_error, to avoid confusion.
  Add commenta.
sql/sql_connect.cc:
  Rename: query_error -> is_slave_error, to avoid confusion.
  Originally it was the same code to handle init-connect and init-slave 
  mysqld options. Then init-connect implementation forked off,
  but the one who copy-pasted the code didn't change it to not
  use a replication-specific variable.
parent 9248b192
......@@ -259,7 +259,7 @@ static void run_query(THD *thd, char *buf, char *end,
DBUG_PRINT("query", ("%s", thd->query));
mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
if (no_print_error && thd->query_error)
if (no_print_error && thd->is_slave_error)
{
int i;
Thd_ndb *thd_ndb= get_thd_ndb(thd);
......@@ -271,7 +271,7 @@ static void run_query(THD *thd, char *buf, char *end,
sql_print_error("NDB: %s: error %s %d(ndb: %d) %d %d",
buf, thd->net.last_error, thd->net.last_errno,
thd_ndb->m_error_code,
thd->net.report_error, thd->query_error);
thd->net.report_error, thd->is_slave_error);
}
thd->options= save_thd_options;
......
......@@ -1447,7 +1447,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
(We should in the future either rewrite handler::print_error() or make
a nice method of this.
*/
bool query_error= thd->query_error;
bool is_slave_error= thd->is_slave_error;
sp_rcontext *spcont= thd->spcont;
SELECT_LEX *current_select= thd->lex->current_select;
char buff[sizeof(thd->net.last_error)];
......@@ -1455,7 +1455,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
int last_errno= thd->net.last_errno;
strmake(buff, thd->net.last_error, sizeof(buff)-1);
thd->query_error= 0;
thd->is_slave_error= 0;
thd->spcont= NULL;
thd->lex->current_select= 0;
thd->net.last_error[0]= 0;
......@@ -1475,7 +1475,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
strmake(new_error, thd->net.last_error, sizeof(buff)-1);
/* restore thd */
thd->query_error= query_error;
thd->is_slave_error= is_slave_error;
thd->spcont= spcont;
thd->lex->current_select= current_select;
thd->net.last_errno= last_errno;
......
......@@ -2891,8 +2891,8 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log,
*decrease_log_space-= file_size;
ha_binlog_index_purge_file(current_thd, log_info.log_file_name);
if (current_thd->query_error) {
DBUG_PRINT("info",("query error: %d", current_thd->query_error));
if (current_thd->is_slave_error) {
DBUG_PRINT("info",("slave error: %d", current_thd->is_slave_error));
if (my_errno == EMFILE) {
DBUG_PRINT("info",("my_errno: %d, set ret = LOG_INFO_EMFILE", my_errno));
ret = LOG_INFO_EMFILE;
......
......@@ -148,7 +148,7 @@ static void pretty_print_str(IO_CACHE* cache, char* str, int len)
static void clear_all_errors(THD *thd, Relay_log_info *rli)
{
thd->query_error = 0;
thd->is_slave_error = 0;
thd->clear_error();
rli->clear_error();
}
......@@ -2106,7 +2106,7 @@ and was aborted. There is a chance that your master is inconsistent at this \
point. If you are sure that your master is ok, run this query manually on the \
slave and then restart the slave with SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; \
START SLAVE; . Query: '%s'", expected_error, thd->query);
thd->query_error= 1;
thd->is_slave_error= 1;
}
goto end;
}
......@@ -2138,7 +2138,7 @@ Default database: '%s'. Query: '%s'",
actual_error ? thd->net.last_error: "no error",
actual_error,
print_slave_db_safe(db), query_arg);
thd->query_error= 1;
thd->is_slave_error= 1;
}
/*
If we get the same error code as expected, or they should be ignored.
......@@ -2153,14 +2153,14 @@ Default database: '%s'. Query: '%s'",
/*
Other cases: mostly we expected no error and get one.
*/
else if (thd->query_error || thd->is_fatal_error)
else if (thd->is_slave_error || thd->is_fatal_error)
{
rli->report(ERROR_LEVEL, actual_error,
"Error '%s' on query. Default database: '%s'. Query: '%s'",
(actual_error ? thd->net.last_error :
"unexpected success or fatal error"),
print_slave_db_safe(thd->db), query_arg);
thd->query_error= 1;
thd->is_slave_error= 1;
}
/*
......@@ -2171,7 +2171,7 @@ Default database: '%s'. Query: '%s'",
sql_print_error("Slave: did not get the expected number of affected \
rows running query from master - expected %d, got %d (this numbers \
should have matched modulo 4294967296).", 0, ...);
thd->query_error = 1;
thd->is_slave_error = 1;
}
We may also want an option to tell the slave to ignore "affected"
mismatch. This mismatch could be implemented with a new ER_ code, and
......@@ -2215,7 +2215,7 @@ Default database: '%s'. Query: '%s'",
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;
return thd->is_slave_error;
}
int Query_log_event::do_update_pos(Relay_log_info *rli)
......@@ -3255,7 +3255,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
thd->set_db(new_db.str, new_db.length);
DBUG_ASSERT(thd->query == 0);
thd->query_length= 0; // Should not be needed
thd->query_error= 0;
thd->is_slave_error= 0;
clear_all_errors(thd, const_cast<Relay_log_info*>(rli));
/* see Query_log_event::do_apply_event() and BUG#13360 */
......@@ -3429,7 +3429,7 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
List<Item> tmp_list;
if (mysql_load(thd, &ex, &tables, field_list, tmp_list, tmp_list,
handle_dup, ignore, net != 0))
thd->query_error= 1;
thd->is_slave_error= 1;
if (thd->cuted_fields)
{
/* log_pos is the position of the LOAD event in the master log */
......@@ -3468,9 +3468,9 @@ int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
close_thread_tables(thd);
DBUG_EXECUTE_IF("LOAD_DATA_INFILE_has_fatal_error",
thd->query_error= 0; thd->is_fatal_error= 1;);
thd->is_slave_error= 0; thd->is_fatal_error= 1;);
if (thd->query_error)
if (thd->is_slave_error)
{
/* this err/sql_errno code is copy-paste from net_send_error() */
const char *err;
......@@ -5655,7 +5655,7 @@ Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid,
m_width(tbl_arg ? tbl_arg->s->fields : 1),
m_rows_buf(0), m_rows_cur(0), m_rows_end(0), m_flags(0)
#ifdef HAVE_REPLICATION
,m_key(NULL), m_curr_row(NULL), m_curr_row_end(NULL)
, m_curr_row(NULL), m_curr_row_end(NULL), m_key(NULL)
#endif
{
/*
......@@ -5703,7 +5703,7 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len,
#endif
m_table_id(0), m_rows_buf(0), m_rows_cur(0), m_rows_end(0)
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
,m_key(NULL), m_curr_row(NULL), m_curr_row_end(NULL)
, m_curr_row(NULL), m_curr_row_end(NULL), m_key(NULL)
#endif
{
DBUG_ENTER("Rows_log_event::Rows_log_event(const char*,...)");
......@@ -5951,7 +5951,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
{
if (!need_reopen)
{
if (thd->query_error || thd->is_fatal_error)
if (thd->is_slave_error || thd->is_fatal_error)
{
/*
Error reporting borrowed from Query_log_event with many excessive
......@@ -5995,7 +5995,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
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)
if (thd->is_slave_error || thd->is_fatal_error)
{
/*
Error reporting borrowed from Query_log_event with many excessive
......@@ -6006,7 +6006,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
"Error '%s' on reopening tables",
(actual_error ? thd->net.last_error :
"unexpected success or fatal error"));
thd->query_error= 1;
thd->is_slave_error= 1;
}
const_cast<Relay_log_info*>(rli)->clear_tables_to_lock();
DBUG_RETURN(error);
......@@ -6029,7 +6029,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
{
mysql_unlock_tables(thd, thd->lock);
thd->lock= 0;
thd->query_error= 1;
thd->is_slave_error= 1;
const_cast<Relay_log_info*>(rli)->clear_tables_to_lock();
DBUG_RETURN(ERR_BAD_TABLE_DEF);
}
......@@ -6159,7 +6159,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
"Error in %s event: row application failed. %s",
get_type_str(),
thd->net.last_error ? thd->net.last_error : "");
thd->query_error= 1;
thd->is_slave_error= 1;
break;
}
......@@ -6221,7 +6221,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
*/
thd->reset_current_stmt_binlog_row_based();
const_cast<Relay_log_info*>(rli)->cleanup_context(thd, error);
thd->query_error= 1;
thd->is_slave_error= 1;
DBUG_RETURN(error);
}
......@@ -6519,9 +6519,15 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid,
m_dblen(m_dbnam ? tbl->s->db.length : 0),
m_tblnam(tbl->s->table_name.str),
m_tbllen(tbl->s->table_name.length),
m_colcnt(tbl->s->fields), m_field_metadata(0),
m_field_metadata_size(0), m_memory(NULL), m_meta_memory(NULL), m_data_size(0),
m_table_id(tid), m_null_bits(0), m_flags(flags)
m_colcnt(tbl->s->fields),
m_memory(NULL),
m_table_id(tid),
m_flags(flags),
m_data_size(0),
m_field_metadata(0),
m_field_metadata_size(0),
m_null_bits(0),
m_meta_memory(NULL)
{
DBUG_ASSERT(m_table_id != ~0UL);
/*
......@@ -6798,7 +6804,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
TABLE_LIST *tmp_table_list= table_list;
if ((error= open_tables(thd, &tmp_table_list, &count, 0)))
{
if (thd->query_error || thd->is_fatal_error)
if (thd->is_slave_error || thd->is_fatal_error)
{
/*
Error reporting borrowed from Query_log_event with many excessive
......@@ -6810,7 +6816,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
(actual_error ? thd->net.last_error :
"unexpected success or fatal error"),
table_list->db, table_list->table_name);
thd->query_error= 1;
thd->is_slave_error= 1;
}
goto err;
}
......
......@@ -68,7 +68,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli
{
if (!need_reopen)
{
if (thd->query_error || thd->is_fatal_error)
if (thd->is_slave_error || thd->is_fatal_error)
{
/*
Error reporting borrowed from Query_log_event with many excessive
......@@ -112,7 +112,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli
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)
if (thd->is_slave_error || thd->is_fatal_error)
{
/*
Error reporting borrowed from Query_log_event with many excessive
......@@ -123,7 +123,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli
"Error '%s' on reopening tables",
(actual_error ? thd->net.last_error :
"unexpected success or fatal error"));
thd->query_error= 1;
thd->is_slave_error= 1;
}
const_cast<Relay_log_info*>(rli)->clear_tables_to_lock();
DBUG_RETURN(error);
......@@ -146,7 +146,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli
{
mysql_unlock_tables(thd, thd->lock);
thd->lock= 0;
thd->query_error= 1;
thd->is_slave_error= 1;
const_cast<Relay_log_info*>(rli)->clear_tables_to_lock();
DBUG_RETURN(Rows_log_event::ERR_BAD_TABLE_DEF);
}
......@@ -255,7 +255,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli
"Error in %s event: row application failed. %s",
ev->get_type_str(),
thd->net.last_error ? thd->net.last_error : "");
thd->query_error= 1;
thd->is_slave_error= 1;
break;
}
......@@ -300,7 +300,7 @@ Old_rows_log_event::do_apply_event(Rows_log_event *ev, const Relay_log_info *rli
*/
thd->reset_current_stmt_binlog_row_based();
const_cast<Relay_log_info*>(rli)->cleanup_context(thd, error);
thd->query_error= 1;
thd->is_slave_error= 1;
DBUG_RETURN(error);
}
......
......@@ -2593,7 +2593,7 @@ int my_message_sql(uint error, const char *str, myf MyFlags)
DBUG_RETURN(0);
}
thd->query_error= 1; // needed to catch query errors during replication
thd->is_slave_error= 1; // needed to catch query errors during replication
if (!thd->no_warnings_for_error)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str);
......
......@@ -84,7 +84,7 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
DBUG_VOID_RETURN;
}
thd->query_error= 1; // needed to catch query errors during replication
thd->is_slave_error= 1; // needed to catch query errors during replication
if (!err)
{
if (sql_errno)
......@@ -162,7 +162,7 @@ net_printf_error(THD *thd, uint errcode, ...)
DBUG_VOID_RETURN;
}
thd->query_error= 1; // needed to catch query errors during replication
thd->is_slave_error= 1; // needed to catch query errors during replication
#ifndef EMBEDDED_LIBRARY
query_cache_abort(net); // Safety
#endif
......
......@@ -980,7 +980,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
DBUG_RETURN(1);
}
thd->query= query;
thd->query_error = 0;
thd->is_slave_error = 0;
thd->net.no_send_ok = 1;
bzero((char*) &tables,sizeof(tables));
......@@ -1009,7 +1009,7 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
thd->db_length= save_db_length;
thd->options = save_options;
if (thd->query_error)
if (thd->is_slave_error)
goto err; // mysql_parse took care of the error send
thd->proc_info = "Opening master dump table";
......@@ -2501,7 +2501,7 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME,
if (sys_init_slave.value_length)
{
execute_init_command(thd, &sys_init_slave, &LOCK_sys_init_slave);
if (thd->query_error)
if (thd->is_slave_error)
{
sql_print_error("\
Slave SQL thread aborted. Can't execute init_slave query");
......
......@@ -1108,7 +1108,7 @@ sp_head::execute(THD *thd)
if ((ctx= thd->spcont))
ctx->clear_handler();
thd->query_error= 0;
thd->is_slave_error= 0;
old_arena= thd->stmt_arena;
/*
......@@ -1275,8 +1275,8 @@ sp_head::execute(THD *thd)
state= EXECUTED;
done:
DBUG_PRINT("info", ("err_status: %d killed: %d query_error: %d report_error: %d",
err_status, thd->killed, thd->query_error,
DBUG_PRINT("info", ("err_status: %d killed: %d is_slave_error: %d report_error: %d",
err_status, thd->killed, thd->is_slave_error,
thd->net.report_error));
if (thd->killed)
......
......@@ -395,7 +395,7 @@ THD::THD()
count_cuted_fields= CHECK_FIELD_IGNORE;
killed= NOT_KILLED;
col_access=0;
query_error= thread_specific_used= FALSE;
is_slave_error= thread_specific_used= FALSE;
hash_clear(&handler_tables_hash);
tmp_table=0;
used_tables=0;
......
......@@ -1466,7 +1466,14 @@ class THD :public Statement,
/* for IS NULL => = last_insert_id() fix in remove_eq_conds() */
bool substitute_null_with_insert_id;
bool in_lock_tables;
bool query_error, bootstrap, cleanup_done;
/**
True if a slave error. Causes the slave to stop. Not the same
as the statement execution error (net.report_error), since
a statement may be expected to return an error, e.g. because
it returned an error on master, and this is OK on the slave.
*/
bool is_slave_error;
bool bootstrap, cleanup_done;
/** is set if some thread specific value(s) used in a statement. */
bool thread_specific_used;
......@@ -1695,7 +1702,7 @@ class THD :public Statement,
net.last_error[0]= 0;
net.last_errno= 0;
net.report_error= 0;
query_error= 0;
is_slave_error= 0;
DBUG_VOID_RETURN;
}
inline bool vio_ok() const { return net.vio != 0; }
......
......@@ -1030,7 +1030,7 @@ static void prepare_new_connection_state(THD* thd)
if (sys_init_connect.value_length && !(sctx->master_access & SUPER_ACL))
{
execute_init_command(thd, &sys_init_connect, &LOCK_sys_init_connect);
if (thd->query_error)
if (thd->net.report_error)
{
thd->killed= THD::KILL_CONNECTION;
sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION),
......
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