| 3380 | */ |
| 3381 | |
| 3382 | static bool auto_repair_table(THD *thd, TABLE_LIST *table_list) |
| 3383 | { |
| 3384 | TABLE_SHARE *share; |
| 3385 | TABLE entry; |
| 3386 | bool result= TRUE; |
| 3387 | |
| 3388 | thd->clear_error(); |
| 3389 | |
| 3390 | if (!(share= tdc_acquire_share(thd, table_list, GTS_TABLE))) |
| 3391 | return result; |
| 3392 | |
| 3393 | DBUG_ASSERT(! share->is_view); |
| 3394 | |
| 3395 | if (open_table_from_share(thd, share, &table_list->alias, |
| 3396 | HA_OPEN_KEYFILE | HA_TRY_READ_ONLY, |
| 3397 | EXTRA_RECORD, |
| 3398 | ha_open_options | HA_OPEN_FOR_REPAIR, |
| 3399 | &entry, FALSE) || ! entry.file || |
| 3400 | (entry.file->is_crashed() && entry.file->ha_check_and_repair(thd))) |
| 3401 | { |
| 3402 | /* Give right error message */ |
| 3403 | thd->clear_error(); |
| 3404 | my_error(ER_NOT_KEYFILE, MYF(0), share->table_name.str); |
| 3405 | sql_print_error("Couldn't repair table: %s.%s", share->db.str, |
| 3406 | share->table_name.str); |
| 3407 | if (entry.file) |
| 3408 | closefrm(&entry); |
| 3409 | } |
| 3410 | else |
| 3411 | { |
| 3412 | thd->clear_error(); // Clear error message |
| 3413 | closefrm(&entry); |
| 3414 | result= FALSE; |
| 3415 | } |
| 3416 | |
| 3417 | tdc_remove_referenced_share(thd, share); |
| 3418 | return result; |
| 3419 | } |
| 3420 | |
| 3421 | |
| 3422 | /** Open_table_context */ |
no test coverage detected