The procedure for adding error messages depends on which version of MySQL you are using:
For all versions, the comp_err program compiles the text error message file or files into language-specific errmsg.sys files that each are located in the appropriate language directory under sql/share. In MySQL 5.0.3 and up, comp_err also generates a number of header files in the include directory. The MySQL build process runs comp_err automatically.
Note: You should observe some general considerations regarding error messages that apply no matter your version of MySQL:
For versions of MySQL older than 5.0.3, use the following procedure to add new error messages:
For MySQL 5.0.3 and up, the procedure for adding error messages is less tedious. You need edit only a single message text file, and it's not necessary to edit *.h header files. Instead, comp_err generates the header files for you based on the contents of the message text file.
The errmsg.txt file begins with some lines that define general characteristics of error messages, followed by sections for particular messages. The following example shows a partial listing of an errmsg. txt file. (The languages line is wrapped here; it must be given all on one line.)
languages czech=cze latin2, danish=dan latin1, dutch=nla latin1, english=eng latin1, estonian=est latin7, french=fre latin1, german=ger latin1, greek=greek greek, hungarian=hun latin2, italian=ita latin1, japanese=jpn ujis, japanese-sjis=jps sjis, korean=kor euckr, norwegian-ny=norwegian-ny latin1, norwegian=nor latin1, polish=pol latin2, portuguese=por latin1, romanian=rum latin2, russian=rus koi8r, serbian=serbian cp1250, slovak=slo latin2, spanish=spa latin1, swedish=swe latin1, ukrainian=ukr koi8u;
Indentation is significant. Unless otherwise specified, leading whitespace should not be used.
The “grammar” of the errmsg.txt file looks like this:
The languages line lists the languages for which language-specific errmsg.sys files should be generated. A language specification langspec in the languages line has this syntax: langspec: langname=langcode langcharset
langname is the long language name, langcode is the short language code, and langcharset is the character set to use for error messages in the language.
The default-language line specifies the short language code for the default language. (If there is no translation into a given language for a given error message, the message from the default language will be used.)
The start-error-number line indicates the number to be assigned to the first error message. Messages that follow the first one are numbered consecutively from this value.
Each error-message-section begins with a line that lists an error (or warning) symbol, optionally followed by one or two SQLSTATE values. The error symbol must begin with ER_ for an error or WARN_ for a warning. Lines following the error symbol line provide language-specific error messages that correspond to the error symbol. Each message line consists of a tab, a short language code, a space, and the text of the error message within double quote ('"') characters. Presumably, there must be a message in the default language. There may be message translations for other languages. Order of message lines within a section does not matter. If no translation is given for a given language, the default language message will be used. The following example defines several language translations for the
In the preceding example, two SQLSTATE values are given following the error symbol (42S22,S0022). Internally (in sql/sql_state.c), these are known as odbc_state and jdbc_state.Currently, only the first appears ever to be used.
Message strings for a given language must be written in the character set indicated for that language in the languages line. For example, the language information for Japanese in that line is japanese= jpn ujis, so messages with a language code of jpn must be written in the ujis character set. You might need to be careful about the editor you use for editing the errmsg.txt file. For example, there is a report that using Emacs will mangle the file, whereas vi will not.
Within a message string, C-style escape sequences are allowed:
A line beginning with a '#' character is taken as a comment. Comments and blank lines are ignored.
Use the following procedure to add new error messages:
comp_err will generate the errmsg.sys files, as well as the header files mysqld_error.h, mysqld_ername.h, and sql_state.h in the include directory.
Be aware that if you make a mistake editing a message text file, comp_err prints a cryptic error message and gives you no other feedback. For example, it does not print the input line number where it found a problem. It's up to you to figure this out and correct the file. Perhaps that is not a serious difficulty: errmsg.txt tends to grow by gradual accretion, so if an error occurs when comp_err processes it, the problem is likely due to whatever change you just made.
MySQL Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
A Guided Tour Of The Mysql Source Code
Important Algorithms And Structures
How Mysql Performs Different Selects
How Mysql Transforms Subqueries
Mysql Client/server Protocol
Prepared Statements And Stored Routines
Myisam Storage Engine
Innodb Storage Engine
Writing A Custom Storage Engine
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.