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

Function read_texts

sql/derror.cc:100–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98*/
99
100bool read_texts(const char *file_name, const char *language,
101 const char ***point, uint error_messages)
102{
103 register uint i;
104 uint count,funktpos,textcount;
105 size_t length;
106 File file;
107 char name[FN_REFLEN];
108 char lang_path[FN_REFLEN];
109 uchar *buff;
110 uchar head[32],*pos;
111 DBUG_ENTER("read_texts");
112
113 LINT_INIT(buff);
114 funktpos=0;
115 convert_dirname(lang_path, language, NullS);
116 (void) my_load_path(lang_path, lang_path, lc_messages_dir);
117 if ((file= mysql_file_open(key_file_ERRMSG,
118 fn_format(name, file_name, lang_path, "", 4),
119 O_RDONLY | O_SHARE | O_BINARY,
120 MYF(0))) < 0)
121 {
122 /*
123 Trying pre-5.4 sematics of the --language parameter.
124 It included the language-specific part, e.g.:
125
126 --language=/path/to/english/
127 */
128 if ((file= mysql_file_open(key_file_ERRMSG,
129 fn_format(name, file_name, lc_messages_dir, "", 4),
130 O_RDONLY | O_SHARE | O_BINARY,
131 MYF(0))) < 0)
132 goto err;
133
134 sql_print_warning("Using pre 5.5 semantics to load error messages from %s.",
135 lc_messages_dir);
136
137 sql_print_warning("If this is not intended, refer to the documentation for "
138 "valid usage of --lc-messages-dir and --language "
139 "parameters.");
140 }
141
142 funktpos=1;
143 if (mysql_file_read(file, (uchar*) head, 32, MYF(MY_NABP)))
144 goto err;
145 if (head[0] != (uchar) 254 || head[1] != (uchar) 254 ||
146 head[2] != 3 || head[3] != 1)
147 goto err; /* purecov: inspected */
148 textcount=head[4];
149
150 error_message_charset_info= system_charset_info;
151 length=uint4korr(head+6); count=uint4korr(head+10);
152
153 if (count < error_messages)
154 {
155 sql_print_error("\
156Error message file '%s' had only %d error messages,\n\
157but it should contain at least %d error messages.\n\

Callers 2

check_localeFunction · 0.85
init_errmessageFunction · 0.85

Calls 7

convert_dirnameFunction · 0.85
my_load_pathFunction · 0.85
fn_formatFunction · 0.85
sql_print_warningFunction · 0.85
sql_print_errorFunction · 0.85
my_freeFunction · 0.85
my_mallocFunction · 0.85

Tested by

no test coverage detected