| 3582 | */ |
| 3583 | |
| 3584 | int ha_delete_table(THD *thd, handlerton *hton, const char *path, |
| 3585 | const LEX_CSTRING *db, const LEX_CSTRING *alias, |
| 3586 | bool generate_warning) |
| 3587 | { |
| 3588 | int error; |
| 3589 | bool is_error= thd->is_error(); |
| 3590 | DBUG_ENTER("ha_delete_table"); |
| 3591 | |
| 3592 | /* hton is NULL in ALTER TABLE when renaming only .frm files */ |
| 3593 | if (hton == NULL || hton == view_pseudo_hton) |
| 3594 | DBUG_RETURN(0); |
| 3595 | |
| 3596 | if (ha_check_if_updates_are_ignored(thd, hton, "DROP")) |
| 3597 | DBUG_RETURN(0); |
| 3598 | |
| 3599 | error= hton->drop_table(hton, path); |
| 3600 | if (error > 0) |
| 3601 | { |
| 3602 | /* |
| 3603 | It's not an error if the table doesn't exist in the engine. |
| 3604 | warn the user, but still report DROP being a success |
| 3605 | */ |
| 3606 | bool intercept= non_existing_table_error(error); |
| 3607 | |
| 3608 | if ((!intercept || generate_warning) && ! thd->is_error()) |
| 3609 | { |
| 3610 | TABLE dummy_table; |
| 3611 | TABLE_SHARE dummy_share; |
| 3612 | handler *file= get_new_handler(nullptr, thd->mem_root, hton); |
| 3613 | if (file) { |
| 3614 | bzero((char*) &dummy_table, sizeof(dummy_table)); |
| 3615 | bzero((char*) &dummy_share, sizeof(dummy_share)); |
| 3616 | dummy_share.path.str= (char*) path; |
| 3617 | dummy_share.path.length= strlen(path); |
| 3618 | dummy_share.normalized_path= dummy_share.path; |
| 3619 | dummy_share.db= Lex_ident_db(*db); |
| 3620 | dummy_share.table_name= Lex_ident_table(*alias); |
| 3621 | dummy_table.s= &dummy_share; |
| 3622 | dummy_table.alias.set(alias->str, alias->length, table_alias_charset); |
| 3623 | file->change_table_ptr(&dummy_table, &dummy_share); |
| 3624 | file->print_error(error, MYF(intercept ? ME_WARNING : 0)); |
| 3625 | delete file; |
| 3626 | } |
| 3627 | } |
| 3628 | if (intercept) |
| 3629 | { |
| 3630 | /* Clear error if we got it in this function */ |
| 3631 | if (!is_error) |
| 3632 | thd->clear_error(); |
| 3633 | error= -1; |
| 3634 | } |
| 3635 | } |
| 3636 | if (error) |
| 3637 | DBUG_PRINT("exit", ("error: %d", error)); |
| 3638 | DBUG_RETURN(error); |
| 3639 | } |
| 3640 | |
| 3641 | /**************************************************************************** |
no test coverage detected