27 #include "mysys_err.h"
30 #include "sql_class.h"
32 static void init_myfunc_errs(
void);
36 static const char **get_server_errmsgs()
39 return DEFAULT_ERRMSGS;
40 return CURRENT_THD_ERRMSGS;
60 const char **errmsgs, **ptr;
61 DBUG_ENTER(
"init_errmessage");
67 errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
70 if (
read_texts(ERRMSG_FILE, my_default_lc_messages->errmsgs->language,
71 &errmsgs, ER_ERROR_LAST - ER_ERROR_FIRST + 1) &&
74 if (!(errmsgs= (
const char**) my_malloc((ER_ERROR_LAST-ER_ERROR_FIRST+1)*
75 sizeof(
char*), MYF(0))))
77 for (ptr= errmsgs; ptr < errmsgs + ER_ERROR_LAST - ER_ERROR_FIRST; ptr++)
82 if (my_error_register(get_server_errmsgs, ER_ERROR_FIRST, ER_ERROR_LAST))
88 DEFAULT_ERRMSGS= errmsgs;
101 const char ***point, uint error_messages)
104 uint count,funktpos,textcount;
107 char name[FN_REFLEN];
108 char lang_path[FN_REFLEN];
111 DBUG_ENTER(
"read_texts");
115 convert_dirname(lang_path, language, NullS);
116 (void) my_load_path(lang_path, lang_path, lc_messages_dir);
118 fn_format(name, file_name, lang_path,
"", 4),
119 O_RDONLY | O_SHARE | O_BINARY,
129 fn_format(name, file_name, lc_messages_dir,
"", 4),
130 O_RDONLY | O_SHARE | O_BINARY,
134 sql_print_warning(
"Using pre 5.5 semantics to load error messages from %s.",
137 sql_print_warning(
"If this is not intended, refer to the documentation for "
138 "valid usage of --lc-messages-dir and --language "
145 if (head[0] != (uchar) 254 || head[1] != (uchar) 254 ||
146 head[2] != 3 || head[3] != 1)
150 error_message_charset_info= system_charset_info;
151 length=uint4korr(head+6); count=uint4korr(head+10);
153 if (count < error_messages)
156 Error message file '%s' had only %d error messages,\n\
157 but it should contain at least %d error messages.\n\
158 Check that the above file is the right version for this program!",
159 name,count,error_messages);
166 if (!(*point= (
const char**)
167 my_malloc((
size_t) (length+count*
sizeof(
char*)),MYF(0))))
172 buff= (uchar*) (*point + count);
176 for (i=0, pos= buff ; i< count ; i++)
178 (*point)[
i]= (
char*) buff+uint4korr(pos);
184 for (i=1 ; i < textcount ; i++)
186 point[
i]= *point +uint2korr(head+10+i+i);
192 sql_print_error((funktpos == 2) ?
"Not enough memory for messagefile '%s'" :
193 ((funktpos == 1) ?
"Can't read from messagefile '%s'" :
194 "Can't find messagefile '%s'"), name);
205 static void init_myfunc_errs()
208 if (!(specialflag & SPECIAL_ENGLISH))
210 EE(EE_FILENOTFOUND) = ER(ER_FILE_NOT_FOUND);
211 EE(EE_CANTCREATEFILE) = ER(ER_CANT_CREATE_FILE);
212 EE(EE_READ) = ER(ER_ERROR_ON_READ);
213 EE(EE_WRITE) = ER(ER_ERROR_ON_WRITE);
214 EE(EE_BADCLOSE) = ER(ER_ERROR_ON_CLOSE);
215 EE(EE_OUTOFMEMORY) = ER(ER_OUTOFMEMORY);
216 EE(EE_DELETE) = ER(ER_CANT_DELETE_FILE);
217 EE(EE_LINK) = ER(ER_ERROR_ON_RENAME);
218 EE(EE_EOFERR) = ER(ER_UNEXPECTED_EOF);
219 EE(EE_CANTLOCK) = ER(ER_CANT_LOCK);
220 EE(EE_DIR) = ER(ER_CANT_READ_DIR);
221 EE(EE_STAT) = ER(ER_CANT_GET_STAT);
222 EE(EE_GETWD) = ER(ER_CANT_GET_WD);
223 EE(EE_SETWD) = ER(ER_CANT_SET_WD);
224 EE(EE_DISK_FULL) = ER(ER_DISK_FULL);