mirror of
https://github.com/MariaDB/server.git
synced 2026-05-08 08:04:29 +02:00
fixed bug with FULLTEXT and ORDER BY
include/ft_global.h: fixed bug with ORDER BY sql/ha_myisam.cc: fixed bug with ORDER BY sql/item_func.cc: fixed bug with ORDER BY sql/item_func.h: fixed bug with ORDER BY sql/sql_select.cc: fixed bug with ORDER BY
This commit is contained in:
parent
30cab56229
commit
2122fc2603
5 changed files with 34 additions and 28 deletions
|
|
@ -47,8 +47,9 @@ void ft_free_stopwords(void);
|
||||||
|
|
||||||
FT_DOCLIST * ft_init_search(void *, uint, byte *, uint, my_bool);
|
FT_DOCLIST * ft_init_search(void *, uint, byte *, uint, my_bool);
|
||||||
int ft_read_next(FT_DOCLIST *, char *);
|
int ft_read_next(FT_DOCLIST *, char *);
|
||||||
#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0))
|
#define ft_close_search(handler) my_free(((gptr)(handler)),MYF(0))
|
||||||
#define ft_get_relevance(handler) ((handler)->doc[(handler)->curdoc].weight)
|
#define ft_get_relevance(handler) ((handler)->doc[(handler)->curdoc].weight)
|
||||||
|
#define ft_reinit_search(handler) (((FT_DOCLIST *)(handler))->curdoc=-1)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1088,7 +1088,8 @@ int ha_myisam::ft_read(byte * buf)
|
||||||
|
|
||||||
thread_safe_increment(ha_read_next_count,&LOCK_status); // why ?
|
thread_safe_increment(ha_read_next_count,&LOCK_status); // why ?
|
||||||
|
|
||||||
error=ft_read_next((FT_DOCLIST *) ft_handler,(char*) buf);
|
if (error=ft_read_next((FT_DOCLIST *) ft_handler,(char*) buf))
|
||||||
|
ft_handler=NULL; // Magic here ! See Item_func_match::val()
|
||||||
|
|
||||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||||
return error;
|
return error;
|
||||||
|
|
|
||||||
|
|
@ -1846,43 +1846,46 @@ double Item_func_match::val()
|
||||||
|
|
||||||
if (join_key)
|
if (join_key)
|
||||||
{
|
{
|
||||||
return ft_get_relevance(ft_handler);
|
if (table->file->ft_handler)
|
||||||
|
return ft_get_relevance(ft_handler);
|
||||||
|
|
||||||
|
join_key=0; // Magic here ! See ha_myisam::ft_read()
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/* we'll have to find ft_relevance manually in ft_handler array */
|
||||||
|
|
||||||
|
int a,b,c;
|
||||||
|
FT_DOC *docs=ft_handler->doc;
|
||||||
|
my_off_t docid=table->file->row_position();
|
||||||
|
|
||||||
|
if ((null_value=(docid==HA_OFFSET_ERROR)))
|
||||||
|
return 0.0;
|
||||||
|
|
||||||
|
// Assuming docs[] is sorted by dpos...
|
||||||
|
|
||||||
|
for (a=0, b=ft_handler->ndocs, c=(a+b)/2; b-a>1; c=(a+b)/2)
|
||||||
{
|
{
|
||||||
/* we'll have to find ft_relevance manually in ft_handler array */
|
if (docs[c].dpos > docid)
|
||||||
|
b=c;
|
||||||
int a,b,c;
|
|
||||||
FT_DOC *docs=ft_handler->doc;
|
|
||||||
my_off_t docid=table->file->row_position();
|
|
||||||
|
|
||||||
if ((null_value=(docid==HA_OFFSET_ERROR)))
|
|
||||||
return 0.0;
|
|
||||||
|
|
||||||
// Assuming docs[] is sorted by dpos...
|
|
||||||
|
|
||||||
for (a=0, b=ft_handler->ndocs, c=(a+b)/2; b-a>1; c=(a+b)/2)
|
|
||||||
{
|
|
||||||
if (docs[c].dpos > docid)
|
|
||||||
b=c;
|
|
||||||
else
|
|
||||||
a=c;
|
|
||||||
}
|
|
||||||
if (docs[a].dpos == docid)
|
|
||||||
return docs[a].weight;
|
|
||||||
else
|
else
|
||||||
return 0.0;
|
a=c;
|
||||||
}
|
}
|
||||||
|
if (docs[a].dpos == docid)
|
||||||
|
return docs[a].weight;
|
||||||
|
else
|
||||||
|
return 0.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item_func_match::init_search()
|
void Item_func_match::init_search(bool no_order)
|
||||||
{
|
{
|
||||||
if (ft_handler)
|
if (ft_handler)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (master)
|
if (master)
|
||||||
{
|
{
|
||||||
master->init_search();
|
join_key=master->join_key=join_key|master->join_key;
|
||||||
|
master->init_search(no_order);
|
||||||
ft_handler=master->ft_handler;
|
ft_handler=master->ft_handler;
|
||||||
join_key=master->join_key;
|
join_key=master->join_key;
|
||||||
return;
|
return;
|
||||||
|
|
@ -1894,7 +1897,8 @@ void Item_func_match::init_search()
|
||||||
|
|
||||||
ft_tmp=key_item()->val_str(&tmp2);
|
ft_tmp=key_item()->val_str(&tmp2);
|
||||||
ft_handler=(FT_DOCLIST *)
|
ft_handler=(FT_DOCLIST *)
|
||||||
table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length(), join_key);
|
table->file->ft_init_ext(key, (byte*) ft_tmp->ptr(), ft_tmp->length(),
|
||||||
|
join_key && !no_order);
|
||||||
|
|
||||||
if (join_key)
|
if (join_key)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -863,5 +863,5 @@ public:
|
||||||
longlong val_int() { return val()!=0.0; }
|
longlong val_int() { return val()!=0.0; }
|
||||||
|
|
||||||
bool fix_index();
|
bool fix_index();
|
||||||
void init_search();
|
void init_search(bool no_order);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -532,7 +532,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
|
||||||
|
|
||||||
while ((ifm=li++))
|
while ((ifm=li++))
|
||||||
{
|
{
|
||||||
ifm->init_search();
|
ifm->init_search(test(order));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Create a tmp table if distinct or if the sort is too complicated */
|
/* Create a tmp table if distinct or if the sort is too complicated */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue