Server Error Codes and Messages
2910
• An SQLSTATE value. The value is a five-character string (for example,
'42S02'
). The values are
taken from ANSI SQL and ODBC and are more standardized.
A message string that provides a textual description of the error is also available.
When an error occurs, the MySQL error code, SQLSTATE value, and message string are available
using C API functions:
• MySQL error code: Call
mysql_errno()
• SQLSTATE value: Call
mysql_sqlstate()
• Error message: Call
mysql_error()
For prepared statements, the corresponding error functions are
mysql_stmt_errno()
,
mysql_stmt_sqlstate()
, and
mysql_stmt_error()
. All error functions are described in
Section 20.6, “MySQL C API”
.
The number of errors, warnings, and notes for the previous statement can be obtained by calling
mysql_warning_count()
. See
Section 20.6.6.72, “
mysql_warning_count()
”
.
The first two characters of an SQLSTATE value indicate the error class:
• Class =
'00'
indicates success.
• Class =
'01'
indicates a warning.
• Class =
'02'
indicates “not found.” This is relevant within the context of cursors and is used to
control what happens when a cursor reaches the end of a data set. This condition also occurs for
SELECT ... INTO var_list
statements that retrieve no rows.
• Class >
'02'
indicates an exception.
C.3. Server Error Codes and Messages
MySQL programs have access to several types of error information when the server returns an error.
For example, the
mysql
client program displays errors using the following format:
shell>
SELECT * FROM no_such_table;
ERROR 1146 (42S02): Table 'test.no_such_table' doesn't exist
The message displayed contains three types of information:
• A numeric error code (
1146
). This number is MySQL-specific and is not portable to other database
systems.
• A five-character SQLSTATE value (
'42S02'
). The values are taken from ANSI SQL and ODBC and
are more standardized. Not all MySQL error numbers have corresponding SQLSTATE values. In
these cases,
'HY000'
(general error) is used.
• A message string that provides a textual description of the error.
For error checking, use error codes, not error messages. Error messages do not change often, but it is
possible. Also if the database administrator changes the language setting, that affects the language of
error messages.
Error codes are stable across GA releases of a given MySQL series. Before a series reaches GA
status, new codes may still be under development and subject to change.
Server error information comes from the following source files. For details about the way that error
information is defined, see the
MySQL Internals Manual
.
• Error message information is listed in the
share/errmsg.txt
file.
%d
and
%s
represent numbers
and strings, respectively, that are substituted into the Message values when they are displayed.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...