Commit 08384a3a authored by serg@serg.mysql.com's avatar serg@serg.mysql.com

getting rid of default_charset_info

parent a7310464
...@@ -84,6 +84,7 @@ typedef struct st_ft_info { ...@@ -84,6 +84,7 @@ typedef struct st_ft_info {
struct _ft_vft *please; struct _ft_vft *please;
MI_INFO *info; MI_INFO *info;
uint keynr; uint keynr;
CHARSET_INFO *charset;
enum { UNINITIALIZED, READY, INDEX_SEARCH, INDEX_DONE /*, SCAN*/ } state; enum { UNINITIALIZED, READY, INDEX_SEARCH, INDEX_DONE /*, SCAN*/ } state;
uint with_scan; uint with_scan;
FTB_EXPR *root; FTB_EXPR *root;
...@@ -101,11 +102,11 @@ int FTB_WORD_cmp(void *v __attribute__((unused)), FTB_WORD *a, FTB_WORD *b) ...@@ -101,11 +102,11 @@ int FTB_WORD_cmp(void *v __attribute__((unused)), FTB_WORD *a, FTB_WORD *b)
return i; return i;
} }
int FTB_WORD_cmp_list(void *v __attribute__((unused)), FTB_WORD **a, FTB_WORD **b) int FTB_WORD_cmp_list(CHARSET_INFO *cs, FTB_WORD **a, FTB_WORD **b)
{ {
/* ORDER BY word DESC, ndepth DESC */ /* ORDER BY word DESC, ndepth DESC */
int i=_mi_compare_text(default_charset_info, (*b)->word+1,(*b)->len-1, int i=_mi_compare_text(cs, (*b)->word+1,(*b)->len-1,
(*a)->word+1,(*a)->len-1,0); (*a)->word+1,(*a)->len-1,0);
if (!i) if (!i)
i=CMP_NUM((*b)->ndepth,(*a)->ndepth); i=CMP_NUM((*b)->ndepth,(*a)->ndepth);
return i; return i;
...@@ -203,7 +204,7 @@ void _ftb_init_index_search(FT_INFO *ftb) ...@@ -203,7 +204,7 @@ void _ftb_init_index_search(FT_INFO *ftb)
SEARCH_FIND | SEARCH_BIGGER, keyroot); SEARCH_FIND | SEARCH_BIGGER, keyroot);
if (!r) if (!r)
{ {
r=_mi_compare_text(default_charset_info, r=_mi_compare_text(ftb->charset,
info->lastkey + (ftbw->flags&FTB_FLAG_TRUNC), info->lastkey + (ftbw->flags&FTB_FLAG_TRUNC),
ftbw->len - (ftbw->flags&FTB_FLAG_TRUNC), ftbw->len - (ftbw->flags&FTB_FLAG_TRUNC),
ftbw->word + (ftbw->flags&FTB_FLAG_TRUNC), ftbw->word + (ftbw->flags&FTB_FLAG_TRUNC),
...@@ -241,6 +242,9 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, ...@@ -241,6 +242,9 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query,
ftb->state=UNINITIALIZED; ftb->state=UNINITIALIZED;
ftb->info=info; ftb->info=info;
ftb->keynr=keynr; ftb->keynr=keynr;
ftb->charset= ((keynr==NO_SUCH_KEY) ?
default_charset_info :
info->s->keyinfo[keynr].seg->charset);
ftb->with_scan=0; ftb->with_scan=0;
init_alloc_root(&ftb->mem_root, 1024, 1024); init_alloc_root(&ftb->mem_root, 1024, 1024);
...@@ -265,7 +269,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, ...@@ -265,7 +269,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query,
sizeof(FTB_WORD *)*ftb->queue.elements); sizeof(FTB_WORD *)*ftb->queue.elements);
memcpy(ftb->list, ftb->queue.root+1, sizeof(FTB_WORD *)*ftb->queue.elements); memcpy(ftb->list, ftb->queue.root+1, sizeof(FTB_WORD *)*ftb->queue.elements);
qsort2(ftb->list, ftb->queue.elements, sizeof(FTB_WORD *), qsort2(ftb->list, ftb->queue.elements, sizeof(FTB_WORD *),
(qsort2_cmp)FTB_WORD_cmp_list, 0); (qsort2_cmp)FTB_WORD_cmp_list, ftb->charset);
if (ftb->queue.elements<2) ftb->with_scan=0; if (ftb->queue.elements<2) ftb->with_scan=0;
ftb->state=READY; ftb->state=READY;
return ftb; return ftb;
...@@ -359,7 +363,7 @@ int ft_boolean_read_next(FT_INFO *ftb, char *record) ...@@ -359,7 +363,7 @@ int ft_boolean_read_next(FT_INFO *ftb, char *record)
SEARCH_BIGGER , keyroot); SEARCH_BIGGER , keyroot);
if (!r) if (!r)
{ {
r=_mi_compare_text(default_charset_info, r=_mi_compare_text(ftb->charset,
info->lastkey + (ftbw->flags&FTB_FLAG_TRUNC), info->lastkey + (ftbw->flags&FTB_FLAG_TRUNC),
ftbw->len - (ftbw->flags&FTB_FLAG_TRUNC), ftbw->len - (ftbw->flags&FTB_FLAG_TRUNC),
ftbw->word + (ftbw->flags&FTB_FLAG_TRUNC), ftbw->word + (ftbw->flags&FTB_FLAG_TRUNC),
...@@ -443,7 +447,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) ...@@ -443,7 +447,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length)
for (a=0, b=ftb->queue.elements, c=(a+b)/2; b-a>1; c=(a+b)/2) for (a=0, b=ftb->queue.elements, c=(a+b)/2; b-a>1; c=(a+b)/2)
{ {
ftbw=(FTB_WORD *)(ftb->list[c]); ftbw=(FTB_WORD *)(ftb->list[c]);
if (_mi_compare_text(default_charset_info, word.pos,word.len, if (_mi_compare_text(ftb->charset, word.pos,word.len,
(uchar*) ftbw->word+1,ftbw->len-1, (uchar*) ftbw->word+1,ftbw->len-1,
(ftbw->flags&FTB_FLAG_TRUNC) ) >0) (ftbw->flags&FTB_FLAG_TRUNC) ) >0)
b=c; b=c;
...@@ -453,7 +457,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) ...@@ -453,7 +457,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length)
for (; c>=0; c--) for (; c>=0; c--)
{ {
ftbw=(FTB_WORD *)(ftb->list[c]); ftbw=(FTB_WORD *)(ftb->list[c]);
if (_mi_compare_text(default_charset_info, word.pos,word.len, if (_mi_compare_text(ftb->charset, word.pos,word.len,
(uchar*) ftbw->word+1,ftbw->len-1, (uchar*) ftbw->word+1,ftbw->len-1,
(ftbw->flags&FTB_FLAG_TRUNC) )) (ftbw->flags&FTB_FLAG_TRUNC) ))
break; break;
......
...@@ -37,6 +37,7 @@ struct st_ft_info { ...@@ -37,6 +37,7 @@ struct st_ft_info {
typedef struct st_all_in_one { typedef struct st_all_in_one {
MI_INFO *info; MI_INFO *info;
uint keynr; uint keynr;
CHARSET_INFO *charset;
uchar *keybuff; uchar *keybuff;
MI_KEYDEF *keyinfo; MI_KEYDEF *keyinfo;
my_off_t key_root; my_off_t key_root;
...@@ -93,7 +94,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) ...@@ -93,7 +94,7 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
while(!r) while(!r)
{ {
if (_mi_compare_text(default_charset_info, if (_mi_compare_text(aio->charset,
aio->info->lastkey,keylen, aio->info->lastkey,keylen,
aio->keybuff,keylen,0)) break; aio->keybuff,keylen,0)) break;
...@@ -184,8 +185,9 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query, ...@@ -184,8 +185,9 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query,
aio.info=info; aio.info=info;
aio.keynr=keynr; aio.keynr=keynr;
aio.keybuff=info->lastkey+info->s->base.max_key_length;
aio.keyinfo=info->s->keyinfo+keynr; aio.keyinfo=info->s->keyinfo+keynr;
aio.charset=aio.keyinfo->seg->charset;
aio.keybuff=info->lastkey+info->s->base.max_key_length;
aio.key_root=info->s->state.key_root[keynr]; aio.key_root=info->s->state.key_root[keynr];
bzero(&allocated_wtree,sizeof(allocated_wtree)); bzero(&allocated_wtree,sizeof(allocated_wtree));
...@@ -193,6 +195,7 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query, ...@@ -193,6 +195,7 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query,
init_tree(&aio.dtree,0,0,sizeof(FT_SUPERDOC),(qsort_cmp2)&FT_SUPERDOC_cmp,0, init_tree(&aio.dtree,0,0,sizeof(FT_SUPERDOC),(qsort_cmp2)&FT_SUPERDOC_cmp,0,
NULL, NULL); NULL, NULL);
ft_parse_init(&allocated_wtree, aio.charset);
if(ft_parse(&allocated_wtree,query,query_len)) if(ft_parse(&allocated_wtree,query,query_len))
goto err; goto err;
......
...@@ -35,12 +35,10 @@ typedef struct st_ft_docstat { ...@@ -35,12 +35,10 @@ typedef struct st_ft_docstat {
} FT_DOCSTAT; } FT_DOCSTAT;
static int FT_WORD_cmp(void* cmp_arg, FT_WORD *w1, FT_WORD *w2) static int FT_WORD_cmp(CHARSET_INFO* cs, FT_WORD *w1, FT_WORD *w2)
{ {
return _mi_compare_text(default_charset_info, return _mi_compare_text(cs, (uchar*) w1->pos, w1->len,
(uchar*) w1->pos, w1->len, (uchar*) w2->pos, w2->len, 0);
(uchar*) w2->pos, w2->len,
(my_bool) (cmp_arg != 0));
} }
static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat) static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat)
...@@ -207,16 +205,17 @@ byte ft_simple_get_word(byte **start, byte *end, FT_WORD *word) ...@@ -207,16 +205,17 @@ byte ft_simple_get_word(byte **start, byte *end, FT_WORD *word)
return 0; return 0;
} }
void ft_parse_init(TREE *wtree, CHARSET_INFO *cs)
{
if (!is_tree_inited(wtree))
init_tree(wtree,0,0,sizeof(FT_WORD),(qsort_cmp2)&FT_WORD_cmp,0,NULL, cs);
}
int ft_parse(TREE *wtree, byte *doc, int doclen) int ft_parse(TREE *wtree, byte *doc, int doclen)
{ {
byte *end=doc+doclen; byte *end=doc+doclen;
FT_WORD w; FT_WORD w;
if (!is_tree_inited(wtree))
{
init_tree(wtree,0,0,sizeof(FT_WORD),(qsort_cmp2)&FT_WORD_cmp,0,NULL, NULL);
}
while (ft_simple_get_word(&doc,end,&w)) while (ft_simple_get_word(&doc,end,&w))
{ {
if (!tree_insert(wtree, &w, 0)) if (!tree_insert(wtree, &w, 0))
......
...@@ -90,16 +90,13 @@ uint _mi_ft_parse(TREE *parsed, MI_INFO *info, uint keynr, const byte *record) ...@@ -90,16 +90,13 @@ uint _mi_ft_parse(TREE *parsed, MI_INFO *info, uint keynr, const byte *record)
FT_SEG_ITERATOR ftsi; FT_SEG_ITERATOR ftsi;
_mi_ft_segiterator_init(info, keynr, record, &ftsi); _mi_ft_segiterator_init(info, keynr, record, &ftsi);
ft_parse_init(parsed, info->s->keyinfo[keynr].seg->charset);
while (_mi_ft_segiterator(&ftsi)) while (_mi_ft_segiterator(&ftsi))
if (ftsi.pos) if (ftsi.pos)
if (ft_parse(parsed, (byte *)ftsi.pos, ftsi.len)) if (ft_parse(parsed, (byte *)ftsi.pos, ftsi.len))
return 1; return 1;
/* Handle the case where all columns are NULL */ return 0;
if (!is_tree_inited(parsed) && ft_parse(parsed, (byte*) "", 0))
return 1;
else
return 0;
} }
FT_WORD * _mi_ft_parserecord(MI_INFO *info, uint keynr, FT_WORD * _mi_ft_parserecord(MI_INFO *info, uint keynr,
...@@ -153,6 +150,7 @@ static int _mi_ft_erase(MI_INFO *info, uint keynr, byte *keybuf, FT_WORD *wlist, ...@@ -153,6 +150,7 @@ static int _mi_ft_erase(MI_INFO *info, uint keynr, byte *keybuf, FT_WORD *wlist,
int _mi_ft_cmp(MI_INFO *info, uint keynr, const byte *rec1, const byte *rec2) int _mi_ft_cmp(MI_INFO *info, uint keynr, const byte *rec1, const byte *rec2)
{ {
FT_SEG_ITERATOR ftsi1, ftsi2; FT_SEG_ITERATOR ftsi1, ftsi2;
CHARSET_INFO *cs=info->s->keyinfo[keynr].seg->charset;
_mi_ft_segiterator_init(info, keynr, rec1, &ftsi1); _mi_ft_segiterator_init(info, keynr, rec1, &ftsi1);
_mi_ft_segiterator_init(info, keynr, rec2, &ftsi2); _mi_ft_segiterator_init(info, keynr, rec2, &ftsi2);
...@@ -160,9 +158,8 @@ int _mi_ft_cmp(MI_INFO *info, uint keynr, const byte *rec1, const byte *rec2) ...@@ -160,9 +158,8 @@ int _mi_ft_cmp(MI_INFO *info, uint keynr, const byte *rec1, const byte *rec2)
{ {
if ((ftsi1.pos != ftsi2.pos) && if ((ftsi1.pos != ftsi2.pos) &&
(!ftsi1.pos || !ftsi2.pos || (!ftsi1.pos || !ftsi2.pos ||
_mi_compare_text(default_charset_info, _mi_compare_text(cs, (uchar*) ftsi1.pos,ftsi1.len,
(uchar*) ftsi1.pos,ftsi1.len, (uchar*) ftsi2.pos,ftsi2.len,0)))
(uchar*) ftsi2.pos,ftsi2.len,0)))
return THOSE_TWO_DAMN_KEYS_ARE_REALLY_DIFFERENT; return THOSE_TWO_DAMN_KEYS_ARE_REALLY_DIFFERENT;
} }
return GEE_THEY_ARE_ABSOLUTELY_IDENTICAL; return GEE_THEY_ARE_ABSOLUTELY_IDENTICAL;
...@@ -174,6 +171,7 @@ int _mi_ft_update(MI_INFO *info, uint keynr, byte *keybuf, ...@@ -174,6 +171,7 @@ int _mi_ft_update(MI_INFO *info, uint keynr, byte *keybuf,
{ {
int error= -1; int error= -1;
FT_WORD *oldlist,*newlist, *old_word, *new_word; FT_WORD *oldlist,*newlist, *old_word, *new_word;
CHARSET_INFO *cs=info->s->keyinfo[keynr].seg->charset;
uint key_length; uint key_length;
int cmp, cmp2; int cmp, cmp2;
...@@ -185,9 +183,8 @@ int _mi_ft_update(MI_INFO *info, uint keynr, byte *keybuf, ...@@ -185,9 +183,8 @@ int _mi_ft_update(MI_INFO *info, uint keynr, byte *keybuf,
error=0; error=0;
while(old_word->pos && new_word->pos) while(old_word->pos && new_word->pos)
{ {
cmp=_mi_compare_text(default_charset_info, cmp=_mi_compare_text(cs, (uchar*) old_word->pos,old_word->len,
(uchar*) old_word->pos,old_word->len, (uchar*) new_word->pos,new_word->len,0);
(uchar*) new_word->pos,new_word->len,0);
cmp2= cmp ? 0 : (fabs(old_word->weight - new_word->weight) > 1.e-5); cmp2= cmp ? 0 : (fabs(old_word->weight - new_word->weight) > 1.e-5);
if (cmp < 0 || cmp2) if (cmp < 0 || cmp2)
......
...@@ -130,6 +130,7 @@ void _mi_ft_segiterator_init(MI_INFO *, uint, const byte *, FT_SEG_ITERATOR *); ...@@ -130,6 +130,7 @@ void _mi_ft_segiterator_init(MI_INFO *, uint, const byte *, FT_SEG_ITERATOR *);
void _mi_ft_segiterator_dummy_init(const byte *, uint, FT_SEG_ITERATOR *); void _mi_ft_segiterator_dummy_init(const byte *, uint, FT_SEG_ITERATOR *);
uint _mi_ft_segiterator(FT_SEG_ITERATOR *); uint _mi_ft_segiterator(FT_SEG_ITERATOR *);
void ft_parse_init(TREE *, CHARSET_INFO *);
int ft_parse(TREE *, byte *, int); int ft_parse(TREE *, byte *, int);
FT_WORD * ft_linearize(/*MI_INFO *, uint, byte *, */TREE *); FT_WORD * ft_linearize(/*MI_INFO *, uint, byte *, */TREE *);
FT_WORD * _mi_ft_parserecord(MI_INFO *, uint, byte *, const byte *); FT_WORD * _mi_ft_parserecord(MI_INFO *, uint, byte *, const byte *);
......
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