MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / init_errmessage

Function init_errmessage

sql/derror.cc:42–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40 return CURRENT_THD_ERRMSGS;
41}
42C_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
58bool 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/**

Callers 1

init_common_variablesFunction · 0.85

Calls 6

my_error_unregisterFunction · 0.85
read_textsFunction · 0.85
my_mallocFunction · 0.85
my_error_registerFunction · 0.85
my_freeFunction · 0.85
init_myfunc_errsFunction · 0.85

Tested by

no test coverage detected