diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-04-07 15:19:45 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-04-07 15:19:45 +0200 |
commit | bbbd7cedf522e7ea9883b881370fceb91ed3d746 (patch) | |
tree | 64a54bba635ba04a1904921c587bcf15851e49da | |
parent | fdcaa6cb3201ef432574946976cbc981bcffac61 (diff) | |
download | mariadb-git-bbbd7cedf522e7ea9883b881370fceb91ed3d746.tar.gz |
my_dir() cleanup
* replace pointer acrobatics with a struct
* make sorting explicit: MY_DONT_SORT -> MY_WANT_SORT
(if you want something to be done - say it. fixes all places where
my_dir() was used without thinking)
* typo s/number_off_files/number_of_files/
* directory_file_name() doesn't need to be extern
* remove #ifdef __BORLANDC__
* ignore '.' and '..' entries
-rw-r--r-- | client/mysqltest.cc | 12 | ||||
-rw-r--r-- | include/my_dir.h | 5 | ||||
-rw-r--r-- | include/my_sys.h | 1 | ||||
-rw-r--r-- | mysys/default.c | 2 | ||||
-rw-r--r-- | mysys/my_lib.c | 248 | ||||
-rw-r--r-- | sql/log.cc | 2 | ||||
-rw-r--r-- | sql/log_event.cc | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 7 | ||||
-rw-r--r-- | sql/sql_db.cc | 32 | ||||
-rw-r--r-- | sql/sql_show.cc | 16 | ||||
-rw-r--r-- | sql/tztime.cc | 2 | ||||
-rw-r--r-- | storage/maria/ma_init.c | 2 | ||||
-rw-r--r-- | storage/maria/ma_loghandler.c | 2 | ||||
-rw-r--r-- | storage/maria/unittest/ma_maria_log_cleanup.c | 2 |
14 files changed, 125 insertions, 210 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 2cca53f4e74..222ecbdba6c 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -3633,7 +3633,6 @@ void do_remove_files_wildcard(struct st_command *command) fn_format(dirname, ds_directory.str, "", "", MY_UNPACK_FILENAME); DBUG_PRINT("info", ("listing directory: %s", dirname)); - /* Note that my_dir sorts the list if not given any flags */ if (!(dir_info= my_dir(dirname, MYF(MY_DONT_SORT | MY_WANT_STAT | MY_WME)))) { error= 1; @@ -3648,7 +3647,7 @@ void do_remove_files_wildcard(struct st_command *command) /* Set default wild chars for wild_compare, is changed in embedded mode */ set_wild_chars(1); - for (i= 0; i < (uint) dir_info->number_off_files; i++) + for (i= 0; i < (uint) dir_info->number_of_files; i++) { file= dir_info->dir_entry + i; /* Remove only regular files, i.e. no directories etc. */ @@ -3911,17 +3910,12 @@ static int get_list_files(DYNAMIC_STRING *ds, const DYNAMIC_STRING *ds_dirname, DBUG_ENTER("get_list_files"); DBUG_PRINT("info", ("listing directory: %s", ds_dirname->str)); - /* Note that my_dir sorts the list if not given any flags */ - if (!(dir_info= my_dir(ds_dirname->str, MYF(0)))) + if (!(dir_info= my_dir(ds_dirname->str, MYF(MY_WANT_SORT)))) DBUG_RETURN(1); set_wild_chars(1); - for (i= 0; i < (uint) dir_info->number_off_files; i++) + for (i= 0; i < (uint) dir_info->number_of_files; i++) { file= dir_info->dir_entry + i; - if (file->name[0] == '.' && - (file->name[1] == '\0' || - (file->name[1] == '.' && file->name[2] == '\0'))) - continue; /* . or .. */ if (ds_wild && ds_wild->length && wild_compare(file->name, ds_wild->str, 0)) continue; diff --git a/include/my_dir.h b/include/my_dir.h index 6a941b37d79..be988ae790c 100644 --- a/include/my_dir.h +++ b/include/my_dir.h @@ -46,8 +46,9 @@ extern "C" { #define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO) /* Ensure these dosn't clash with anything in my_sys.h */ -#define MY_DONT_SORT 8192 /* my_lib; Don't sort files */ +#define MY_WANT_SORT 8192 /* my_lib; sort files */ #define MY_WANT_STAT 16384 /* my_lib; stat files */ +#define MY_DONT_SORT 0 /* typedefs for my_dir & my_stat */ @@ -94,7 +95,7 @@ typedef struct st_my_dir /* Struct returned from my_dir */ we don't want to change code that uses my_dir. */ struct fileinfo *dir_entry; - uint number_off_files; + uint number_of_files; } MY_DIR; extern MY_DIR *my_dir(const char *path,myf MyFlags); diff --git a/include/my_sys.h b/include/my_sys.h index 13e4d463515..40061a33636 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -708,7 +708,6 @@ extern size_t cleanup_dirname(char * to,const char *from); extern size_t system_filename(char * to,const char *from); extern size_t unpack_filename(char * to,const char *from); extern char * intern_filename(char * to,const char *from); -extern char * directory_file_name(char * dst, const char *src); extern int pack_filename(char * to, const char *name, size_t max_length); extern char * my_path(char * to,const char *progname, const char *own_pathname_part); diff --git a/mysys/default.c b/mysys/default.c index a90f428eca5..9e23eb6b261 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -846,7 +846,7 @@ static int search_default_file_with_ext(Process_option_func opt_handler, if (!(search_dir= my_dir(ptr, MYF(MY_WME)))) goto err; - for (i= 0; i < (uint) search_dir->number_off_files; i++) + for (i= 0; i < (uint) search_dir->number_of_files; i++) { search_file= search_dir->dir_entry + i; ext= fn_ext(search_file->name); diff --git a/mysys/my_lib.c b/mysys/my_lib.c index f11ea97d328..e8a81b19e22 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -22,10 +22,8 @@ #include "mysys_err.h" #if defined(HAVE_DIRENT_H) # include <dirent.h> -# define NAMLEN(dirent) strlen((dirent)->d_name) #else # define dirent direct -# define NAMLEN(dirent) (dirent)->d_namlen # if defined(HAVE_SYS_NDIR_H) # include <sys/ndir.h> # endif @@ -60,25 +58,29 @@ static int comp_names(struct fileinfo *a,struct fileinfo *b); +typedef struct { + MY_DIR dir; + DYNAMIC_ARRAY array; + MEM_ROOT root; +} MY_DIR_HANDLE; - /* We need this because program don't know with malloc we used */ +/* We need this because the caller doesn't know which malloc we've used */ -void my_dirend(MY_DIR *buffer) +void my_dirend(MY_DIR *dir) { + MY_DIR_HANDLE *dirh= (MY_DIR_HANDLE*) dir; DBUG_ENTER("my_dirend"); - if (buffer) + if (dirh) { - delete_dynamic((DYNAMIC_ARRAY*)((char*)buffer + - ALIGN_SIZE(sizeof(MY_DIR)))); - free_root((MEM_ROOT*)((char*)buffer + ALIGN_SIZE(sizeof(MY_DIR)) + - ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))), MYF(0)); - my_free(buffer); + delete_dynamic(&dirh->array); + free_root(&dirh->root, MYF(0)); + my_free(dirh); } DBUG_VOID_RETURN; } /* my_dirend */ - /* Compare in sort of filenames */ + /* Compare in sort of filenames */ static int comp_names(struct fileinfo *a, struct fileinfo *b) { @@ -88,13 +90,27 @@ static int comp_names(struct fileinfo *a, struct fileinfo *b) #if !defined(_WIN32) +static char *directory_file_name (char * dst, const char *src) +{ + /* Process as Unix format: just remove test the final slash. */ + char *end; + DBUG_ASSERT(strlen(src) < (FN_REFLEN + 1)); + + if (src[0] == 0) + src= (char*) "."; /* Use empty as current */ + end=strmov(dst, src); + if (end[-1] != FN_LIBCHAR + 1) + { + *end++= FN_LIBCHAR; /* Add last '/' */ + *end='\0'; + } + return end; +} + MY_DIR *my_dir(const char *path, myf MyFlags) { - char *buffer; - MY_DIR *result= 0; + MY_DIR_HANDLE *dirh= 0; FILEINFO finfo; - DYNAMIC_ARRAY *dir_entries_storage; - MEM_ROOT *names_storage; DIR *dirp; struct dirent *dp; char tmp_path[FN_REFLEN + 2], *tmp_file; @@ -107,59 +123,53 @@ MY_DIR *my_dir(const char *path, myf MyFlags) mysql_mutex_lock(&THR_LOCK_open); #endif - dirp = opendir(directory_file_name(tmp_path,(char *) path)); -#if defined(__amiga__) - if ((dirp->dd_fd) < 0) /* Directory doesn't exists */ - goto error; -#endif - if (dirp == NULL || - ! (buffer= my_malloc(ALIGN_SIZE(sizeof(MY_DIR)) + - ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)) + - sizeof(MEM_ROOT), MyFlags))) + tmp_file= directory_file_name(tmp_path, path); + + if (!(dirp= opendir(tmp_path))) goto error; - dir_entries_storage= (DYNAMIC_ARRAY*)(buffer + ALIGN_SIZE(sizeof(MY_DIR))); - names_storage= (MEM_ROOT*)(buffer + ALIGN_SIZE(sizeof(MY_DIR)) + - ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))); + if (!(dirh= my_malloc(sizeof(*dirh), MyFlags | MY_ZEROFILL))) + goto error; - if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO), + if (my_init_dynamic_array(&dirh->array, sizeof(FILEINFO), ENTRIES_START_SIZE, ENTRIES_INCREMENT, MYF(MyFlags))) - { - my_free(buffer); goto error; - } - init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE, - MYF(MyFlags)); - /* MY_DIR structure is allocated and completly initialized at this point */ - result= (MY_DIR*)buffer; - - tmp_file=strend(tmp_path); + init_alloc_root(&dirh->root, NAMES_START_SIZE, NAMES_START_SIZE, + MYF(MyFlags)); dp= (struct dirent*) dirent_tmp; while (!(READDIR(dirp,(struct dirent*) dirent_tmp,dp))) { - if (!(finfo.name= strdup_root(names_storage, dp->d_name))) - goto error; + MY_STAT statbuf, *mystat= 0; + if (dp->d_name[0] == '.' && + (dp->d_name[1] == '\0' || + (dp->d_name[1] == '.' && dp->d_name[2] == '\0'))) + continue; /* . or .. */ + if (MyFlags & MY_WANT_STAT) { - if (!(finfo.mystat= (MY_STAT*)alloc_root(names_storage, - sizeof(MY_STAT)))) - goto error; - - bzero(finfo.mystat, sizeof(MY_STAT)); - (void) strmov(tmp_file,dp->d_name); - (void) my_stat(tmp_path, finfo.mystat, MyFlags); - if (!(finfo.mystat->st_mode & MY_S_IREAD)) + mystat= &statbuf; + bzero(mystat, sizeof(*mystat)); + (void) strmov(tmp_file, dp->d_name); + (void) my_stat(tmp_path, mystat, MyFlags); + if (!(mystat->st_mode & MY_S_IREAD)) continue; } - else - finfo.mystat= NULL; - if (push_dynamic(dir_entries_storage, (uchar*)&finfo)) + if (!(finfo.name= strdup_root(&dirh->root, dp->d_name))) + goto error; + + if (mystat && + !((mystat= memdup_root(&dirh->root, mystat, sizeof(*mystat))))) + goto error; + + finfo.mystat= mystat; + + if (push_dynamic(&dirh->array, (uchar*)&finfo)) goto error; } @@ -167,13 +177,14 @@ MY_DIR *my_dir(const char *path, myf MyFlags) #if !defined(HAVE_READDIR_R) mysql_mutex_unlock(&THR_LOCK_open); #endif - result->dir_entry= (FILEINFO *)dir_entries_storage->buffer; - result->number_off_files= dir_entries_storage->elements; - if (!(MyFlags & MY_DONT_SORT)) - my_qsort((void *) result->dir_entry, result->number_off_files, - sizeof(FILEINFO), (qsort_cmp) comp_names); - DBUG_RETURN(result); + if (MyFlags & MY_WANT_SORT) + sort_dynamic(&dirh->array, (qsort_cmp) comp_names); + + dirh->dir.dir_entry= dynamic_element(&dirh->array, 0, FILEINFO *); + dirh->dir.number_of_files= dirh->array.elements; + + DBUG_RETURN(&dirh->dir); error: #if !defined(HAVE_READDIR_R) @@ -182,37 +193,13 @@ MY_DIR *my_dir(const char *path, myf MyFlags) my_errno=errno; if (dirp) (void) closedir(dirp); - my_dirend(result); + my_dirend(&dirh->dir); if (MyFlags & (MY_FAE | MY_WME)) - my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,my_errno); - DBUG_RETURN((MY_DIR *) NULL); + my_error(EE_DIR, MYF(ME_BELL | ME_WAITTANG), path, my_errno); + DBUG_RETURN(NULL); } /* my_dir */ -/* - * Convert from directory name to filename. - * On UNIX, it's simple: just make sure there is a terminating / - - * Returns pointer to dst; - */ - -char * directory_file_name (char * dst, const char *src) -{ - /* Process as Unix format: just remove test the final slash. */ - char *end; - DBUG_ASSERT(strlen(src) < (FN_REFLEN + 1)); - - if (src[0] == 0) - src= (char*) "."; /* Use empty as current */ - end= strnmov(dst, src, FN_REFLEN + 1); - if (end[-1] != FN_LIBCHAR) - { - end[0]=FN_LIBCHAR; /* Add last '/' */ - end[1]='\0'; - } - return dst; -} - #else /* @@ -223,18 +210,11 @@ char * directory_file_name (char * dst, const char *src) MY_DIR *my_dir(const char *path, myf MyFlags) { - char *buffer; - MY_DIR *result= 0; + MY_DIR_HANDLE *dirh= 0; FILEINFO finfo; - DYNAMIC_ARRAY *dir_entries_storage; - MEM_ROOT *names_storage; -#ifdef __BORLANDC__ - struct ffblk find; -#else struct _finddata_t find; -#endif ushort mode; - char tmp_path[FN_REFLEN],*tmp_file,attrib; + char tmp_path[FN_REFLEN], *tmp_file,attrib; #ifdef _WIN64 __int64 handle; #else @@ -257,32 +237,18 @@ MY_DIR *my_dir(const char *path, myf MyFlags) tmp_file[2]='*'; tmp_file[3]='\0'; - if (!(buffer= my_malloc(ALIGN_SIZE(sizeof(MY_DIR)) + - ALIGN_SIZE(sizeof(DYNAMIC_ARRAY)) + - sizeof(MEM_ROOT), MyFlags))) + if (!(dirh= my_malloc(sizeof(*dirh), MyFlags | MY_ZEROFILL))) goto error; - - dir_entries_storage= (DYNAMIC_ARRAY*)(buffer + ALIGN_SIZE(sizeof(MY_DIR))); - names_storage= (MEM_ROOT*)(buffer + ALIGN_SIZE(sizeof(MY_DIR)) + - ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))); - if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO), + if (my_init_dynamic_array(&dirh->array, sizeof(FILEINFO), ENTRIES_START_SIZE, ENTRIES_INCREMENT, MYF(MyFlags))) - { - my_free(buffer); goto error; - } - init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE, MYF(MyFlags)); - - /* MY_DIR structure is allocated and completly initialized at this point */ - result= (MY_DIR*)buffer; -#ifdef __BORLANDC__ - if ((handle= findfirst(tmp_path,&find,0)) == -1L) -#else + init_alloc_root(&dirh->root, NAMES_START_SIZE, NAMES_START_SIZE, + MYF(MyFlags)); + if ((handle=_findfirst(tmp_path,&find)) == -1L) -#endif { DBUG_PRINT("info", ("findfirst returned error, errno: %d", errno)); if (errno != EINVAL) @@ -295,12 +261,8 @@ MY_DIR *my_dir(const char *path, myf MyFlags) } else { - do { -#ifdef __BORLANDC__ - attrib= find.ff_attrib; -#else attrib= find.attrib; /* Do not show hidden and system files which Windows sometimes create. @@ -309,71 +271,55 @@ MY_DIR *my_dir(const char *path, myf MyFlags) */ if (attrib & (_A_HIDDEN | _A_SYSTEM)) continue; -#endif -#ifdef __BORLANDC__ - if (!(finfo.name= strdup_root(names_storage, find.ff_name))) - goto error; -#else - if (!(finfo.name= strdup_root(names_storage, find.name))) + + if (find.name[0] == '.' && + (find.name[1] == '\0' || + (find.name[1] == '.' && find.name[2] == '\0'))) + continue; /* . or .. */ + + if (!(finfo.name= strdup_root(&dirh->root, find.name))) goto error; -#endif if (MyFlags & MY_WANT_STAT) { - if (!(finfo.mystat= (MY_STAT*)alloc_root(names_storage, - sizeof(MY_STAT)))) + if (!(finfo.mystat= (MY_STAT*)alloc_root(&dirh->root, sizeof(MY_STAT)))) goto error; bzero(finfo.mystat, sizeof(MY_STAT)); -#ifdef __BORLANDC__ - finfo.mystat->st_size=find.ff_fsize; -#else finfo.mystat->st_size=find.size; -#endif mode= MY_S_IREAD; if (!(attrib & _A_RDONLY)) mode|= MY_S_IWRITE; if (attrib & _A_SUBDIR) mode|= MY_S_IFDIR; finfo.mystat->st_mode= mode; -#ifdef __BORLANDC__ - finfo.mystat->st_mtime= ((uint32) find.ff_ftime); -#else finfo.mystat->st_mtime= ((uint32) find.time_write); -#endif } else finfo.mystat= NULL; - if (push_dynamic(dir_entries_storage, (uchar*)&finfo)) + if (push_dynamic(&dirh->array, (uchar*)&finfo)) goto error; } -#ifdef __BORLANDC__ - while (findnext(&find) == 0); -#else while (_findnext(handle,&find) == 0); - _findclose(handle); -#endif } - result->dir_entry= (FILEINFO *)dir_entries_storage->buffer; - result->number_off_files= dir_entries_storage->elements; + if (MyFlags & MY_WANT_SORT) + sort_dynamic(&dirh->array, (qsort_cmp) comp_names); + + dirh->dir.dir_entry= dynamic_element(&dirh->array, 0, FILEINFO *); + dirh->dir.number_of_files= dirh->array.elements; - if (!(MyFlags & MY_DONT_SORT)) - my_qsort((void *) result->dir_entry, result->number_off_files, - sizeof(FILEINFO), (qsort_cmp) comp_names); - DBUG_PRINT("exit", ("found %d files", result->number_off_files)); - DBUG_RETURN(result); + DBUG_PRINT("exit", ("found %d files", dirh->dir.number_of_files)); + DBUG_RETURN(&dirh->dir); error: my_errno=errno; -#ifndef __BORLANDC__ if (handle != -1) _findclose(handle); -#endif - my_dirend(result); - if (MyFlags & MY_FAE+MY_WME) - my_error(EE_DIR,MYF(ME_BELL+ME_WAITTANG),path,errno); - DBUG_RETURN((MY_DIR *) NULL); + my_dirend(&dirh->dir); + if (MyFlags & (MY_FAE | MY_WME)) + my_error(EE_DIR,MYF(ME_BELL | ME_WAITTANG), path, errno); + DBUG_RETURN(NULL); } /* my_dir */ #endif /* _WIN32 */ diff --git a/sql/log.cc b/sql/log.cc index 0c273453751..5ddfab6f805 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2277,7 +2277,7 @@ static int find_uniq_filename(char *name) DBUG_RETURN(1); } file_info= dir_info->dir_entry; - for (i= dir_info->number_off_files ; i-- ; file_info++) + for (i= dir_info->number_of_files ; i-- ; file_info++) { if (memcmp(file_info->name, start, length) == 0 && test_if_number(file_info->name+length, &number,0)) diff --git a/sql/log_event.cc b/sql/log_event.cc index 55b95996515..19bc79babb1 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -577,7 +577,7 @@ static void cleanup_load_tmpdir() *(p++)= '-'; *p= 0; - for (i=0 ; i < (uint)dirp->number_off_files; i++) + for (i=0 ; i < (uint)dirp->number_of_files; i++) { file=dirp->dir_entry+i; if (is_prefix(file->name, prefbuf)) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d32f39cae2f..0d31ba06e12 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -9230,15 +9230,10 @@ my_bool mysql_rm_tmp_tables(void) /* Remove all SQLxxx tables from directory */ - for (idx=0 ; idx < (uint) dirp->number_off_files ; idx++) + for (idx=0 ; idx < (uint) dirp->number_of_files ; idx++) { file=dirp->dir_entry+idx; - /* skiping . and .. */ - if (file->name[0] == '.' && (!file->name[1] || - (file->name[1] == '.' && !file->name[2]))) - continue; - if (!memcmp(file->name, tmp_file_prefix, tmp_file_prefix_length)) { diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 87650e643f2..b287aad49ef 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -52,11 +52,9 @@ const char *del_exts[]= {".frm", ".BAK", ".TMD",".opt", NullS}; static TYPELIB deletable_extentions= {array_elements(del_exts)-1,"del_exts", del_exts, NULL}; -static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp, - const char *db, - const char *path, - TABLE_LIST **tables, - bool *found_other_files); +static bool find_db_tables_and_rm_known_files(THD *, MY_DIR *, const char *, + const char *, TABLE_LIST **, + bool *); long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path); static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error); @@ -1010,18 +1008,13 @@ static bool find_db_tables_and_rm_known_files(THD *thd, MY_DIR *dirp, tot_list_next_local= tot_list_next_global= &tot_list; for (uint idx=0 ; - idx < (uint) dirp->number_off_files && !thd->killed ; + idx < (uint) dirp->number_of_files && !thd->killed ; idx++) { FILEINFO *file=dirp->dir_entry+idx; char *extension; DBUG_PRINT("info",("Examining: %s", file->name)); - /* skiping . and .. */ - if (file->name[0] == '.' && (!file->name[1] || - (file->name[1] == '.' && !file->name[2]))) - continue; - if (file->name[0] == 'a' && file->name[1] == 'r' && file->name[2] == 'c' && file->name[3] == '\0') { @@ -1189,18 +1182,13 @@ long mysql_rm_arc_files(THD *thd, MY_DIR *dirp, const char *org_path) DBUG_PRINT("enter", ("path: %s", org_path)); for (uint idx=0 ; - idx < (uint) dirp->number_off_files && !thd->killed ; + idx < (uint) dirp->number_of_files && !thd->killed ; idx++) { FILEINFO *file=dirp->dir_entry+idx; char *extension, *revision; DBUG_PRINT("info",("Examining: %s", file->name)); - /* skiping . and .. */ - if (file->name[0] == '.' && (!file->name[1] || - (file->name[1] == '.' && !file->name[2]))) - continue; - extension= fn_ext(file->name); if (extension[0] != '.' || extension[1] != 'f' || extension[2] != 'r' || @@ -1687,7 +1675,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db) /* Step2: Move tables to the new database */ if ((dirp = my_dir(path,MYF(MY_DONT_SORT)))) { - uint nfiles= (uint) dirp->number_off_files; + uint nfiles= (uint) dirp->number_of_files; for (uint idx=0 ; idx < nfiles && !thd->killed ; idx++) { FILEINFO *file= dirp->dir_entry + idx; @@ -1778,17 +1766,15 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db) if ((dirp = my_dir(path,MYF(MY_DONT_SORT)))) { - uint nfiles= (uint) dirp->number_off_files; + uint nfiles= (uint) dirp->number_of_files; for (uint idx=0 ; idx < nfiles ; idx++) { FILEINFO *file= dirp->dir_entry + idx; char oldname[FN_REFLEN + 1], newname[FN_REFLEN + 1]; DBUG_PRINT("info",("Examining: %s", file->name)); - /* skiping . and .. and MY_DB_OPT_FILE */ - if ((file->name[0] == '.' && - (!file->name[1] || (file->name[1] == '.' && !file->name[2]))) || - !my_strcasecmp(files_charset_info, file->name, MY_DB_OPT_FILE)) + /* skiping MY_DB_OPT_FILE */ + if (!my_strcasecmp(files_charset_info, file->name, MY_DB_OPT_FILE)) continue; /* pass empty file name, and file->name as extension to avoid encoding */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index fdfdea52a75..a9c40a44997 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -60,8 +60,6 @@ #include "datadict.h" // dd_frm_type() #include "keycaches.h" -#define STR_OR_NIL(S) ((S) ? (S) : "<nil>") - #ifdef WITH_PARTITION_STORAGE_ENGINE #include "ha_partition.h" #endif @@ -737,7 +735,7 @@ find_files(THD *thd, List<LEX_STRING> *files, const char *db, bzero((char*) &table_list,sizeof(table_list)); - if (!(dirp = my_dir(path,MYF((dir ? MY_WANT_STAT : 0) | + if (!(dirp = my_dir(path, MYF((dir ? MY_WANT_STAT : 0) | MY_WANT_SORT | MY_THREAD_SPECIFIC)))) { if (my_errno == ENOENT) @@ -747,16 +745,12 @@ find_files(THD *thd, List<LEX_STRING> *files, const char *db, DBUG_RETURN(FIND_FILES_DIR); } - for (i=0 ; i < (uint) dirp->number_off_files ; i++) + for (i=0 ; i < (uint) dirp->number_of_files ; i++) { char uname[SAFE_NAME_LEN + 1]; /* Unencoded name */ file=dirp->dir_entry+i; if (dir) { /* Return databases */ - if ((file->name[0] == '.' && - ((file->name[1] == '.' && file->name[2] == '\0') || - file->name[1] == '\0'))) - continue; /* . or .. */ #ifdef USE_SYMDIR char *ext; char buff[FN_REFLEN]; @@ -4626,9 +4620,9 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) goto err; } - DBUG_PRINT("INDEX VALUES",("db_name='%s', table_name='%s'", - STR_OR_NIL(lookup_field_vals.db_value.str), - STR_OR_NIL(lookup_field_vals.table_value.str))); + DBUG_PRINT("info",("db_name='%s', table_name='%s'", + lookup_field_vals.db_value.str, + lookup_field_vals.table_value.str)); if (!lookup_field_vals.wild_db_value && !lookup_field_vals.wild_table_value) { diff --git a/sql/tztime.cc b/sql/tztime.cc index 000e3ac0518..5e1e8bec7b3 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -2505,7 +2505,7 @@ scan_tz_dir(char * name_end) name_end= strmake(name_end, "/", FN_REFLEN - (name_end - fullname)); - for (i= 0; i < cur_dir->number_off_files; i++) + for (i= 0; i < cur_dir->number_of_files; i++) { if (cur_dir->dir_entry[i].name[0] != '.') { diff --git a/storage/maria/ma_init.c b/storage/maria/ma_init.c index 78ca7ed9bf8..962405552f0 100644 --- a/storage/maria/ma_init.c +++ b/storage/maria/ma_init.c @@ -148,7 +148,7 @@ my_bool maria_upgrade() "Converting them to Aria names", MYF(ME_JUST_INFO)); - for (i= 0; i < dir->number_off_files; i++) + for (i= 0; i < dir->number_of_files; i++) { const char *file= dir->dir_entry[i].name; if (strncmp(file, "maria_log.", 10) == 0 && diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 70d26b5ca49..5233e57594c 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -3479,7 +3479,7 @@ my_bool translog_walk_filenames(const char *directory, if (!(dirp = my_dir(directory, MYF(MY_DONT_SORT)))) return FALSE; - for (i= 0; i < dirp->number_off_files; i++) + for (i= 0; i < dirp->number_of_files; i++) { char *file= dirp->dir_entry[i].name; if (strncmp(file, "aria_log.", 10) == 0 && diff --git a/storage/maria/unittest/ma_maria_log_cleanup.c b/storage/maria/unittest/ma_maria_log_cleanup.c index 60e4fdb02fd..3e4bc755832 100644 --- a/storage/maria/unittest/ma_maria_log_cleanup.c +++ b/storage/maria/unittest/ma_maria_log_cleanup.c @@ -38,7 +38,7 @@ my_bool maria_log_remove(const char *testdir) if (!(dirp = my_dir(maria_data_root, MYF(MY_DONT_SORT)))) return 1; - for (i= 0; i < dirp->number_off_files; i++) + for (i= 0; i < dirp->number_of_files; i++) { char *file= dirp->dir_entry[i].name; if (strncmp(file, "aria_log.", 9) == 0 && |