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 nameerrmsg.txt, but when you cross the boundary from before MySQL 5.5 to 5.5 or higher, you should useerrmsg-utf8.txtinstead.)

LetGAreference the most recent stable version. For example, if MySQL 5.1 is GA, and MySQL 5.2 is -beta, thenGArefers to MySQL 5.1.

来add a new error message in multiple versions, first add the specific error message to theGAversion, at the end oferrmsg.txt.

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

Finally, for any version <GA,do not addthe specific error message. Instead, use theER_UNKNOWN_ERRORerror 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.5errmsg.txtfile with information that then needs to be added to theerrmsg-utf8.txtfile. To handle this, you can use theerrmsg-cnv.shscript, which convertserrmsg.txttoerrmsg-utf8.txt. However, you must be careful not to wipe out the existing 5.5-specific information inerrmsg-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 oferrmgs-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 intoerrmsg-utf8.txt, but remove 5.5 messages.

3. Openerrmsg-utf8.txtanderrmsg-utf8.txt.savin a text editor, then cut and paste 5.5-specific messages intoerrmsg-utf8.txt.

4. Make sure everything went fine:

git diff errmsg-utf8.txt