MySQL Internals Manual  /  Important Algorithms and Structures  /  Error Flags and Functions

10.12 Error Flags and Functions

The following flags can be examined or set to alter the behavior during error handling:

  • thd->net.report_error

thd->net.report_error is set in my_message_sql() if the error message was registered. (my_message_sql() is called by my_error(), my_printf_error(), my_message()).

  • thd->query_error

Like net.report_error, but is always set to 1 in my_message_sql() if error was not caught by an error handler. Used by replication to see if a query generated any kind of errors.

  • thd->no_warnings_for_error

Normally an error also generates a warning. The warning can be disabled by setting thd->no_warnings_for_error. (This allows one to catch all error messages generated by a statement)

  • thd->lex->current_select->no_error

This is set to in case likes INSERT IGNORE ... SELECT. In this case we ignore all not fatal errors generated by the select.

  • thd->is_fatal_error

Set this if we should abort the current statement (and any multi-line statements) because something went fatally wrong. (for example, a stored procedure continue handler should not be able to catch this). This is reset by mysql_reset_thd_for_next_command().

  • thd->abort_on_warning

Strict mode flag, which means that we should abort the statement if we get a warning. In the field::store function this changes the warning level from WARN to ERROR. In other cases, this flag is mostly tested with thd->really_abort_on_warning() to ensure we don't abort in the middle of an update with not transactional tables.

  • thd->count_cuted_fields

If set, we generate warning for field conversations (normal case for INSERT/UPDATE/DELETE). This is mainly set to 0 when doing internal copying of data between fields and we don't want to generate any conversion errors at any level.

  • thd->killed

Set in case of error in connection protocol or in case of 'kill'. In this case we should abort the query and kill the connection.

Error functions

  • thd->really_abort_on_warning()

This function returns 1 if a warning should be converted to an error, like in strict mode when all tables are transactional. The conversion is handled in sql_error.cc::push_warning().

  • thd->fatal_error()

Should be called if we want to abort the current statement and any multi-line statement.

  • thd->clear_error()

Resets thd->net.report_error and thd->query_error.


User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Sign Up Login You must be logged in to post a comment.