MySQL Internals Manual  /  ...  /  Adding an Error Message to Multiple MySQL Versions

27.1.1 Adding an Error Message to Multiple MySQL Versions

It is critical that error codes are identical in all versions. That is, the value of ER_SOME_ERROR must be the same in all versions for which it is defined. The following procedure follows from this requirement. (The discussion uses the name errmsg.txt, but when you cross the boundary from before MySQL 5.5 to 5.5 or higher, you should use errmsg-utf8.txt instead.)

Let GA reference the most recent stable version. For example, if MySQL 5.1 is GA, and MySQL 5.2 is -beta, then GA refers to MySQL 5.1.

To add a new error message in multiple versions, first add the specific error message to the GA version, at the end of errmsg.txt.

Next, add the specific error message to all versions > GA, at the same position in errmsg.txt, not at the end of the file. This will ensure that the error code value is the same in GA and all later versions. This will have the side effect that any error codes which are not in GA will change their values in post-GA versions. This is acceptable, in non-stable versions. We consider pre-RC versions non-stable in this context.

Finally, for any version < GA, do not add the specific error message. Instead, use the ER_UNKNOWN_ERROR error code, and print a helpful error text with code similar to this:

my_printf_error(ER_UNKNOWN_ERROR,
                 "Some error text here, with the '%-.64s' parameter value"
                 MYF(0), a_parameter);

This will provide the user with useful information, while ensuring that all versions have consistent error codes.

If you need to merge error messages up from 5.1 to 5.5, the merge operation will update the 5.5 errmsg.txt file with information that then needs to be added to the errmsg-utf8.txt file. To handle this, you can use the errmsg-cnv.sh script, which converts errmsg.txt to errmsg-utf8.txt. However, you must be careful not to wipe out the existing 5.5-specific information in errmsg-utf8.txt.

Suppose that you added a new error message into 5.1 and have merged this change into 5.5. You can do the following:

1. Make a backup of errmgs-utf8.txt:

cp errmsg-utf8.txt errmsg-utf8.txt.sav

2. Convert 5.1 messages:

sh errmsg-cnv.sh

Note: This will add 5.1 messages into errmsg-utf8.txt, but remove 5.5 messages.

3. Open errmsg-utf8.txt and errmsg-utf8.txt.sav in a text editor, then cut and paste 5.5-specific messages into errmsg-utf8.txt.

4. Make sure everything went fine:

git diff errmsg-utf8.txt


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.