490
490
static long mysql_rm_known_files(Session *session,
491
491
const string &db,
492
492
const char *org_path,
493
set<string> &dropped_tables)
493
plugin::TableNameList &dropped_tables)
495
495
CachedDirectory dirp(org_path);
500
char filePath[FN_REFLEN];
501
500
TableList *tot_list= NULL, **tot_list_next;
503
502
tot_list_next= &tot_list;
505
504
plugin::StorageEngine::getTableNames(db, dropped_tables);
507
for (CachedDirectory::Entries::const_iterator iter= dirp.getEntries().begin();
508
iter != dirp.getEntries().end() && !session->killed;
506
for (plugin::TableNameList::iterator it= dropped_tables.begin();
507
it != dropped_tables.end();
511
string filename((*iter)->filename);
513
/* skiping . and .. */
514
if (filename[0] == '.' && (!filename[1] ||
515
(filename[1] == '.' && !filename[2])))
518
string extension("");
519
size_t ext_pos= filename.rfind('.');
520
if (ext_pos != string::npos)
522
extension= filename.substr(ext_pos);
524
if (deletable_extentions.find(extension) == deletable_extentions.end())
529
strange checking for magic extensions that are then deleted if
530
not reg_ext (i.e. .frm).
532
and (previously) we'd err out on drop database if files not matching
533
engine ha_known_exts() or deletable_extensions were present.
535
presumably this was to avoid deleting other user data... except if that
536
data happened to be in files ending in .BAK, .opt or .TMD. *fun*
540
/* just for safety we use files_charset_info */
541
if (!my_strcasecmp(files_charset_info, extension.c_str(), ".dfe"))
543
size_t db_len= db.size();
545
/* Drop the table nicely */
546
filename.erase(ext_pos);
547
TableList *table_list=(TableList*)
548
session->calloc(sizeof(*table_list) +
550
filename.size() + 1);
554
table_list->db= (char*) (table_list+1);
555
table_list->table_name= strcpy(table_list->db, db.c_str()) + db_len + 1;
556
filename_to_tablename(filename.c_str(), table_list->table_name,
557
filename.size() + 1);
558
table_list->alias= table_list->table_name; // If lower_case_table_names=2
559
table_list->internal_tmp_table= (strncmp(filename.c_str(),
561
strlen(TMP_FILE_PREFIX)) == 0);
563
(*tot_list_next)= table_list;
564
tot_list_next= &table_list->next_local;
569
sprintf(filePath, "%s/%s", org_path, filename.c_str());
570
if (internal::my_delete_with_symlink(filePath,MYF(MY_WME)))
510
size_t db_len= db.size();
512
/* Drop the table nicely */
513
TableList *table_list=(TableList*)
514
session->calloc(sizeof(*table_list) +
521
table_list->db= (char*) (table_list+1);
522
table_list->table_name= strcpy(table_list->db, db.c_str()) + db_len + 1;
523
filename_to_tablename((*it).c_str(), table_list->table_name,
525
table_list->alias= table_list->table_name; // If lower_case_table_names=2
526
table_list->internal_tmp_table= (strncmp((*it).c_str(),
528
strlen(TMP_FILE_PREFIX)) == 0);
530
(*tot_list_next)= table_list;
531
tot_list_next= &table_list->next_local;
576
534
if (session->killed)