| 40 | return CURRENT_THD_ERRMSGS; |
| 41 | } |
| 42 | C_MODE_END |
| 43 | |
| 44 | /** |
| 45 | Read messages from errorfile. |
| 46 | |
| 47 | This function can be called multiple times to reload the messages. |
| 48 | If it fails to load the messages, it will fail softly by initializing |
| 49 | the errmesg pointer to an array of empty strings or by keeping the |
| 50 | old array if it exists. |
| 51 | |
| 52 | @retval |
| 53 | FALSE OK |
| 54 | @retval |
| 55 | TRUE Error |
| 56 | */ |
| 57 | |
| 58 | bool init_errmessage(void) |
| 59 | { |
| 60 | const char **errmsgs, **ptr; |
| 61 | DBUG_ENTER("init_errmessage"); |
| 62 | |
| 63 | /* |
| 64 | Get a pointer to the old error messages pointer array. |
| 65 | read_texts() tries to free it. |
| 66 | */ |
| 67 | errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); |
| 68 | |
| 69 | /* Read messages from file. */ |
| 70 | if (read_texts(ERRMSG_FILE, my_default_lc_messages->errmsgs->language, |
| 71 | &errmsgs, ER_ERROR_LAST - ER_ERROR_FIRST + 1) && |
| 72 | !errmsgs) |
| 73 | { |
| 74 | if (!(errmsgs= (const char**) my_malloc((ER_ERROR_LAST-ER_ERROR_FIRST+1)* |
| 75 | sizeof(char*), MYF(0)))) |
| 76 | DBUG_RETURN(TRUE); |
| 77 | for (ptr= errmsgs; ptr < errmsgs + ER_ERROR_LAST - ER_ERROR_FIRST; ptr++) |
| 78 | *ptr= ""; |
| 79 | } |
| 80 | |
| 81 | /* Register messages for use with my_error(). */ |
| 82 | if (my_error_register(get_server_errmsgs, ER_ERROR_FIRST, ER_ERROR_LAST)) |
| 83 | { |
| 84 | my_free(errmsgs); |
| 85 | DBUG_RETURN(TRUE); |
| 86 | } |
| 87 | |
| 88 | DEFAULT_ERRMSGS= errmsgs; /* Init global variable */ |
| 89 | init_myfunc_errs(); /* Init myfunc messages */ |
| 90 | DBUG_RETURN(FALSE); |
| 91 | } |
| 92 | |
| 93 | |
| 94 | /** |
no test coverage detected