diff options
author | unknown <monty@hundin.mysql.fi> | 2001-05-31 14:07:17 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2001-05-31 14:07:17 +0300 |
commit | d9a9f38e870f24c4bc148ed58333abaedad81f05 (patch) | |
tree | f19c68fd5b7d68ad4f7919cb8e6eae7d6961956e /myisam | |
parent | 5ec74dda9bb5970f8fbba559e47c19a2b6e91561 (diff) | |
download | mariadb-git-d9a9f38e870f24c4bc148ed58333abaedad81f05.tar.gz |
Removed compiler warnings.
Added preliminary handling of symlinks in MyISAM.
When using myisamchk to check tables with --force, don't repair
tables that are marked as 'not closed' if they are ok.
Change fn_format() to use my_real_path and my_symlink
include/myisam.h:
Added handling of symlinks
myisam/ft_boolean_search.c:
cleanup
myisam/ft_dump.c:
cleanup
myisam/mi_check.c:
Added handling of symlinks.
When using check and --force, don't repair tables that are marked
as 'not closed' if they are ok.
myisam/mi_create.c:
Added handling of symlinks.
myisam/mi_dbug.c:
Added handling of symlinks.
myisam/mi_info.c:
Added handling of symlinks.
myisam/mi_open.c:
Added handling of symlinks.
myisam/mi_search.c:
cleanup
myisam/myisamchk.c:
Added handling of symlinks.
myisam/myisamdef.h:
Added handling of symlinks.
myisam/myisamlog.c:
Fixed bug when using new trees
myisam/myisampack.c:
cleanup
mysys/mf_cache.c:
cleanup
mysys/mf_format.c:
Change to use my_real_path and my_symlink
mysys/my_alloc.c:
cleanup
BitKeeper/etc/ignore:
Added libmysqld/sql_command libmysqld/backup_dir libmysqld/simple-test to the ignore list
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/ft_boolean_search.c | 2 | ||||
-rw-r--r-- | myisam/ft_dump.c | 10 | ||||
-rw-r--r-- | myisam/mi_check.c | 18 | ||||
-rw-r--r-- | myisam/mi_create.c | 25 | ||||
-rw-r--r-- | myisam/mi_dbug.c | 2 | ||||
-rw-r--r-- | myisam/mi_info.c | 2 | ||||
-rw-r--r-- | myisam/mi_open.c | 38 | ||||
-rw-r--r-- | myisam/mi_search.c | 12 | ||||
-rw-r--r-- | myisam/myisamchk.c | 4 | ||||
-rw-r--r-- | myisam/myisamdef.h | 4 | ||||
-rw-r--r-- | myisam/myisamlog.c | 7 | ||||
-rw-r--r-- | myisam/myisampack.c | 3 |
12 files changed, 84 insertions, 43 deletions
diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index f0865932ca0..5ff049888f2 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -198,7 +198,7 @@ FT_DOCLIST *ft_boolean_search(MI_INFO *info, uint keynr, byte *query, aio.end=query+query_len; aio.total_yes=aio.total_no=0; - init_tree(&aio.dtree,0,sizeof(FT_SUPERDOC),(qsort_cmp)&FT_SUPERDOC_cmp,0, + init_tree(&aio.dtree,0,sizeof(FT_SUPERDOC),(qsort2_cmp) &FT_SUPERDOC_cmp,0, NULL); if (do_boolean(&aio,0,0,0,0)) diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c index 62e2a67dfc2..bb308188969 100644 --- a/myisam/ft_dump.c +++ b/myisam/ft_dump.c @@ -31,11 +31,11 @@ static char *query=NULL; int main(int argc,char *argv[]) { int error=0; - uint keylen, inx, doc_cnt; + uint keylen, inx, doc_cnt=0; float weight; - double gws, min_gws, avg_gws=0; + double gws, min_gws=0, avg_gws=0; MI_INFO *info; - char buf[MAX], buf2[MAX], buf_maxlen[MAX], buf_min_gws[MAX], *s; + char buf[MAX], buf2[MAX], buf_maxlen[MAX], buf_min_gws[MAX]; ulong total=0, maxlen=0, uniq=0, max_doc_cnt=0; #ifdef EVAL_RUN uint cnt; @@ -111,8 +111,8 @@ int main(int argc,char *argv[]) cnt=*(byte *)(info->lastkey+keylen); #endif /* EVAL_RUN */ - snprintf(buf,MAX,"%.*s",keylen,info->lastkey+1); - for (s=buf;*s;s++) *s=tolower(*s); + snprintf(buf,MAX,"%.*s",(int) keylen,info->lastkey+1); + casedn_str(buf); total++; if (count || stats) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index b19a3ffdfbc..75bc7aa876c 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -103,6 +103,7 @@ void myisamchk_init(MI_CHECK *param) int chk_status(MI_CHECK *param, register MI_INFO *info) { MYISAM_SHARE *share=info->s; + if (mi_is_crashed_on_repair(info)) mi_check_print_warning(param, "Table is marked as crashed and last repair failed"); @@ -111,9 +112,12 @@ int chk_status(MI_CHECK *param, register MI_INFO *info) "Table is marked as crashed"); if (share->state.open_count != (uint) (info->s->global_changed ? 1 : 0)) { + /* Don't count this as a real warning, as check can correct this ! */ + uint save=param->warning_printed; mi_check_print_warning(param, "%d clients is using or hasn't closed the table properly", share->state.open_count); + param->warning_printed=save; } return 0; } @@ -1288,7 +1292,7 @@ err: { my_close(new_file,MYF(0)); info->dfile=new_file= -1; - if (change_to_newfile(share->filename,MI_NAME_DEXT, + if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, DATA_TMP_EXT, share->base.raid_chunks, (param->testflag & T_BACKUP_DATA ? MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || @@ -1514,7 +1518,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) VOID(my_close(share->kfile,MYF(MY_WME))); share->kfile = -1; VOID(my_close(new_file,MYF(MY_WME))); - if (change_to_newfile(share->filename,MI_NAME_IEXT,INDEX_TMP_EXT,0, + if (change_to_newfile(share->index_file_name,MI_NAME_IEXT,INDEX_TMP_EXT,0, MYF(0)) || mi_open_keyfile(share)) goto err2; @@ -1994,7 +1998,7 @@ err: { my_close(new_file,MYF(0)); info->dfile=new_file= -1; - if (change_to_newfile(share->filename,MI_NAME_DEXT, + if (change_to_newfile(share->data_file_name,MI_NAME_DEXT, DATA_TMP_EXT, share->base.raid_chunks, (param->testflag & T_BACKUP_DATA ? MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || @@ -2846,7 +2850,6 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) MI_STATUS_INFO status_info; uint unpack,key_parts; ha_rows max_records; - char name[FN_REFLEN]; ulonglong file_length,tmp_length; MI_CREATE_INFO create_info; @@ -2955,8 +2958,9 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) create_info.language = (param->language ? param->language : share.state.header.language); - if (mi_create(fn_format(name,filename,"",MI_NAME_IEXT, - 4+ (param->opt_follow_links ? 16 : 0)), + /* We don't have to handle symlinks here because we are using + HA_DONT_TOUCH_DATA */ + if (mi_create(filename, share.base.keys - share.state.header.uniques, keyinfo, share.base.fields, recdef, share.state.header.uniques, uniquedef, @@ -2966,7 +2970,7 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) mi_check_print_error(param,"Got error %d when trying to recreate indexfile",my_errno); goto end; } - *org_info=mi_open(name,O_RDWR, + *org_info=mi_open(filename,O_RDWR, (param->testflag & T_WAIT_FOREVER) ? HA_OPEN_WAIT_IF_LOCKED : (param->testflag & T_DESCRIPT) ? HA_OPEN_IGNORE_IF_LOCKED : HA_OPEN_ABORT_IF_LOCKED); diff --git a/myisam/mi_create.c b/myisam/mi_create.c index 6de13f8f84a..baac816092d 100644 --- a/myisam/mi_create.c +++ b/myisam/mi_create.c @@ -468,16 +468,20 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, if (! (flags & HA_DONT_TOUCH_DATA)) share.state.create_time= (long) time((time_t*) 0); - if ((file = my_create(fn_format(buff,name,"",MI_NAME_IEXT,4),0, - O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) + if ((file= my_create_with_symlink(ci->index_file_name, + fn_format(buff,name,"",MI_NAME_IEXT,4+ + (ci->index_file_name ? 0 : 32)), + 0, O_RDWR | O_TRUNC, + MYF(MY_WME | MY_DELETE_OLD))) < 0) goto err; errpos=1; - VOID(fn_format(buff,name,"",MI_NAME_DEXT,2+4)); + if (!(flags & HA_DONT_TOUCH_DATA)) { #ifdef USE_RAID if (share.base.raid_type) { + (void) fn_format(buff,name,"",MI_NAME_DEXT,2+4); if ((dfile=my_raid_create(buff,0,O_RDWR | O_TRUNC, share.base.raid_type, share.base.raid_chunks, @@ -487,9 +491,14 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, } else #endif - if ((dfile = my_create(buff,0,O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) - goto err; - + { + (void) fn_format(buff,name,"",MI_NAME_DEXT,2+4 + + (ci->data_file_name ? 0 : 32)); + if ((dfile= + my_create_with_symlink(ci->data_file_name, buff, + 0,O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) + goto err; + } errpos=3; } @@ -601,6 +610,8 @@ err: /* QQ: Tõnu should add a call to my_raid_delete() here */ VOID(fn_format(buff,name,"",MI_NAME_DEXT,2+4)); my_delete(buff,MYF(0)); + if (ci->data_file_name && strcmp(buff,ci->data_file_name)) + my_delete(ci->data_file_name,MYF(0)); } /* fall through */ case 1: @@ -609,6 +620,8 @@ err: { VOID(fn_format(buff,name,"",MI_NAME_IEXT,2+4)); my_delete(buff,MYF(0)); + if (ci->index_file_name && strcmp(buff,ci->index_file_name)) + my_delete(ci->index_file_name,MYF(0)); } } my_free((char*) rec_per_key_part, MYF(0)); diff --git a/myisam/mi_dbug.c b/myisam/mi_dbug.c index eda1aafecc8..8c532970dd9 100644 --- a/myisam/mi_dbug.c +++ b/myisam/mi_dbug.c @@ -162,7 +162,7 @@ my_bool check_table_is_closed(const char *name, const char *where) { MI_INFO *info=(MI_INFO*) pos->data; MYISAM_SHARE *share=info->s; - if (!strcmp(share->filename,filename)) + if (!strcmp(share->unique_file_name,filename)) { if (share->last_version) { diff --git a/myisam/mi_info.c b/myisam/mi_info.c index 6e7abfc0914..867718de326 100644 --- a/myisam/mi_info.c +++ b/myisam/mi_info.c @@ -87,6 +87,8 @@ int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag) x->raid_chunks= share->base.raid_chunks; x->raid_chunksize= share->base.raid_chunksize; x->key_map = share->state.key_map; + x->data_file_name = share->data_file_name; + x->index_file_name = share->index_file_name; } if ((flag & HA_STATUS_TIME) && !my_fstat(info->dfile,&state,MYF(0))) x->update_time=state.st_mtime; diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 7f94de9ffa2..3ecc1cb8475 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -49,7 +49,7 @@ static MI_INFO *test_if_reopen(char *filename) { MI_INFO *info=(MI_INFO*) pos->data; MYISAM_SHARE *share=info->s; - if (!strcmp(share->filename,filename) && share->last_version) + if (!strcmp(share->unique_file_name,filename) && share->last_version) return info; } return 0; @@ -69,7 +69,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) int lock_error,kfile,open_mode,save_errno; uint i,j,len,errpos,head_length,base_pos,offset,info_length,extra,keys, key_parts,unique_key_parts,tmp_length,uniques; - char name_buff[FN_REFLEN],*disk_cache,*disk_pos; + char name_buff[FN_REFLEN], org_name [FN_REFLEN], index_name[FN_REFLEN], + data_name[FN_REFLEN]; + char *disk_cache,*disk_pos; MI_INFO info,*m_info,*old_info; MYISAM_SHARE share_buff,*share; ulong rec_per_key_part[MI_MAX_POSSIBLE_KEY*MI_MAX_KEY_SEG]; @@ -84,7 +86,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) head_length=sizeof(share_buff.state.header); bzero((byte*) &info,sizeof(info)); - VOID(fn_format(name_buff,name,"",MI_NAME_IEXT,4+16+32)); + my_realpath(name_buff, fn_format(org_name,name,"",MI_NAME_IEXT,4),MYF(0)); pthread_mutex_lock(&THR_LOCK_myisam); if (!(old_info=test_if_reopen(name_buff))) { @@ -128,6 +130,13 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) my_errno=HA_ERR_OLD_FILE; goto err; } + /* Don't call realpath() if the name can't be a link */ + if (strcmp(name_buff, org_name)) + my_readlink(index_name, org_name, MYF(0)); + else + strmov(index_name, org_name); + fn_format(data_name,org_name,"",MI_NAME_DEXT,4+16); + info_length=mi_uint2korr(share->state.header.header_length); base_pos=mi_uint2korr(share->state.header.base_pos); if (!(disk_cache=(char*) my_alloca(info_length))) @@ -250,7 +259,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) &share->rec, (share->base.fields+1)*sizeof(MI_COLUMNDEF), &share->blobs,sizeof(MI_BLOB)*share->base.blobs, - &share->filename,strlen(name_buff)+1, + &share->unique_file_name,strlen(name_buff)+1, + &share->index_file_name,strlen(index_name)+1, + &share->data_file_name,strlen(data_name)+1, &share->state.key_root,keys*sizeof(my_off_t), &share->state.key_del, (share->state.header.max_block_size*sizeof(my_off_t)), @@ -268,7 +279,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) memcpy((char*) share->state.key_del, (char*) key_del, (sizeof(my_off_t) * share->state.header.max_block_size)); - strmov(share->filename,name_buff); + strmov(share->unique_file_name, name_buff); + strmov(share->index_file_name, index_name); + strmov(share->data_file_name, data_name); share->blocksize=min(IO_SIZE,myisam_block_size); { @@ -438,12 +451,12 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) &info.buff,(share->base.max_key_block_length*2+ share->base.max_key_length), &info.lastkey,share->base.max_key_length*3+1, - &info.filename,strlen(name)+1, + &info.filename,strlen(org_name)+1, NullS)) goto err; errpos=6; - strmov(info.filename,name); + strmov(info.filename,org_name); memcpy(info.blobs,share->blobs,sizeof(MI_BLOB)*share->base.blobs); info.lastkey2=info.lastkey+share->base.max_key_length; @@ -514,7 +527,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) pthread_mutex_unlock(&THR_LOCK_myisam); if (myisam_log_file >= 0) { - intern_filename(name_buff,share->filename); + intern_filename(name_buff,share->index_file_name); _myisam_log(MI_LOG_OPEN,m_info,name_buff,(uint) strlen(name_buff)); } DBUG_RETURN(m_info); @@ -1000,13 +1013,10 @@ char *mi_recinfo_read(char *ptr, MI_COLUMNDEF *recinfo) int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share) { - char name_buff[FN_REFLEN]; - (void) fn_format(name_buff, share->filename,"",MI_NAME_DEXT, 2+4); - #ifdef USE_RAID if (share->base.raid_type) { - if ((info->dfile=my_raid_open(name_buff, + if ((info->dfile=my_raid_open(share->data_file_name, share->mode | O_SHARE, share->base.raid_type, share->base.raid_chunks, @@ -1016,7 +1026,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share) } else #endif - if ((info->dfile=my_open(name_buff, share->mode | O_SHARE, + if ((info->dfile=my_open(share->data_file_name, share->mode | O_SHARE, MYF(MY_WME))) < 0) return 1; return 0; @@ -1025,7 +1035,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share) int mi_open_keyfile(MYISAM_SHARE *share) { - if ((share->kfile=my_open(share->filename, share->mode | O_SHARE, + if ((share->kfile=my_open(share->unique_file_name, share->mode | O_SHARE, MYF(MY_WME))) < 0) return 1; return 0; diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 1db8c2a8b67..b6e85d2c0db 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -256,6 +256,7 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, DBUG_RETURN(flag); } /* _mi_seq_search */ + int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, uchar *key, uint key_len, uint nextflag, uchar **ret_pos, uchar *buff, my_bool *last_key) @@ -274,6 +275,13 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, uint saved_length=0, saved_prefix_len=0; DBUG_ENTER("_mi_prefix_search"); + LINT_INIT(length); + LINT_INIT(prefix_len); + LINT_INIT(seg_len_pack); + LINT_INIT(saved_from); + LINT_INIT(saved_to); + LINT_INIT(saved_vseg); + t_buff[0]=0; /* Avoid bugs */ if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST))) key_len=USE_WHOLE_KEY; @@ -405,11 +413,11 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, */ if (len < cmplen) { - my_flag=-1; + my_flag= -1; } else if (len > cmplen) { - if(my_flag = !(nextflag & SEARCH_PREFIX) && key_len_left>0) + if ((my_flag= (!(nextflag & SEARCH_PREFIX) && key_len_left>0))) break; goto fix_flag; } diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index cff5f781538..c2f67c64e48 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -207,7 +207,7 @@ static struct option long_options[] = static void print_version(void) { - printf("%s Ver 1.45 for %s at %s\n",my_progname,SYSTEM_TYPE, + printf("%s Ver 1.46 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE); } @@ -676,7 +676,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) info->update|=HA_STATE_CHANGED; } VOID(fn_format(fixed_name,filename,"",MI_NAME_IEXT, - 4+ (param->opt_follow_links ? 16 : 0))); + 4+ (param->opt_follow_links ? 32 : 0))); if (rep_quick && chk_del(&check_param, info, param->testflag & ~T_VERBOSE)) diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index 7c8a4a113f4..4dae9562758 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -159,7 +159,9 @@ typedef struct st_mi_isam_share { /* Shared between opens */ MI_COLUMNDEF *rec; /* Pointer to field information */ MI_PACK pack; /* Data about packed records */ MI_BLOB *blobs; /* Pointer to blobs */ - char *filename; /* Name of indexfile */ + char *unique_file_name; /* realpath() of index file */ + char *data_file_name, /* Resolved path names from symlinks */ + *index_file_name; byte *file_map; /* mem-map of file if possible */ ulong this_process; /* processid */ ulong last_process; /* For table-change-check */ diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c index ca2c4f27a74..4b227bb9699 100644 --- a/myisam/myisamlog.c +++ b/myisam/myisamlog.c @@ -56,7 +56,7 @@ extern int main(int argc,char * *argv); static void get_options(int *argc,char ***argv); static int examine_log(my_string file_name,char **table_names); static int read_string(IO_CACHE *file,gptr *to,uint length); -static int file_info_compare(void *a,void *b); +static int file_info_compare(void *cmp_arg, void *a,void *b); static int test_if_open(struct file_info *key,element_count count, struct test_if_open_param *param); static void fix_blob_pointers(MI_INFO *isam,byte *record); @@ -331,7 +331,7 @@ static int examine_log(my_string file_name, char **table_names) init_io_cache(&cache,file,0,READ_CACHE,start_offset,0,MYF(0)); bzero((gptr) com_count,sizeof(com_count)); - init_tree(&tree,0,sizeof(file_info),(qsort_cmp) file_info_compare,1, + init_tree(&tree,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, (void(*)(void*)) file_info_free); VOID(init_key_cache(KEY_CACHE_SIZE,(uint) (10*4*(IO_SIZE+MALLOC_OVERHEAD)))); @@ -698,7 +698,8 @@ static int read_string(IO_CACHE *file, register gptr *to, register uint length) } /* read_string */ -static int file_info_compare(void *a, void *b) +static int file_info_compare(void* cmp_arg __attribute__((unused)), + void *a, void *b) { long lint; diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 90ba655e41f..416b029dd1c 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -894,7 +894,8 @@ static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts) DBUG_RETURN(error != HA_ERR_END_OF_FILE); } -static int compare_huff_elements(void *not_used, byte *a, byte *b) +static int compare_huff_elements(void* cmp_arg __attribute__((unused)), + byte *a, byte *b) { return *((my_off_t*) a) < *((my_off_t*) b) ? -1 : (*((my_off_t*) a) == *((my_off_t*) b) ? 0 : 1); |