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

Function main

extra/perror.c:244–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242}
243
244int main(int argc,char *argv[])
245{
246 int error,code,found;
247 const char *msg;
248 const char *name;
249 char *unknown_error = 0;
250#if defined(__WIN__)
251 my_bool skip_win_message= 0;
252#endif
253 MY_INIT(argv[0]);
254
255 if (get_options(&argc,&argv))
256 exit(1);
257
258 my_handler_error_register();
259
260 error=0;
261 {
262 /*
263 On some system, like Linux, strerror(unknown_error) returns a
264 string 'Unknown Error'. To avoid printing it we try to find the
265 error string by asking for an impossible big error message.
266
267 On Solaris 2.8 it might return NULL
268 */
269 if ((msg= strerror(10000)) == NULL)
270 msg= "Unknown Error";
271
272 /*
273 Allocate a buffer for unknown_error since strerror always returns
274 the same pointer on some platforms such as Windows
275 */
276 unknown_error= malloc(strlen(msg)+1);
277 strmov(unknown_error, msg);
278
279 for ( ; argc-- > 0 ; argv++)
280 {
281
282 found=0;
283 code=atoi(*argv);
284#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
285 if (ndb_code)
286 {
287 if ((ndb_error_string(code, ndb_string, sizeof(ndb_string)) < 0) &&
288 (ndbd_exit_string(code, ndb_string, sizeof(ndb_string)) < 0) &&
289 (mgmapi_error_string(code, ndb_string, sizeof(ndb_string)) < 0))
290 {
291 msg= 0;
292 }
293 else
294 msg= ndb_string;
295 if (msg)
296 {
297 if (verbose)
298 printf("NDB error code %3d: %s\n",code,msg);
299 else
300 puts(msg);
301 }

Callers

nothing calls this directly

Calls 8

strmovFunction · 0.85
atoiFunction · 0.85
mgmapi_error_stringFunction · 0.85
get_ha_error_msgFunction · 0.85
get_ER_error_msgFunction · 0.85
print_win_error_msgFunction · 0.85
get_optionsFunction · 0.70

Tested by

no test coverage detected