10bet网址
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr)- 36.3Mb
PDF (A4)- 36.3Mb
Man Pages (TGZ)- 235.6Kb
Man Pages (Zip)- 347.2Kb
Info (Gzip)- 3.3Mb
Info (Zip)- 3.3Mb
Excerpts from this Manual

10.6 Error Message Character Set

This section describes how the MySQL server uses character sets for constructing error messages. For information about the language of error messages (rather than the character set), seeSection 10.12, “Setting the Error Message Language”. For general information about configuring error logging, seeSection 5.4.2, “The Error Log”.

Character Set for Error Message Construction

The server constructs error messages as follows:

  • The message template uses UTF-8 (utf8mb3).

  • Parameters in the message template are replaced with values that apply to a specific error occurrence:

    • Identifiers such as table or column names use UTF-8 internally so they are copied as is.

    • Character (nonbinary) string values are converted from their character set to UTF-8.

    • Binary string values are copied as is for bytes in the range0x20to0x7E, and using\xhexadecimal encoding for bytes outside that range. For example, if a duplicate-key error occurs for an attempt to insert0x41CF9Finto aVARBINARYunique column, the resulting error message uses UTF-8 with some bytes hexadecimal encoded:

      Duplicate entry 'A\xCF\x9F' for key 1

Character Set for Error Message Disposition

An error message, once constructed, can be written by the server to the error log or sent to clients:

  • If the server writes the error message to the error log, it writes it in UTF-8, as constructed, without conversion to another character set.

  • If the server sends the error message to a client program, the server converts it from UTF-8 to the character set specified by thecharacter_set_resultssystem variable. Ifcharacter_set_resultshas a value ofNULLorbinary, no conversion occurs. No conversion occurs if the variable value isutf8mb3orutf8mb4, either, because those character sets have a repertoire that includes all UTF-8 characters used in message construction.

    If characters cannot be represented incharacter_set_results, some encoding may occur during the conversion. The encoding uses Unicode code point values:

    • Characters in the Basic Multilingual Plane (BMP) range (0x0000to0xFFFF) are written using\nnnnnotation.

    • Characters outside the BMP range (0x10000to0x10FFFF) are written using\+nnnnnnnotation.

    Clients can setcharacter_set_results控制他们接受的字符集error messages. The variable can be set directly, or indirectly by means such asSET NAMES. For more information aboutcharacter_set_results, seeSection 10.4, “Connection Character Sets and Collations”.