WL#8206: Introduce separate error code range for 5.7
Affects: Server-5.7 — Status: Complete — Priority: Medium
All error messages sent from the server to the client have separate error codes. The error code is available as the MYSQL_ERRNO item in the Condition Area. See: - http://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html - http://dev.mysql.com/doc/refman/5.7/en/diagnostics-area.html These codes are currently numbered consecutively, starting at 1000. We also have a second range of error codes used by the client, starting at 2000. The problem is that the first range of codes is currently up to 1974 which means that these two ranges will soon overlap. Which will make it hard to differentiate between server and client errors. This worklog is about implementing a separate range of numbers for new server error messages introduced in 5.7. The range will start at 3000. This avoids the problem of overlapping server and client error codes. Further, by introducing a separate range for 5.7, it will be possible to introduce new error codes in 5.6 even after 5.7 is GA as this can be done without interfering with codes already in use by 5.7. (We guarantee that a given error messages never changes its code). We should therefore also use separate ranges for each new GA version. Finally, it will make it possible to e.g. reserve code ranges for forks so that they can use codes without interfering with codes used by MySQL. User Documentation ================== http://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-6.html
Error messages are organized in sections. In each section, error messages are numbered consecutively. F-1: It should now be possible to have more than one section. Each new section is started by adding a "start-error-number xxxx" line in errmsg-utf8.txt. Messages below this line will start at number "xxxx". NF-1: errmsg.sys format should not change. This means that older versions (e.g. 5.5 clients) will still be able to read the 5.7 version of the file.
No other user observable changes except for that new 5.7 error messages will have a separate number range and thus not be consecutively numbered with existing error messages.
- Encapsulate MY_LOCALE_ERRMSGS members and move them to derror.h/derror.cc Especially the errmsgs strings array should be private so that the mapping of number to string can be controlled. - Change the signature of my_error_register() from extern int my_error_register(const char** (*get_errmsgs) (), ... to extern int my_error_register(const char* (*get_errmsg) (int), ... so that the function provided is responsible from mapping from number to string. - Keep error messages packed in a single array, but modify the lookup in the array from (nr - 1000) to (nr - section_start + size_of_earlier_sections). Example: Sections start at 1000 and 3000. Section 1 has 886 messages. Error nr 3567 => (3567 - 3000 + 886) = array index 1453. - Remove ER_ERROR_FIRST and ER_ERROR_LAST #define's from mysqld_error.h Replace them with static const int errmsg_section_start static const int errmsg_section_length arrays containing the start nr and length of each section.
Copyright (c) 2000, 2018, Oracle Corporation and/or its affiliates. All rights reserved.