Commit f4565513 authored by unknown's avatar unknown

BUG#5327 - mi_sort_index() of 2-level tree

parent f7f85eb6
......@@ -1585,7 +1585,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name)
int old_lock;
MYISAM_SHARE *share=info->s;
MI_STATE_INFO old_state;
DBUG_ENTER("sort_index");
DBUG_ENTER("mi_sort_index");
if (!(param->testflag & T_SILENT))
printf("- Sorting index for MyISAM-table '%s'\n",name);
......@@ -1664,7 +1664,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name)
err2:
VOID(my_delete(param->temp_filename,MYF(MY_WME)));
DBUG_RETURN(-1);
} /* sort_index */
} /* mi_sort_index */
/* Sort records recursive using one index */
......@@ -1672,7 +1672,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name)
static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
my_off_t pagepos, File new_file)
{
uint length,nod_flag,used_length;
uint length,nod_flag,used_length, key_length;
uchar *buff,*keypos,*endpos;
uchar key[MI_MAX_POSSIBLE_KEY_BUFF];
my_off_t new_page_pos,next_page;
......@@ -1693,7 +1693,7 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
llstr(pagepos,llbuff));
goto err;
}
if ((nod_flag=mi_test_if_nod(buff)))
if ((nod_flag=mi_test_if_nod(buff)) || keyinfo->flag & HA_FULLTEXT)
{
used_length=mi_getint(buff);
keypos=buff+2+nod_flag;
......@@ -1704,7 +1704,7 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
{
next_page=_mi_kpos(nod_flag,keypos);
_mi_kpointer(info,keypos-nod_flag,param->new_file_pos); /* Save new pos */
if (sort_one_index(param,info,keyinfo,next_page, new_file))
if (sort_one_index(param,info,keyinfo,next_page,new_file))
{
DBUG_PRINT("error",("From page: %ld, keyoffset: %d used_length: %d",
(ulong) pagepos, (int) (keypos - buff),
......@@ -1714,11 +1714,25 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
}
}
if (keypos >= endpos ||
((*keyinfo->get_key)(keyinfo,nod_flag,&keypos,key)) == 0)
(key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&keypos,key)) == 0)
break;
#ifdef EXTRA_DEBUG
assert(keypos <= endpos);
#endif
DBUG_ASSERT(keypos <= endpos);
if (keyinfo->flag & HA_FULLTEXT)
{
uint off;
int subkeys;
get_key_full_length_rdonly(off, key);
subkeys=ft_sintXkorr(key+off);
if (subkeys < 0)
{
next_page= _mi_dpos(info,0,key+key_length);
_mi_dpointer(info,keypos-nod_flag-info->s->rec_reflength,
param->new_file_pos); /* Save new pos */
if (sort_one_index(param,info,&info->s->ft2_keyinfo,
next_page,new_file))
goto err;
}
}
}
}
......
......@@ -7,6 +7,15 @@ FULLTEXT KEY (a)
repair table t1 quick;
Table Op Msg_type Msg_text
test.t1 repair status OK
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select count(*) from t1 where match a against ('aaaxxx');
count(*)
260
......
......@@ -44,6 +44,9 @@ while ($1)
# converting to two-level
repair table t1 quick;
check table t1;
optimize table t1; # BUG#5327 - mi_sort_index() of 2-level tree
check table t1;
select count(*) from t1 where match a against ('aaaxxx');
select count(*) from t1 where match a against ('aaayyy');
......@@ -102,6 +105,11 @@ CREATE TABLE t1 (
FULLTEXT KEY (a)
) ENGINE=MyISAM;
#
# now same as about but w/o repair table
# 2-level tree created by mi_write
#
# two-level entry, second-level tree with depth 2
--disable_query_log
let $1=260;
......
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