Commit ef678c6a authored by unknown's avatar unknown

Merge work:/home/bk/mysql-4.0 into hundin.mysql.fi:/my/bk/mysql-4.0


BitKeeper/etc/logging_ok:
  auto-union
parents e6ecbfd6 d9a9f38e
...@@ -355,3 +355,6 @@ support-files/mysql.server ...@@ -355,3 +355,6 @@ support-files/mysql.server
support-files/mysql.spec support-files/mysql.spec
tags tags
tmp/* tmp/*
libmysqld/sql_command
libmysqld/backup_dir
libmysqld/simple-test
jani@janikt.pp.saunalahti.fi jani@janikt.pp.saunalahti.fi
monty@hundin.mysql.fi monty@hundin.mysql.fi
monty@work.mysql.com
mwagner@evoq.mwagner.org mwagner@evoq.mwagner.org
sasha@mysql.sashanet.com sasha@mysql.sashanet.com
tonu@hundin.mysql.fi tonu@hundin.mysql.fi
monty@work.mysql.com
...@@ -68,6 +68,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */ ...@@ -68,6 +68,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */
ulong mean_reclength; /* Mean recordlength (if packed) */ ulong mean_reclength; /* Mean recordlength (if packed) */
ulonglong auto_increment; ulonglong auto_increment;
ulonglong key_map; /* Which keys are used */ ulonglong key_map; /* Which keys are used */
char *data_file_name, *index_file_name;
uint keys; /* Number of keys in use */ uint keys; /* Number of keys in use */
uint options; /* HA_OPTIONS_... used */ uint options; /* HA_OPTIONS_... used */
int errkey, /* With key was dupplicated on err */ int errkey, /* With key was dupplicated on err */
...@@ -86,6 +87,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */ ...@@ -86,6 +87,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */
typedef struct st_mi_create_info typedef struct st_mi_create_info
{ {
char *index_file_name, *data_file_name; /* If using symlinks */
ha_rows max_rows; ha_rows max_rows;
ha_rows reloc_rows; ha_rows reloc_rows;
ulonglong auto_increment; ulonglong auto_increment;
......
...@@ -198,7 +198,7 @@ FT_DOCLIST *ft_boolean_search(MI_INFO *info, uint keynr, byte *query, ...@@ -198,7 +198,7 @@ FT_DOCLIST *ft_boolean_search(MI_INFO *info, uint keynr, byte *query,
aio.end=query+query_len; aio.end=query+query_len;
aio.total_yes=aio.total_no=0; 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); NULL);
if (do_boolean(&aio,0,0,0,0)) if (do_boolean(&aio,0,0,0,0))
......
...@@ -31,11 +31,11 @@ static char *query=NULL; ...@@ -31,11 +31,11 @@ static char *query=NULL;
int main(int argc,char *argv[]) int main(int argc,char *argv[])
{ {
int error=0; int error=0;
uint keylen, inx, doc_cnt; uint keylen, inx, doc_cnt=0;
float weight; float weight;
double gws, min_gws, avg_gws=0; double gws, min_gws=0, avg_gws=0;
MI_INFO *info; 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; ulong total=0, maxlen=0, uniq=0, max_doc_cnt=0;
#ifdef EVAL_RUN #ifdef EVAL_RUN
uint cnt; uint cnt;
...@@ -111,8 +111,8 @@ int main(int argc,char *argv[]) ...@@ -111,8 +111,8 @@ int main(int argc,char *argv[])
cnt=*(byte *)(info->lastkey+keylen); cnt=*(byte *)(info->lastkey+keylen);
#endif /* EVAL_RUN */ #endif /* EVAL_RUN */
snprintf(buf,MAX,"%.*s",keylen,info->lastkey+1); snprintf(buf,MAX,"%.*s",(int) keylen,info->lastkey+1);
for (s=buf;*s;s++) *s=tolower(*s); casedn_str(buf);
total++; total++;
if (count || stats) if (count || stats)
......
...@@ -103,6 +103,7 @@ void myisamchk_init(MI_CHECK *param) ...@@ -103,6 +103,7 @@ void myisamchk_init(MI_CHECK *param)
int chk_status(MI_CHECK *param, register MI_INFO *info) int chk_status(MI_CHECK *param, register MI_INFO *info)
{ {
MYISAM_SHARE *share=info->s; MYISAM_SHARE *share=info->s;
if (mi_is_crashed_on_repair(info)) if (mi_is_crashed_on_repair(info))
mi_check_print_warning(param, mi_check_print_warning(param,
"Table is marked as crashed and last repair failed"); "Table is marked as crashed and last repair failed");
...@@ -111,9 +112,12 @@ int chk_status(MI_CHECK *param, register MI_INFO *info) ...@@ -111,9 +112,12 @@ int chk_status(MI_CHECK *param, register MI_INFO *info)
"Table is marked as crashed"); "Table is marked as crashed");
if (share->state.open_count != (uint) (info->s->global_changed ? 1 : 0)) 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, mi_check_print_warning(param,
"%d clients is using or hasn't closed the table properly", "%d clients is using or hasn't closed the table properly",
share->state.open_count); share->state.open_count);
param->warning_printed=save;
} }
return 0; return 0;
} }
...@@ -1288,7 +1292,7 @@ err: ...@@ -1288,7 +1292,7 @@ err:
{ {
my_close(new_file,MYF(0)); my_close(new_file,MYF(0));
info->dfile=new_file= -1; 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, DATA_TMP_EXT, share->base.raid_chunks,
(param->testflag & T_BACKUP_DATA ? (param->testflag & T_BACKUP_DATA ?
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || 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) ...@@ -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))); VOID(my_close(share->kfile,MYF(MY_WME)));
share->kfile = -1; share->kfile = -1;
VOID(my_close(new_file,MYF(MY_WME))); 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)) || MYF(0)) ||
mi_open_keyfile(share)) mi_open_keyfile(share))
goto err2; goto err2;
...@@ -1994,7 +1998,7 @@ err: ...@@ -1994,7 +1998,7 @@ err:
{ {
my_close(new_file,MYF(0)); my_close(new_file,MYF(0));
info->dfile=new_file= -1; 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, DATA_TMP_EXT, share->base.raid_chunks,
(param->testflag & T_BACKUP_DATA ? (param->testflag & T_BACKUP_DATA ?
MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) || MYF(MY_REDEL_MAKE_BACKUP): MYF(0))) ||
...@@ -2846,7 +2850,6 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) ...@@ -2846,7 +2850,6 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename)
MI_STATUS_INFO status_info; MI_STATUS_INFO status_info;
uint unpack,key_parts; uint unpack,key_parts;
ha_rows max_records; ha_rows max_records;
char name[FN_REFLEN];
ulonglong file_length,tmp_length; ulonglong file_length,tmp_length;
MI_CREATE_INFO create_info; MI_CREATE_INFO create_info;
...@@ -2955,8 +2958,9 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) ...@@ -2955,8 +2958,9 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename)
create_info.language = (param->language ? param->language : create_info.language = (param->language ? param->language :
share.state.header.language); share.state.header.language);
if (mi_create(fn_format(name,filename,"",MI_NAME_IEXT, /* We don't have to handle symlinks here because we are using
4+ (param->opt_follow_links ? 16 : 0)), HA_DONT_TOUCH_DATA */
if (mi_create(filename,
share.base.keys - share.state.header.uniques, share.base.keys - share.state.header.uniques,
keyinfo, share.base.fields, recdef, keyinfo, share.base.fields, recdef,
share.state.header.uniques, uniquedef, share.state.header.uniques, uniquedef,
...@@ -2966,7 +2970,7 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) ...@@ -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); mi_check_print_error(param,"Got error %d when trying to recreate indexfile",my_errno);
goto end; 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_WAIT_FOREVER) ? HA_OPEN_WAIT_IF_LOCKED :
(param->testflag & T_DESCRIPT) ? HA_OPEN_IGNORE_IF_LOCKED : (param->testflag & T_DESCRIPT) ? HA_OPEN_IGNORE_IF_LOCKED :
HA_OPEN_ABORT_IF_LOCKED); HA_OPEN_ABORT_IF_LOCKED);
......
...@@ -468,16 +468,20 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -468,16 +468,20 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
if (! (flags & HA_DONT_TOUCH_DATA)) if (! (flags & HA_DONT_TOUCH_DATA))
share.state.create_time= (long) time((time_t*) 0); share.state.create_time= (long) time((time_t*) 0);
if ((file = my_create(fn_format(buff,name,"",MI_NAME_IEXT,4),0, if ((file= my_create_with_symlink(ci->index_file_name,
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) 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; goto err;
errpos=1; errpos=1;
VOID(fn_format(buff,name,"",MI_NAME_DEXT,2+4));
if (!(flags & HA_DONT_TOUCH_DATA)) if (!(flags & HA_DONT_TOUCH_DATA))
{ {
#ifdef USE_RAID #ifdef USE_RAID
if (share.base.raid_type) 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, if ((dfile=my_raid_create(buff,0,O_RDWR | O_TRUNC,
share.base.raid_type, share.base.raid_type,
share.base.raid_chunks, share.base.raid_chunks,
...@@ -487,9 +491,14 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -487,9 +491,14 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
} }
else else
#endif #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; errpos=3;
} }
...@@ -601,6 +610,8 @@ err: ...@@ -601,6 +610,8 @@ err:
/* QQ: Tnu should add a call to my_raid_delete() here */ /* QQ: Tnu should add a call to my_raid_delete() here */
VOID(fn_format(buff,name,"",MI_NAME_DEXT,2+4)); VOID(fn_format(buff,name,"",MI_NAME_DEXT,2+4));
my_delete(buff,MYF(0)); 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 */ /* fall through */
case 1: case 1:
...@@ -609,6 +620,8 @@ err: ...@@ -609,6 +620,8 @@ err:
{ {
VOID(fn_format(buff,name,"",MI_NAME_IEXT,2+4)); VOID(fn_format(buff,name,"",MI_NAME_IEXT,2+4));
my_delete(buff,MYF(0)); 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)); my_free((char*) rec_per_key_part, MYF(0));
......
...@@ -162,7 +162,7 @@ my_bool check_table_is_closed(const char *name, const char *where) ...@@ -162,7 +162,7 @@ my_bool check_table_is_closed(const char *name, const char *where)
{ {
MI_INFO *info=(MI_INFO*) pos->data; MI_INFO *info=(MI_INFO*) pos->data;
MYISAM_SHARE *share=info->s; MYISAM_SHARE *share=info->s;
if (!strcmp(share->filename,filename)) if (!strcmp(share->unique_file_name,filename))
{ {
if (share->last_version) if (share->last_version)
{ {
......
...@@ -87,6 +87,8 @@ int mi_status(MI_INFO *info, register MI_ISAMINFO *x, uint flag) ...@@ -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_chunks= share->base.raid_chunks;
x->raid_chunksize= share->base.raid_chunksize; x->raid_chunksize= share->base.raid_chunksize;
x->key_map = share->state.key_map; 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))) if ((flag & HA_STATUS_TIME) && !my_fstat(info->dfile,&state,MYF(0)))
x->update_time=state.st_mtime; x->update_time=state.st_mtime;
......
...@@ -49,7 +49,7 @@ static MI_INFO *test_if_reopen(char *filename) ...@@ -49,7 +49,7 @@ static MI_INFO *test_if_reopen(char *filename)
{ {
MI_INFO *info=(MI_INFO*) pos->data; MI_INFO *info=(MI_INFO*) pos->data;
MYISAM_SHARE *share=info->s; 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 info;
} }
return 0; return 0;
...@@ -69,7 +69,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -69,7 +69,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
int lock_error,kfile,open_mode,save_errno; int lock_error,kfile,open_mode,save_errno;
uint i,j,len,errpos,head_length,base_pos,offset,info_length,extra,keys, uint i,j,len,errpos,head_length,base_pos,offset,info_length,extra,keys,
key_parts,unique_key_parts,tmp_length,uniques; 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; MI_INFO info,*m_info,*old_info;
MYISAM_SHARE share_buff,*share; MYISAM_SHARE share_buff,*share;
ulong rec_per_key_part[MI_MAX_POSSIBLE_KEY*MI_MAX_KEY_SEG]; 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) ...@@ -84,7 +86,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
head_length=sizeof(share_buff.state.header); head_length=sizeof(share_buff.state.header);
bzero((byte*) &info,sizeof(info)); 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); pthread_mutex_lock(&THR_LOCK_myisam);
if (!(old_info=test_if_reopen(name_buff))) if (!(old_info=test_if_reopen(name_buff)))
{ {
...@@ -128,6 +130,13 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -128,6 +130,13 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
my_errno=HA_ERR_OLD_FILE; my_errno=HA_ERR_OLD_FILE;
goto err; 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); info_length=mi_uint2korr(share->state.header.header_length);
base_pos=mi_uint2korr(share->state.header.base_pos); base_pos=mi_uint2korr(share->state.header.base_pos);
if (!(disk_cache=(char*) my_alloca(info_length))) if (!(disk_cache=(char*) my_alloca(info_length)))
...@@ -250,7 +259,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -250,7 +259,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
&share->rec, &share->rec,
(share->base.fields+1)*sizeof(MI_COLUMNDEF), (share->base.fields+1)*sizeof(MI_COLUMNDEF),
&share->blobs,sizeof(MI_BLOB)*share->base.blobs, &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_root,keys*sizeof(my_off_t),
&share->state.key_del, &share->state.key_del,
(share->state.header.max_block_size*sizeof(my_off_t)), (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) ...@@ -268,7 +279,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
memcpy((char*) share->state.key_del, memcpy((char*) share->state.key_del,
(char*) key_del, (sizeof(my_off_t) * (char*) key_del, (sizeof(my_off_t) *
share->state.header.max_block_size)); 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); share->blocksize=min(IO_SIZE,myisam_block_size);
{ {
...@@ -438,12 +451,12 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -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+ &info.buff,(share->base.max_key_block_length*2+
share->base.max_key_length), share->base.max_key_length),
&info.lastkey,share->base.max_key_length*3+1, &info.lastkey,share->base.max_key_length*3+1,
&info.filename,strlen(name)+1, &info.filename,strlen(org_name)+1,
NullS)) NullS))
goto err; goto err;
errpos=6; errpos=6;
strmov(info.filename,name); strmov(info.filename,org_name);
memcpy(info.blobs,share->blobs,sizeof(MI_BLOB)*share->base.blobs); memcpy(info.blobs,share->blobs,sizeof(MI_BLOB)*share->base.blobs);
info.lastkey2=info.lastkey+share->base.max_key_length; 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) ...@@ -514,7 +527,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
pthread_mutex_unlock(&THR_LOCK_myisam); pthread_mutex_unlock(&THR_LOCK_myisam);
if (myisam_log_file >= 0) 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)); _myisam_log(MI_LOG_OPEN,m_info,name_buff,(uint) strlen(name_buff));
} }
DBUG_RETURN(m_info); DBUG_RETURN(m_info);
...@@ -1000,13 +1013,10 @@ char *mi_recinfo_read(char *ptr, MI_COLUMNDEF *recinfo) ...@@ -1000,13 +1013,10 @@ char *mi_recinfo_read(char *ptr, MI_COLUMNDEF *recinfo)
int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share) 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 #ifdef USE_RAID
if (share->base.raid_type) 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->mode | O_SHARE,
share->base.raid_type, share->base.raid_type,
share->base.raid_chunks, share->base.raid_chunks,
...@@ -1016,7 +1026,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share) ...@@ -1016,7 +1026,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share)
} }
else else
#endif #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) MYF(MY_WME))) < 0)
return 1; return 1;
return 0; return 0;
...@@ -1025,7 +1035,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share) ...@@ -1025,7 +1035,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share)
int mi_open_keyfile(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) MYF(MY_WME))) < 0)
return 1; return 1;
return 0; return 0;
......
...@@ -256,6 +256,7 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, ...@@ -256,6 +256,7 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
DBUG_RETURN(flag); DBUG_RETURN(flag);
} /* _mi_seq_search */ } /* _mi_seq_search */
int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
uchar *key, uint key_len, uint nextflag, uchar **ret_pos, uchar *key, uint key_len, uint nextflag, uchar **ret_pos,
uchar *buff, my_bool *last_key) uchar *buff, my_bool *last_key)
...@@ -274,6 +275,13 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, ...@@ -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; uint saved_length=0, saved_prefix_len=0;
DBUG_ENTER("_mi_prefix_search"); 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 */ t_buff[0]=0; /* Avoid bugs */
if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST))) if (!(nextflag & (SEARCH_FIND | SEARCH_NO_FIND | SEARCH_LAST)))
key_len=USE_WHOLE_KEY; key_len=USE_WHOLE_KEY;
...@@ -405,11 +413,11 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, ...@@ -405,11 +413,11 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
*/ */
if (len < cmplen) if (len < cmplen)
{ {
my_flag=-1; my_flag= -1;
} }
else if (len > cmplen) 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; break;
goto fix_flag; goto fix_flag;
} }
......
...@@ -207,7 +207,7 @@ static struct option long_options[] = ...@@ -207,7 +207,7 @@ static struct option long_options[] =
static void print_version(void) 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); MACHINE_TYPE);
} }
...@@ -676,7 +676,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) ...@@ -676,7 +676,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
info->update|=HA_STATE_CHANGED; info->update|=HA_STATE_CHANGED;
} }
VOID(fn_format(fixed_name,filename,"",MI_NAME_IEXT, 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, if (rep_quick && chk_del(&check_param, info,
param->testflag & ~T_VERBOSE)) param->testflag & ~T_VERBOSE))
......
...@@ -159,7 +159,9 @@ typedef struct st_mi_isam_share { /* Shared between opens */ ...@@ -159,7 +159,9 @@ typedef struct st_mi_isam_share { /* Shared between opens */
MI_COLUMNDEF *rec; /* Pointer to field information */ MI_COLUMNDEF *rec; /* Pointer to field information */
MI_PACK pack; /* Data about packed records */ MI_PACK pack; /* Data about packed records */
MI_BLOB *blobs; /* Pointer to blobs */ 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 */ byte *file_map; /* mem-map of file if possible */
ulong this_process; /* processid */ ulong this_process; /* processid */
ulong last_process; /* For table-change-check */ ulong last_process; /* For table-change-check */
......
...@@ -56,7 +56,7 @@ extern int main(int argc,char * *argv); ...@@ -56,7 +56,7 @@ extern int main(int argc,char * *argv);
static void get_options(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 examine_log(my_string file_name,char **table_names);
static int read_string(IO_CACHE *file,gptr *to,uint length); 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, static int test_if_open(struct file_info *key,element_count count,
struct test_if_open_param *param); struct test_if_open_param *param);
static void fix_blob_pointers(MI_INFO *isam,byte *record); 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) ...@@ -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)); init_io_cache(&cache,file,0,READ_CACHE,start_offset,0,MYF(0));
bzero((gptr) com_count,sizeof(com_count)); 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(*)(void*)) file_info_free);
VOID(init_key_cache(KEY_CACHE_SIZE,(uint) (10*4*(IO_SIZE+MALLOC_OVERHEAD)))); 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) ...@@ -698,7 +698,8 @@ static int read_string(IO_CACHE *file, register gptr *to, register uint length)
} /* read_string */ } /* 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; long lint;
......
...@@ -894,7 +894,8 @@ static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts) ...@@ -894,7 +894,8 @@ static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts)
DBUG_RETURN(error != HA_ERR_END_OF_FILE); 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 : return *((my_off_t*) a) < *((my_off_t*) b) ? -1 :
(*((my_off_t*) a) == *((my_off_t*) b) ? 0 : 1); (*((my_off_t*) a) == *((my_off_t*) b) ? 0 : 1);
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
this, just remember the file name for later removal this, just remember the file name for later removal
*/ */
static my_bool cache_remove_open_tmp(IO_CACHE *cache, const char *name) static my_bool cache_remove_open_tmp(IO_CACHE *cache __attribute__((unused)),
const char *name)
{ {
#if O_TEMPORARY == 0 #if O_TEMPORARY == 0
#if !defined(CANT_DELETE_OPEN_FILES) #if !defined(CANT_DELETE_OPEN_FILES)
......
...@@ -17,10 +17,6 @@ ...@@ -17,10 +17,6 @@
#include "mysys_priv.h" #include "mysys_priv.h"
#include <m_string.h> #include <m_string.h>
#ifdef HAVE_REALPATH
#include <sys/param.h>
#include <sys/stat.h>
#endif
/* format a filename with replace of library and extension */ /* format a filename with replace of library and extension */
/* params to and name may be identicall */ /* params to and name may be identicall */
...@@ -33,21 +29,12 @@ ...@@ -33,21 +29,12 @@
/* 32 Resolve filename to full path */ /* 32 Resolve filename to full path */
/* 64 Return NULL if too long path */ /* 64 Return NULL if too long path */
#ifdef SCO
#define BUFF_LEN 4097
#else
#ifdef MAXPATHLEN
#define BUFF_LEN MAXPATHLEN
#else
#define BUFF_LEN FN_LEN
#endif
#endif
my_string fn_format(my_string to, const char *name, const char *dsk, my_string fn_format(my_string to, const char *name, const char *dsk,
const char *form, int flag) const char *form, int flag)
{ {
reg1 uint length; reg1 uint length;
char dev[FN_REFLEN], buff[BUFF_LEN], *pos, *startpos; char dev[FN_REFLEN], buff[FN_REFLEN], *pos, *startpos;
const char *ext; const char *ext;
DBUG_ENTER("fn_format"); DBUG_ENTER("fn_format");
DBUG_PRINT("enter",("name: %s dsk: %s form: %s flag: %d", DBUG_PRINT("enter",("name: %s dsk: %s form: %s flag: %d",
...@@ -109,18 +96,14 @@ my_string fn_format(my_string to, const char *name, const char *dsk, ...@@ -109,18 +96,14 @@ my_string fn_format(my_string to, const char *name, const char *dsk,
#endif #endif
(void) strmov(pos,ext); /* Don't convert extension */ (void) strmov(pos,ext); /* Don't convert extension */
} }
/* Purify gives a lot of UMR errors when using realpath */
#if defined(HAVE_REALPATH) && !defined(HAVE_purify) && !defined(HAVE_BROKEN_REALPATH)
if (flag & 16) if (flag & 16)
{ {
struct stat stat_buff; strmov(buff,to);
if (flag & 32 || (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode))) my_symlink(to, buff, MYF(flag & 32 ? 0 : MY_RESOLVE_LINK));
{
if (realpath(to,buff))
strmake(to,buff,FN_REFLEN-1);
}
} }
#endif else if (flag & 32)
my_realpath(to, to, MYF(flag & 32 ? 0 : MY_RESOLVE_LINK));
DBUG_RETURN (to); DBUG_RETURN (to);
} /* fn_format */ } /* fn_format */
......
...@@ -100,41 +100,34 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) ...@@ -100,41 +100,34 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
#endif #endif
} }
/* Mark all data in blocks free for reusage */
static inline void mark_blocks_free(MEM_ROOT* root) static inline void mark_blocks_free(MEM_ROOT* root)
{ {
reg1 USED_MEM *next,*last = 0; reg1 USED_MEM *next;
reg2 USED_MEM **last;
/* iterate through (partially) free blocks, mark them fully free */ /* iterate through (partially) free blocks, mark them free */
for(next = root->free; next; next = next->next ) last= &root->free;
{ for (next= root->free; next; next= *(last= &next->next))
last = next; next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM));
next->left = next->size - ALIGN_SIZE(sizeof(USED_MEM));
} /* Combine the free and the used list */
/* if free block list was not empty, point the next of the *last= next=root->used;
last free block to the beginning of the used list */
next = root->used; /* a little optimization to avoid dereferencing root /* now go through the used blocks and mark them free */
twice - we will shortly start iterating through used for (; next; next= next->next)
list */ next->left= next->size - ALIGN_SIZE(sizeof(USED_MEM));
if(last)
last->next = next; /* Now everything is set; Indicate that nothing is used anymore */
else /* if free list is empty, just point it to the current used*/ root->used= 0;
root->free = next;
/* now go through the current used list, and mark each block
as fully free. Note that because of our optimization, we do not
need to initialize next here - see above
*/
for(;next; next = next->next)
next->left = next->size - ALIGN_SIZE(sizeof(USED_MEM));
/* Now everything is set - we just need to indicate that nothing is used
anymore
*/
root->used = 0;
} }
/* deallocate everything used by alloc_root or just move
used blocks to free list if called with MY_USED_TO_FREE */ /*
Deallocate everything used by alloc_root or just move
used blocks to free list if called with MY_USED_TO_FREE
*/
void free_root(MEM_ROOT *root, myf MyFlags) void free_root(MEM_ROOT *root, myf MyFlags)
{ {
...@@ -143,23 +136,23 @@ void free_root(MEM_ROOT *root, myf MyFlags) ...@@ -143,23 +136,23 @@ void free_root(MEM_ROOT *root, myf MyFlags)
if (!root) if (!root)
DBUG_VOID_RETURN; /* purecov: inspected */ DBUG_VOID_RETURN; /* purecov: inspected */
if(MyFlags & MY_MARK_BLOCKS_FREE) if (MyFlags & MY_MARK_BLOCKS_FREE)
{ {
mark_blocks_free(root); mark_blocks_free(root);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
if (!(MyFlags & MY_KEEP_PREALLOC)) if (!(MyFlags & MY_KEEP_PREALLOC))
root->pre_alloc=0; root->pre_alloc=0;
for ( next=root->used; next ;) for (next=root->used; next ;)
{ {
old=next; next= next->next ; old=next; next= next->next ;
if (old != root->pre_alloc) if (old != root->pre_alloc)
my_free((gptr) old,MYF(0)); my_free((gptr) old,MYF(0));
} }
for (next= root->free ; next ; ) for (next=root->free ; next ;)
{ {
old=next; next= next->next ; old=next; next= next->next;
if (old != root->pre_alloc) if (old != root->pre_alloc)
my_free((gptr) old,MYF(0)); my_free((gptr) old,MYF(0));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment