5008
5008
session->thread_stack= (char*) &session;
5009
5009
session->store_globals();
5011
if ((dirp= opendir(drizzle_tmpdir)) == NULL)
5014
my_error(ER_CANT_READ_DIR, MYF(0), drizzle_tmpdir, my_errno);
5019
/* Remove all SQLxxx tables from directory */
5020
while (!readdir_r(dirp, &d_entry, &d_result) && (d_result != NULL))
5022
if (!memcmp(d_entry.d_name, TMP_FILE_PREFIX, TMP_FILE_PREFIX_LENGTH))
5011
/* Remove all temp tables in the tmpdir */
5012
/* See if the directory exists */
5013
if ((dirp = my_dir(drizzle_tmpdir ,MYF(MY_WME | MY_DONT_SORT))))
5015
/* Remove all SQLxxx tables from directory */
5016
for (idx=0 ; idx < (uint32_t) dirp->number_off_files ; idx++)
5024
char *ext= fn_ext(d_entry.d_name);
5025
uint32_t ext_len= strlen(ext);
5026
uint32_t filePath_len= snprintf(filePath, sizeof(filePath),
5027
"%s%c%s", drizzle_tmpdir, FN_LIBCHAR,
5030
if (ext_len && !memcmp(".dfe", ext, ext_len))
5018
file=dirp->dir_entry+idx;
5020
/* skiping . and .. */
5021
if (file->name[0] == '.' && (!file->name[1] ||
5022
(file->name[1] == '.' && !file->name[2])))
5025
if (!memcmp(file->name, TMP_FILE_PREFIX, TMP_FILE_PREFIX_LENGTH))
5033
/* We should cut file extention before deleting of table */
5034
memcpy(filePathCopy, filePath, filePath_len - ext_len);
5035
filePathCopy[filePath_len - ext_len]= 0;
5036
share.init(NULL, filePathCopy);
5037
if (!open_table_def(session, &share))
5027
char *ext= fn_ext(file->name);
5028
uint32_t ext_len= strlen(ext);
5029
uint32_t filePath_len= snprintf(filePath, sizeof(filePath),
5030
"%s%c%s", drizzle_tmpdir, FN_LIBCHAR,
5032
if (!memcmp(".dfe", ext, ext_len))
5039
share.db_type()->deleteTable(session, filePathCopy);
5035
/* We should cut file extention before deleting of table */
5036
memcpy(filePathCopy, filePath, filePath_len - ext_len);
5037
filePathCopy[filePath_len - ext_len]= 0;
5038
share.init(NULL, filePathCopy);
5039
if (!open_table_def(session, &share))
5041
share.db_type()->deleteTable(session, filePathCopy);
5043
share.free_table_share();
5041
share.free_table_share();
5046
File can be already deleted by tmp_table.file->delete_table().
5047
So we hide error messages which happnes during deleting of these
5050
my_delete(filePath, MYF(0));
5045
File can be already deleted by tmp_table.file->delete_table().
5046
So we hide error messages which happnes during deleting of these
5049
my_delete(filePath, MYF(0));
5053
(void) closedir(dirp);
5055
5056
delete session;