5011
5010
session->thread_stack= (char*) &session;
5012
5011
session->store_globals();
5013
CachedDirectory dir(drizzle_tmpdir);
5017
my_errno= dir.getError();
5018
my_error(ER_CANT_READ_DIR, MYF(0), drizzle_tmpdir, my_errno);
5022
CachedDirectory::Entries files= dir.getEntries();
5023
CachedDirectory::Entries::iterator fileIter= files.begin();
5014
5025
/* Remove all temp tables in the tmpdir */
5015
/* See if the directory exists */
5016
if ((dirp = my_dir(drizzle_tmpdir ,MYF(MY_WME | MY_DONT_SORT))))
5026
while (fileIter != files.end())
5018
/* Remove all SQLxxx tables from directory */
5019
for (idx=0 ; idx < (uint32_t) dirp->number_off_files ; idx++)
5028
CachedDirectory::Entry *entry= *fileIter;
5029
string prefix= entry->filename.substr(0, TMP_FILE_PREFIX_LENGTH);
5031
if (prefix == TMP_FILE_PREFIX)
5021
file=dirp->dir_entry+idx;
5023
/* skiping . and .. */
5024
if (file->name[0] == '.' && (!file->name[1] ||
5025
(file->name[1] == '.' && !file->name[2])))
5028
if (!memcmp(file->name, TMP_FILE_PREFIX, TMP_FILE_PREFIX_LENGTH))
5033
char *ext= fn_ext(entry->filename.c_str());
5034
uint32_t ext_len= strlen(ext);
5035
uint32_t filePath_len= snprintf(filePath, sizeof(filePath),
5036
"%s%c%s", drizzle_tmpdir, FN_LIBCHAR,
5037
entry->filename.c_str());
5039
if (ext_len && !memcmp(".dfe", ext, ext_len))
5030
char *ext= fn_ext(file->name);
5031
uint32_t ext_len= strlen(ext);
5032
uint32_t filePath_len= snprintf(filePath, sizeof(filePath),
5033
"%s%c%s", drizzle_tmpdir, FN_LIBCHAR,
5035
if (!memcmp(".dfe", ext, ext_len))
5042
/* We should cut file extention before deleting of table */
5043
memcpy(filePathCopy, filePath, filePath_len - ext_len);
5044
filePathCopy[filePath_len - ext_len]= 0;
5045
share.init(NULL, filePathCopy);
5046
if (!open_table_def(session, &share))
5038
/* We should cut file extention before deleting of table */
5039
memcpy(filePathCopy, filePath, filePath_len - ext_len);
5040
filePathCopy[filePath_len - ext_len]= 0;
5041
share.init(NULL, filePathCopy);
5042
if (!open_table_def(session, &share))
5044
share.db_type()->deleteTable(session, filePathCopy);
5046
share.free_table_share();
5048
share.db_type()->deleteTable(session, filePathCopy);
5049
File can be already deleted by tmp_table.file->delete_table().
5050
So we hide error messages which happnes during deleting of these
5053
my_delete(filePath, MYF(0));
5050
share.free_table_share();
5053
File can be already deleted by tmp_table.file->delete_table().
5054
So we hide error messages which happnes during deleting of these
5057
my_delete(filePath, MYF(0));
5059
5063
delete session;