Use an inline getter method (thd->is_error()) to query if there is an error

in THD.
In future the error may be stored elsewhere (not in net.report_error) and 
it's important to start using an opaque getter to simplify merges.
This commit is contained in:
kostja@bodhi.(none) 2007-10-30 20:08:16 +03:00
parent 0909d1f8cb
commit e4b353c40c
20 changed files with 82 additions and 68 deletions

View File

@ -555,7 +555,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
else
file->unlock_row();
/* It does not make sense to read more keys in case of a fatal error */
if (thd->net.report_error)
if (thd->is_error())
break;
}
if (quick_select)
@ -573,7 +573,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
file->ha_rnd_end();
}
if (thd->net.report_error)
if (thd->is_error())
DBUG_RETURN(HA_POS_ERROR);
/* Signal we should use orignal column read and write maps */

View File

@ -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->is_slave_error);
(int) thd->is_error(), thd->is_slave_error);
}
thd->options= save_thd_options;

View File

@ -187,7 +187,7 @@ Item_func::fix_fields(THD *thd, Item **ref)
}
}
fix_length_and_dec();
if (thd->net.report_error) // An error inside fix_length_and_dec occured
if (thd->is_error()) // An error inside fix_length_and_dec occured
return TRUE;
fixed= 1;
return FALSE;
@ -4073,7 +4073,7 @@ my_decimal *user_var_entry::val_decimal(my_bool *null_value, my_decimal *val)
NOTES
For now it always return OK. All problem with value evaluating
will be caught by thd->net.report_error check in sql_set_variables().
will be caught by thd->is_error() check in sql_set_variables().
RETURN
FALSE OK.

View File

@ -248,7 +248,7 @@ bool Item_subselect::exec()
{
int res;
if (thd->net.report_error)
if (thd->is_error())
/* Do not execute subselect in case of a fatal error */
return 1;

View File

@ -3051,7 +3051,7 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list)
if ((error= var->check(thd)))
goto err;
}
if (!(error= test(thd->net.report_error)))
if (!(error= test(thd->is_error())))
{
it.rewind();
while ((var= it++))

View File

@ -1866,7 +1866,7 @@ sp_cache_routines_and_add_tables_aux(THD *thd, LEX *lex,
an error with it's return value without calling my_error(), we
set the generic "mysql.proc table corrupt" error here.
*/
if (!thd->net.report_error)
if (! thd->is_error())
{
/*
SP allows full NAME_LEN chars thus he have to allocate enough

View File

@ -370,7 +370,7 @@ sp_eval_expr(THD *thd, Field *result_field, Item **expr_item_ptr)
thd->abort_on_warning= save_abort_on_warning;
thd->transaction.stmt.modified_non_trans_table= save_stmt_modified_non_trans_table;
if (thd->net.report_error)
if (thd->is_error())
{
/* Return error status if something went wrong. */
err_status= TRUE;
@ -1277,7 +1277,7 @@ sp_head::execute(THD *thd)
done:
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));
thd->is_error()));
if (thd->killed)
err_status= TRUE;
@ -2673,7 +2673,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
cleanup_items() is called in sp_head::execute()
*/
DBUG_RETURN(res || thd->net.report_error);
DBUG_RETURN(res || thd->is_error());
}

View File

@ -6260,7 +6260,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array,
thd->lex->allow_sum_func= save_allow_sum_func;
thd->mark_used_columns= save_mark_used_columns;
DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns));
DBUG_RETURN(test(thd->net.report_error));
DBUG_RETURN(test(thd->is_error()));
}
@ -6804,7 +6804,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
select_lex->conds_processed_with_permanent_arena= 1;
}
thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
DBUG_RETURN(test(thd->net.report_error));
DBUG_RETURN(test(thd->is_error()));
err_no_arena:
select_lex->is_item_list_lookup= save_is_item_list_lookup;
@ -6886,7 +6886,7 @@ fill_record(THD * thd, List<Item> &fields, List<Item> &values,
goto err;
}
}
DBUG_RETURN(thd->net.report_error);
DBUG_RETURN(thd->is_error());
err:
if (table)
table->auto_increment_field_not_null= FALSE;
@ -6971,7 +6971,7 @@ fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors)
table= (*ptr)->table;
table->auto_increment_field_not_null= FALSE;
}
while ((field = *ptr++) && !thd->net.report_error)
while ((field = *ptr++) && ! thd->is_error())
{
value=v++;
table= field->table;
@ -6980,7 +6980,7 @@ fill_record(THD *thd, Field **ptr, List<Item> &values, bool ignore_errors)
if (value->save_in_field(field, 0) < 0)
goto err;
}
DBUG_RETURN(thd->net.report_error);
DBUG_RETURN(thd->is_error());
err:
if (table)

View File

@ -1368,7 +1368,7 @@ bool select_send::send_data(List<Item> &items)
thd->sent_row_count++;
if (!thd->vio_ok())
DBUG_RETURN(0);
if (!thd->net.report_error)
if (! thd->is_error())
DBUG_RETURN(protocol->write());
protocol->remove_last_row();
DBUG_RETURN(1);
@ -1389,7 +1389,7 @@ bool select_send::send_eof()
mysql_unlock_tables(thd, thd->lock);
thd->lock=0;
}
if (!thd->net.report_error)
if (! thd->is_error())
{
::send_eof(thd);
status= 0;

View File

@ -1468,7 +1468,7 @@ public:
bool in_lock_tables;
/**
True if a slave error. Causes the slave to stop. Not the same
as the statement execution error (net.report_error), since
as the statement execution error (is_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.
*/
@ -1716,6 +1716,20 @@ public:
net.report_error= 1;
DBUG_PRINT("error",("Fatal error set"));
}
/**
TRUE if there is an error in the error stack.
Please use this method instead of direct access to
net.report_error.
If TRUE, the current (sub)-statement should be aborted.
The main difference between this member and is_fatal_error
is that a fatal error can not be handled by a stored
procedure continue handler, whereas a normal error can.
To raise this flag, use my_error().
*/
inline bool is_error() const { return net.report_error; }
inline CHARSET_INFO *charset() { return variables.character_set_client; }
void update_charset();

View File

@ -975,12 +975,12 @@ void end_connection(THD *thd)
decrease_user_connections(thd->user_connect);
if (thd->killed ||
net->error && net->vio != 0 && net->report_error)
net->error && net->vio != 0 && thd->is_error())
{
statistic_increment(aborted_threads,&LOCK_status);
}
if (net->error && net->vio != 0 && net->report_error)
if (net->error && net->vio != 0 && thd->is_error())
{
if (!thd->killed && thd->variables.log_warnings > 1)
{
@ -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->net.report_error)
if (thd->is_error())
{
thd->killed= THD::KILL_CONNECTION;
sql_print_warning(ER(ER_NEW_ABORTING_CONNECTION),

View File

@ -252,10 +252,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
table->mark_columns_needed_for_delete();
while (!(error=info.read_record(&info)) && !thd->killed &&
!thd->net.report_error)
! thd->is_error())
{
// thd->net.report_error is tested to disallow delete row on error
if (!(select && select->skip_record())&& !thd->net.report_error )
// thd->is_error() is tested to disallow delete row on error
if (!(select && select->skip_record())&& ! thd->is_error() )
{
if (table->triggers &&
@ -389,7 +389,7 @@ cleanup:
send_ok(thd, (ha_rows) thd->row_count_func);
DBUG_PRINT("info",("%ld records deleted",(long) deleted));
}
DBUG_RETURN(error >= 0 || thd->net.report_error);
DBUG_RETURN(error >= 0 || thd->is_error());
}

View File

@ -738,7 +738,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
table->triggers,
TRG_EVENT_INSERT))
{
if (values_list.elements != 1 && !thd->net.report_error)
if (values_list.elements != 1 && ! thd->is_error())
{
info.records++;
continue;
@ -769,7 +769,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
table->triggers,
TRG_EVENT_INSERT))
{
if (values_list.elements != 1 && ! thd->net.report_error)
if (values_list.elements != 1 && ! thd->is_error())
{
info.records++;
continue;
@ -1909,7 +1909,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
thd->proc_info="got old table";
if (di->thd.killed)
{
if (di->thd.net.report_error)
if (di->thd.is_error())
{
/*
Copy the error message. Note that we don't treat fatal
@ -1940,7 +1940,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
pthread_mutex_unlock(&di->mutex);
if (table_list->table)
{
DBUG_ASSERT(thd->net.report_error == 0);
DBUG_ASSERT(! thd->is_error());
thd->di= di;
}
/* Unlock the delayed insert object after its last access. */
@ -1949,7 +1949,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
end_create:
pthread_mutex_unlock(&LOCK_delayed_create);
DBUG_RETURN(thd->net.report_error);
DBUG_RETURN(thd->is_error());
}
@ -3015,7 +3015,7 @@ bool select_insert::send_data(List<Item> &values)
thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields
store_values(values);
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
if (thd->net.report_error)
if (thd->is_error())
DBUG_RETURN(1);
if (table_list) // Not CREATE ... SELECT
{

View File

@ -436,7 +436,7 @@ pthread_handler_t handle_bootstrap(void *arg)
if (thd->is_fatal_error)
break;
if (thd->net.report_error)
if (thd->is_error())
{
/* The query failed, send error to log and abort bootstrap */
net_send_error(thd);
@ -990,7 +990,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
mysql_parse(thd, thd->query, thd->query_length, & found_semicolon);
while (!thd->killed && found_semicolon && !thd->net.report_error)
while (!thd->killed && found_semicolon && ! thd->is_error())
{
char *next_packet= (char*) found_semicolon;
net->no_send_error= 0;
@ -1355,9 +1355,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->transaction.xid_state.xid.null();
/* report error issued during command execution */
if (thd->killed_errno() && !thd->net.report_error)
if (thd->killed_errno() && ! thd->is_error())
thd->send_kill_message();
if (thd->net.report_error)
if (thd->is_error())
net_send_error(thd);
log_slow_statement(thd);
@ -3930,7 +3930,7 @@ create_sp_error:
thd->row_count_func));
else
{
DBUG_ASSERT(thd->net.report_error == 1 || thd->killed);
DBUG_ASSERT(thd->is_error() || thd->killed);
goto error; // Substatement should already have sent error
}
}
@ -4523,7 +4523,7 @@ finish:
*/
start_waiting_global_read_lock(thd);
}
DBUG_RETURN(res || thd->net.report_error);
DBUG_RETURN(res || thd->is_error());
}
@ -5467,7 +5467,7 @@ void mysql_parse(THD *thd, const char *inBuf, uint length,
else
#endif
{
if (! thd->net.report_error)
if (! thd->is_error())
{
/*
Binlog logs a string starting from thd->query and having length
@ -5491,7 +5491,7 @@ void mysql_parse(THD *thd, const char *inBuf, uint length,
}
else
{
DBUG_ASSERT(thd->net.report_error);
DBUG_ASSERT(thd->is_error());
DBUG_PRINT("info",("Command aborted. Fatal_error: %d",
thd->is_fatal_error));
@ -6311,7 +6311,7 @@ void add_join_natural(TABLE_LIST *a, TABLE_LIST *b, List<String> *using_fields,
RETURN
0 ok
!=0 error. thd->killed or thd->net.report_error is set
!=0 error. thd->killed or thd->is_error() is set
*/
bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
@ -7274,10 +7274,10 @@ bool parse_sql(THD *thd,
bool mysql_parse_status= MYSQLparse(thd) != 0;
/* Check that if MYSQLparse() failed, thd->net.report_error is set. */
/* Check that if MYSQLparse() failed, thd->is_error() is set. */
DBUG_ASSERT(!mysql_parse_status ||
mysql_parse_status && thd->net.report_error);
mysql_parse_status && thd->is_error());
/* Reset Lex_input_stream. */

View File

@ -2864,7 +2864,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
lex_start(thd);
error= parse_sql(thd, &lip, NULL) ||
thd->net.report_error ||
thd->is_error() ||
init_param_array(this);
lex->set_trg_event_type_for_tables();

View File

@ -263,8 +263,8 @@ bool handle_select(THD *thd, LEX *lex, select_result *result,
result, unit, select_lex);
}
DBUG_PRINT("info",("res: %d report_error: %d", res,
thd->net.report_error));
res|= thd->net.report_error;
thd->is_error()));
res|= thd->is_error();
if (unlikely(res))
result->abort();
@ -491,7 +491,7 @@ JOIN::prepare(Item ***rref_pointer_array,
(having->fix_fields(thd, &having) ||
having->check_cols(1)));
select_lex->having_fix_field= 0;
if (having_fix_rc || thd->net.report_error)
if (having_fix_rc || thd->is_error())
DBUG_RETURN(-1); /* purecov: inspected */
thd->lex->allow_sum_func= save_allow_sum_func;
}
@ -817,7 +817,7 @@ JOIN::optimize()
}
conds= optimize_cond(this, conds, join_list, &cond_value);
if (thd->net.report_error)
if (thd->is_error())
{
error= 1;
DBUG_PRINT("error",("Error from optimize_cond"));
@ -826,7 +826,7 @@ JOIN::optimize()
{
having= optimize_cond(this, having, join_list, &having_value);
if (thd->net.report_error)
if (thd->is_error())
{
error= 1;
DBUG_PRINT("error",("Error from optimize_cond"));
@ -1031,7 +1031,7 @@ JOIN::optimize()
{
ORDER *org_order= order;
order=remove_const(this, order,conds,1, &simple_order);
if (thd->net.report_error)
if (thd->is_error())
{
error= 1;
DBUG_PRINT("error",("Error from remove_const"));
@ -1162,7 +1162,7 @@ JOIN::optimize()
group_list= remove_const(this, (old_group_list= group_list), conds,
rollup.state == ROLLUP::STATE_NONE,
&simple_group);
if (thd->net.report_error)
if (thd->is_error())
{
error= 1;
DBUG_PRINT("error",("Error from remove_const"));
@ -1185,7 +1185,7 @@ JOIN::optimize()
{
group_list= procedure->group= remove_const(this, procedure->group, conds,
1, &simple_group);
if (thd->net.report_error)
if (thd->is_error())
{
error= 1;
DBUG_PRINT("error",("Error from remove_const"));
@ -2098,10 +2098,10 @@ JOIN::exec()
}
}
}
/* XXX: When can we have here thd->net.report_error not zero? */
if (thd->net.report_error)
/* XXX: When can we have here thd->is_error() not zero? */
if (thd->is_error())
{
error= thd->net.report_error;
error= thd->is_error();
DBUG_VOID_RETURN;
}
curr_join->having= curr_join->tmp_having;
@ -2307,7 +2307,7 @@ mysql_select(THD *thd, Item ***rref_pointer_array,
join->having_history= (join->having?join->having:join->tmp_having);
}
if (thd->net.report_error)
if (thd->is_error())
goto err;
join->exec();
@ -2333,7 +2333,7 @@ err:
{
thd->proc_info="end";
err|= select_lex->cleanup();
DBUG_RETURN(err || thd->net.report_error);
DBUG_RETURN(err || thd->is_error());
}
DBUG_RETURN(join->error);
}
@ -10717,7 +10717,7 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
DBUG_PRINT("error",("Error: do_select() failed"));
}
#endif
DBUG_RETURN(join->thd->net.report_error ? -1 : rc);
DBUG_RETURN(join->thd->is_error() ? -1 : rc);
}
@ -16050,7 +16050,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
first->options | thd->options | SELECT_DESCRIBE,
result, unit, first);
}
DBUG_RETURN(res || thd->net.report_error);
DBUG_RETURN(res || thd->is_error());
}

View File

@ -58,7 +58,7 @@ bool select_union::send_data(List<Item> &values)
return 0;
}
fill_record(thd, table->field, values, 1);
if (thd->net.report_error)
if (thd->is_error())
return 1;
if ((error= table->file->ha_write_row(table->record[0])))

View File

@ -844,7 +844,7 @@ int mysql_update(THD *thd,
}
thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
thd->abort_on_warning= 0;
DBUG_RETURN((error >= 0 || thd->net.report_error) ? 1 : 0);
DBUG_RETURN((error >= 0 || thd->is_error()) ? 1 : 0);
err:
delete select;
@ -1193,8 +1193,8 @@ bool mysql_multi_update(THD *thd,
OPTION_SETUP_TABLES_DONE,
result, unit, select_lex);
DBUG_PRINT("info",("res: %d report_error: %d", res,
thd->net.report_error));
res|= thd->net.report_error;
(int) thd->is_error()));
res|= thd->is_error();
if (unlikely(res))
{
/* If we had a another error reported earlier then this will be ignored */

View File

@ -607,7 +607,7 @@ err:
thd->proc_info= "end";
lex->link_first_table_back(view, link_to_local);
unit->cleanup();
DBUG_RETURN(res || thd->net.report_error);
DBUG_RETURN(res || thd->is_error());
}
@ -823,7 +823,7 @@ loop_out:
view_parameters + revision_number_position, 1,
&file_parser_dummy_hook))
{
error= thd->net.report_error? -1 : 0;
error= thd->is_error() ? -1 : 0;
goto err;
}
}
@ -886,7 +886,7 @@ loop_out:
if (sql_create_definition_file(&dir, &file, view_file_type,
(uchar*)view, view_parameters, num_view_backups))
{
error= thd->net.report_error? -1 : 1;
error= thd->is_error() ? -1 : 1;
goto err;
}
DBUG_RETURN(0);

View File

@ -9804,7 +9804,7 @@ NUM_literal:
| DECIMAL_NUM
{
$$= new Item_decimal($1.str, $1.length, YYTHD->charset());
if (YYTHD->net.report_error)
if (YYTHD->is_error())
{
MYSQL_YYABORT;
}
@ -9812,7 +9812,7 @@ NUM_literal:
| FLOAT_NUM
{
$$ = new Item_float($1.str, $1.length);
if (YYTHD->net.report_error)
if (YYTHD->is_error())
{
MYSQL_YYABORT;
}