| 358 | */ |
| 359 | |
| 360 | uint filename_to_tablename(const char *from, char *to, uint to_length |
| 361 | #ifndef DBUG_OFF |
| 362 | , bool stay_quiet |
| 363 | #endif /* DBUG_OFF */ |
| 364 | ) |
| 365 | { |
| 366 | uint errors; |
| 367 | size_t res; |
| 368 | DBUG_ENTER("filename_to_tablename"); |
| 369 | DBUG_PRINT("enter", ("from '%s'", from)); |
| 370 | |
| 371 | if (strlen(from) >= tmp_file_prefix_length && |
| 372 | !memcmp(from, tmp_file_prefix, tmp_file_prefix_length)) |
| 373 | { |
| 374 | /* Temporary table name. */ |
| 375 | res= (strnmov(to, from, to_length) - to); |
| 376 | } |
| 377 | else |
| 378 | { |
| 379 | res= strconvert(&my_charset_filename, from, |
| 380 | system_charset_info, to, to_length, &errors); |
| 381 | if (errors) // Old 5.0 name |
| 382 | { |
| 383 | res= (strxnmov(to, to_length, MYSQL50_TABLE_NAME_PREFIX, from, NullS) - |
| 384 | to); |
| 385 | #ifndef DBUG_OFF |
| 386 | if (!stay_quiet) { |
| 387 | #endif /* DBUG_OFF */ |
| 388 | sql_print_error("Invalid (old?) table or database name '%s'", from); |
| 389 | #ifndef DBUG_OFF |
| 390 | } |
| 391 | #endif /* DBUG_OFF */ |
| 392 | /* |
| 393 | TODO: add a stored procedure for fix table and database names, |
| 394 | and mention its name in error log. |
| 395 | */ |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | DBUG_PRINT("exit", ("to '%s'", to)); |
| 400 | DBUG_RETURN(res); |
| 401 | } |
| 402 | |
| 403 | |
| 404 | /** |
nothing calls this directly
no test coverage detected