MySQL 9.0.0
Source Code Documentation
derror.cc File Reference
#include "sql/derror.h"
#include <fcntl.h>
#include <stddef.h>
#include <sys/types.h>
#include "m_string.h"
#include "my_byteorder.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_sys.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/my_loglevel.h"
#include "mysql/psi/mysql_file.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql/strings/m_ctype.h"
#include "mysqld_error.h"
#include "nulls.h"
#include "sql/current_thd.h"
#include "sql/log.h"
#include "sql/mysqld.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_class.h"
#include "sql/sql_locale.h"
#include "sql/system_variables.h"
#include "storage/perfschema/pfs_error.h"

Functions

int mysql_errno_to_builtin (uint mysql_errno)
 Find the error message record for a given MySQL error code in the array of registered messages. More...
 
const char * ER_DEFAULT (int mysql_errno)
 
const char * ER_THD (const THD *thd, int mysql_errno)
 
const char * ER_DEFAULT_NONCONST (int mysql_errno)
 
const char * ER_THD_NONCONST (const THD *thd, int mysql_errno)
 
static const char * error_message_fetch (int mysql_errno)
 Get the error-message corresponding to the given MySQL error-code, or nullptr if no message is available for that code (this may indicate a bug in the caller). More...
 
const char * error_message_for_error_log (int mysql_errno)
 Get the error-message corresponding to the given MySQL error-code, or nullptr if no message is available for that code (this may indicate a bug in the caller). More...
 
const char * error_message_for_client (int mysql_errno)
 Get the error-message corresponding to the given MySQL error-code, or nullptr if no message is available for that code (this may indicate a bug in the caller). More...
 
bool init_errmessage ()
 Read the error message file, initialize and register error messages for all languages. More...
 
void deinit_errmessage ()
 Unregister error messages for all languages. More...
 

Variables

CHARSET_INFOerror_message_charset_info
 Character set of the buildin error messages loaded from errmsg.sys. More...
 
static const char * ERRMSG_FILE = "errmsg.sys"
 

Function Documentation

◆ deinit_errmessage()

void deinit_errmessage ( )

Unregister error messages for all languages.

◆ ER_DEFAULT()

const char * ER_DEFAULT ( int  mysql_errno)

◆ ER_DEFAULT_NONCONST()

const char * ER_DEFAULT_NONCONST ( int  mysql_errno)

◆ ER_THD()

const char * ER_THD ( const THD thd,
int  mysql_errno 
)

◆ ER_THD_NONCONST()

const char * ER_THD_NONCONST ( const THD thd,
int  mysql_errno 
)

◆ error_message_fetch()

static const char * error_message_fetch ( int  mysql_errno)
static

Get the error-message corresponding to the given MySQL error-code, or nullptr if no message is available for that code (this may indicate a bug in the caller).

If error messages have been loaded, return the appropriate message in the configured default language; otherwise, retrieve the message from the compiled-in set (in English).

Parameters
mysql_errnoMySQL error-code
Return values
anerror-message if available, or nullptr

◆ error_message_for_client()

const char * error_message_for_client ( int  mysql_errno)

Get the error-message corresponding to the given MySQL error-code, or nullptr if no message is available for that code (this may indicate a bug in the caller).

Use this variant for messages intended for sending to a client.

If the session language is known, the message will be returned in that language if available; otherwise, we will fall back on the configured default language if loaded, or finally on the built-in default, English.

Parameters
mysql_errnoMySQL error-code
Return values
anerror-message if available, or nullptr

◆ error_message_for_error_log()

const char * error_message_for_error_log ( int  mysql_errno)

Get the error-message corresponding to the given MySQL error-code, or nullptr if no message is available for that code (this may indicate a bug in the caller).

Use this variant for messages intended for the server's error-log.

If error messages have been loaded, return the appropriate message in the configured default language; otherwise, retrieve the message from the compiled-in set (in English).

Parameters
mysql_errnoMySQL error-code
Return values
anerror-message if available, or nullptr

◆ init_errmessage()

bool init_errmessage ( )

Read the error message file, initialize and register error messages for all languages.

Return values
trueif initialization failed, false otherwise.

◆ mysql_errno_to_builtin()

int mysql_errno_to_builtin ( uint  mysql_errno)

Find the error message record for a given MySQL error code in the array of registered messages.

The result is an index for said array; this value should not be considered stable between subsequent invocations of the server.

Parameters
mysql_errnothe error code to look for
Return values
-1no message registered for this error code
>=0index

Variable Documentation

◆ ERRMSG_FILE

const char* ERRMSG_FILE = "errmsg.sys"
static

◆ error_message_charset_info

CHARSET_INFO* error_message_charset_info

Character set of the buildin error messages loaded from errmsg.sys.