Commit a411286c authored by unknown's avatar unknown

bug in ft2 repair-by-sort fixed (sort_key_cmp() using ft2_keydef for ft keys)


myisam/ft_dump.c:
  style fix
myisam/sort.c:
  typo fixed
parent 5cf0014a
...@@ -124,13 +124,9 @@ int main(int argc,char *argv[]) ...@@ -124,13 +124,9 @@ int main(int argc,char *argv[])
{ {
keylen=*(info->lastkey); keylen=*(info->lastkey);
#if HA_FT_WTYPE == HA_KEYTYPE_FLOAT subkeys=ft_sintXkorr(info->lastkey+keylen+1);
subkeys=mi_sint4korr(info->lastkey+keylen+1);
if (subkeys >= 0) if (subkeys >= 0)
weight=*(float*)&subkeys; weight=*(float*)&subkeys;
#else
#error
#endif
snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey+1); snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey+1);
my_casedn_str(default_charset_info,buf); my_casedn_str(default_charset_info,buf);
......
...@@ -1893,6 +1893,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -1893,6 +1893,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
{ {
sort_param.read_cache=param->read_cache; sort_param.read_cache=param->read_cache;
sort_param.keyinfo=share->keyinfo+sort_param.key; sort_param.keyinfo=share->keyinfo+sort_param.key;
sort_param.seg=sort_param.keyinfo->seg;
if (!(((ulonglong) 1 << sort_param.key) & key_map)) if (!(((ulonglong) 1 << sort_param.key) & key_map))
{ {
/* Remember old statistics for key */ /* Remember old statistics for key */
...@@ -1906,7 +1907,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, ...@@ -1906,7 +1907,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
if ((!(param->testflag & T_SILENT))) if ((!(param->testflag & T_SILENT)))
printf ("- Fixing index %d\n",sort_param.key+1); printf ("- Fixing index %d\n",sort_param.key+1);
sort_param.max_pos=sort_param.pos=share->pack.header_length; sort_param.max_pos=sort_param.pos=share->pack.header_length;
keyseg=sort_param.keyinfo->seg; keyseg=sort_param.seg;
bzero((char*) sort_param.unique,sizeof(sort_param.unique)); bzero((char*) sort_param.unique,sizeof(sort_param.unique));
sort_param.key_length=share->rec_reflength; sort_param.key_length=share->rec_reflength;
for (i=0 ; keyseg[i].type != HA_KEYTYPE_END; i++) for (i=0 ; keyseg[i].type != HA_KEYTYPE_END; i++)
...@@ -2255,6 +2256,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, ...@@ -2255,6 +2256,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
{ {
sort_param[i].key=key; sort_param[i].key=key;
sort_param[i].keyinfo=share->keyinfo+key; sort_param[i].keyinfo=share->keyinfo+key;
sort_param[i].seg=sort_param[i].keyinfo->seg;
if (!(((ulonglong) 1 << key) & key_map)) if (!(((ulonglong) 1 << key) & key_map))
{ {
/* Remember old statistics for key */ /* Remember old statistics for key */
...@@ -2292,7 +2294,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, ...@@ -2292,7 +2294,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
(share->base.pack_reclength * i)); (share->base.pack_reclength * i));
sort_param[i].key_length=share->rec_reflength; sort_param[i].key_length=share->rec_reflength;
for (keyseg=sort_param[i].keyinfo->seg; keyseg->type != HA_KEYTYPE_END; for (keyseg=sort_param[i].seg; keyseg->type != HA_KEYTYPE_END;
keyseg++) keyseg++)
{ {
sort_param[i].key_length+=keyseg->length; sort_param[i].key_length+=keyseg->length;
...@@ -3051,7 +3053,7 @@ static int sort_key_cmp(MI_SORT_PARAM *sort_param, const void *a, ...@@ -3051,7 +3053,7 @@ static int sort_key_cmp(MI_SORT_PARAM *sort_param, const void *a,
const void *b) const void *b)
{ {
uint not_used; uint not_used;
return (ha_key_cmp(sort_param->keyinfo->seg, *((uchar**) a), *((uchar**) b), return (ha_key_cmp(sort_param->seg, *((uchar**) a), *((uchar**) b),
USE_WHOLE_KEY, SEARCH_SAME,&not_used)); USE_WHOLE_KEY, SEARCH_SAME,&not_used));
} /* sort_key_cmp */ } /* sort_key_cmp */
...@@ -3066,7 +3068,7 @@ static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a) ...@@ -3066,7 +3068,7 @@ static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a)
if (sort_info->key_block->inited) if (sort_info->key_block->inited)
{ {
cmp=ha_key_cmp(sort_param->keyinfo->seg,sort_info->key_block->lastkey, cmp=ha_key_cmp(sort_param->seg,sort_info->key_block->lastkey,
(uchar*) a, USE_WHOLE_KEY,SEARCH_FIND | SEARCH_UPDATE, (uchar*) a, USE_WHOLE_KEY,SEARCH_FIND | SEARCH_UPDATE,
&diff_pos); &diff_pos);
sort_param->unique[diff_pos-1]++; sort_param->unique[diff_pos-1]++;
...@@ -3091,7 +3093,7 @@ static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a) ...@@ -3091,7 +3093,7 @@ static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a)
llbuff2)); llbuff2));
param->testflag|=T_RETRY_WITHOUT_QUICK; param->testflag|=T_RETRY_WITHOUT_QUICK;
if (sort_info->param->testflag & T_VERBOSE) if (sort_info->param->testflag & T_VERBOSE)
_mi_print_key(stdout,sort_param->keyinfo->seg,(uchar*) a, USE_WHOLE_KEY); _mi_print_key(stdout,sort_param->seg,(uchar*) a, USE_WHOLE_KEY);
return (sort_delete_record(sort_param)); return (sort_delete_record(sort_param));
} }
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -3182,7 +3184,7 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a) ...@@ -3182,7 +3184,7 @@ static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a)
get_key_full_length_rdonly(val_off, ft_buf->lastkey); get_key_full_length_rdonly(val_off, ft_buf->lastkey);
if (val_off == a_len && if (val_off == a_len &&
mi_compare_text(sort_param->keyinfo->seg->charset, mi_compare_text(sort_param->seg->charset,
((uchar *)a)+1,a_len-1, ((uchar *)a)+1,a_len-1,
ft_buf->lastkey+1,val_off-1, 0)==0) ft_buf->lastkey+1,val_off-1, 0)==0)
{ {
......
...@@ -295,6 +295,7 @@ typedef struct st_mi_sort_param ...@@ -295,6 +295,7 @@ typedef struct st_mi_sort_param
uint maxbuffers, keys, find_length, sort_keys_length; uint maxbuffers, keys, find_length, sort_keys_length;
my_bool fix_datafile, master; my_bool fix_datafile, master;
MI_KEYDEF *keyinfo; MI_KEYDEF *keyinfo;
HA_KEYSEG *seg;
SORT_INFO *sort_info; SORT_INFO *sort_info;
uchar **sort_keys; uchar **sort_keys;
byte *rec_buff; byte *rec_buff;
......
...@@ -111,7 +111,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ...@@ -111,7 +111,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
DBUG_ENTER("_create_index_by_sort"); DBUG_ENTER("_create_index_by_sort");
DBUG_PRINT("enter",("sort_length: %d", info->key_length)); DBUG_PRINT("enter",("sort_length: %d", info->key_length));
if (info->keyinfo->flag && HA_VAR_LENGTH_KEY) if (info->keyinfo->flag & HA_VAR_LENGTH_KEY)
{ {
info->write_keys=write_keys_varlen; info->write_keys=write_keys_varlen;
info->read_to_buffer=read_to_buffer_varlen; info->read_to_buffer=read_to_buffer_varlen;
...@@ -622,7 +622,7 @@ inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs) ...@@ -622,7 +622,7 @@ inline int my_var_write(MI_SORT_PARAM *info,IO_CACHE *to_file,char *bufs)
{ {
int err; int err;
uint16 len = _mi_keylength(info->keyinfo,bufs); uint16 len = _mi_keylength(info->keyinfo,bufs);
if ((err= my_b_write(to_file,(byte*)&len,sizeof(len)))) if ((err= my_b_write(to_file,(byte*)&len,sizeof(len))))
return (err); return (err);
if ((err= my_b_write(to_file,(byte*)bufs,(uint) len))) if ((err= my_b_write(to_file,(byte*)bufs,(uint) len)))
...@@ -641,7 +641,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_k ...@@ -641,7 +641,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_k
qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp, qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp,
info); info);
if (!my_b_inited(tempfile) && if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST", open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
DISK_BUFFER_SIZE, info->sort_info->param->myf_rw)) DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
DBUG_RETURN(1); /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */
...@@ -650,7 +650,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_k ...@@ -650,7 +650,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, register uchar **sort_k
for (end=sort_keys+count ; sort_keys != end ; sort_keys++) for (end=sort_keys+count ; sort_keys != end ; sort_keys++)
{ {
if ((err= my_var_write(info,tempfile,*sort_keys))) if ((err= my_var_write(info,tempfile,*sort_keys)))
DBUG_RETURN(err); DBUG_RETURN(err);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} /* write_keys_varlen */ } /* write_keys_varlen */
...@@ -777,7 +777,7 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek, ...@@ -777,7 +777,7 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
uint16 length_of_key = 0; uint16 length_of_key = 0;
uint idx; uint idx;
uchar *buffp; uchar *buffp;
if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count))) if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count)))
{ {
buffp = buffpek->base; buffp = buffpek->base;
...@@ -786,11 +786,11 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek, ...@@ -786,11 +786,11 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek,
{ {
if (my_pread(fromfile->file,(byte*)&length_of_key,sizeof(length_of_key), if (my_pread(fromfile->file,(byte*)&length_of_key,sizeof(length_of_key),
buffpek->file_pos,MYF_RW)) buffpek->file_pos,MYF_RW))
return((uint) -1); return((uint) -1);
buffpek->file_pos+=sizeof(length_of_key); buffpek->file_pos+=sizeof(length_of_key);
if (my_pread(fromfile->file,(byte*) buffp,length_of_key, if (my_pread(fromfile->file,(byte*) buffp,length_of_key,
buffpek->file_pos,MYF_RW)) buffpek->file_pos,MYF_RW))
return((uint) -1); return((uint) -1);
buffpek->file_pos+=length_of_key; buffpek->file_pos+=length_of_key;
buffp = buffp + sort_length; buffp = buffp + sort_length;
} }
......
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