594
class DeleteTableStorageEngine
595
: public unary_function<plugin::StorageEngine *, void>
602
DeleteTableStorageEngine(Session *session_arg, const char *path_arg,
603
Cursor **file_arg, int *error_arg)
604
: session(session_arg), path(path_arg), file(file_arg), dt_error(error_arg) {}
606
result_type operator() (argument_type engine)
608
char tmp_path[FN_REFLEN];
611
if(*dt_error!=ENOENT) /* already deleted table */
617
if (!engine->is_enabled())
620
if ((tmp_file= engine->create(NULL, session->mem_root)))
625
path= engine->checkLowercaseNames(path, tmp_path);
626
const string table_path(path);
627
int tmp_error= engine->doDeleteTable(session, table_path);
629
if (tmp_error != ENOENT)
633
if (engine->check_flag(HTON_BIT_HAS_DATA_DICTIONARY))
634
delete_table_proto_file(path);
636
tmp_error= delete_table_proto_file(path);
639
*dt_error= tmp_error;
654
595
This should return ENOENT if the file doesn't exists.
655
596
The .frm file will be deleted only if we return 0 or ENOENT
658
599
const char *db, const char *alias,
659
600
bool generate_warning)
661
TableShare dummy_share;
663
memset(&dummy_table, 0, sizeof(dummy_table));
664
memset(&dummy_share, 0, sizeof(dummy_share));
666
dummy_table.s= &dummy_share;
671
for_each(all_engines.begin(), all_engines.end(),
672
DeleteTableStorageEngine(session, path, &file, &error));
674
if (error == ENOENT) /* proto may be left behind */
675
error= delete_table_proto_file(path);
604
message::Table src_proto;
605
plugin::StorageEngine* engine;
607
error_proto= plugin::StorageEngine::getTableProto(path, &src_proto);
609
engine= plugin::StorageEngine::findByName(session,
610
src_proto.engine().name());
613
error= engine->doDeleteTable(session, path);
619
if (engine && engine->check_flag(HTON_BIT_HAS_DATA_DICTIONARY))
620
delete_table_proto_file(path);
622
error= delete_table_proto_file(path);
626
if (error_proto && error == 0)
677
629
if (error && generate_warning)
631
TableShare dummy_share;
637
if ((file= engine->create(NULL, session->mem_root)))
640
memset(&dummy_table, 0, sizeof(dummy_table));
641
memset(&dummy_share, 0, sizeof(dummy_share));
642
dummy_table.s= &dummy_share;
680
645
Because file->print_error() use my_error() to generate the error message
681
646
we use an internal error Cursor to intercept it and store the text