mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
sql_select.cc ft-optimization: AND, GT/LT/GE/LE
sql_select.cc EXPLAIN fulltext Makefile.am CLEANFILES corrected sql_show.cc SHOW CREATE now displays FULLTEXT keys properly
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
|
||||
"MAYBE_REF","ALL","range","index" };
|
||||
"MAYBE_REF","ALL","range","index","fulltext" };
|
||||
|
||||
static bool make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
|
||||
DYNAMIC_ARRAY *keyuse,List<Item_func_match> &ftfuncs);
|
||||
@@ -1280,15 +1280,54 @@ static void
|
||||
add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
|
||||
JOIN_TAB *stat,COND *cond,table_map usable_tables)
|
||||
{
|
||||
/* for now, handling only the simples WHERE MATCH (...) case */
|
||||
/* a bit more complex WHERE MATCH (...) > const,
|
||||
AND's and (perhaps) OR's are on the way SerG */
|
||||
Item_func_match *cond_func=NULL;
|
||||
|
||||
if (cond->type() != Item::FUNC_ITEM ||
|
||||
((Item_func*) cond)->functype() != Item_func::FT_FUNC)
|
||||
return;
|
||||
if (cond->type() == Item::FUNC_ITEM)
|
||||
{
|
||||
Item_func *func=(Item_func *)cond,
|
||||
*arg0=(Item_func *)(func->arguments()[0]),
|
||||
*arg1=(Item_func *)(func->arguments()[1]);
|
||||
|
||||
if (func->functype() == Item_func::FT_FUNC)
|
||||
cond_func=(Item_func_match *)cond;
|
||||
else if (arg0->type() == Item::FUNC_ITEM &&
|
||||
arg0->functype() == Item_func::FT_FUNC &&
|
||||
(func->functype() == Item_func::GE_FUNC ||
|
||||
func->functype() == Item_func::GT_FUNC) &&
|
||||
arg1->const_item() && arg1->val()>=0)
|
||||
cond_func=(Item_func_match *)arg0;
|
||||
else if (arg1->type() == Item::FUNC_ITEM &&
|
||||
arg1->functype() == Item_func::FT_FUNC &&
|
||||
(func->functype() == Item_func::LE_FUNC ||
|
||||
func->functype() == Item_func::LT_FUNC) &&
|
||||
arg0->const_item() && arg0->val()>=0)
|
||||
cond_func=(Item_func_match *)arg1;
|
||||
}
|
||||
else if (cond->type() == Item::COND_ITEM)
|
||||
{
|
||||
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
|
||||
|
||||
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
|
||||
{
|
||||
Item *item;
|
||||
/* I'm too lazy to implement proper recursive descent here,
|
||||
and anyway, nobody will use such a stupid queries
|
||||
that will require it :-)
|
||||
May be later...
|
||||
*/
|
||||
while ((item=li++))
|
||||
if (item->type() == Item::FUNC_ITEM &&
|
||||
((Item_func *)item)->functype() == Item_func::FT_FUNC)
|
||||
{
|
||||
cond_func=(Item_func_match *)item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!cond_func)
|
||||
return;
|
||||
|
||||
Item_func_match *cond_func= (Item_func_match *) cond;
|
||||
KEYUSE keyuse;
|
||||
|
||||
keyuse.table= cond_func->table;
|
||||
@@ -1936,8 +1975,7 @@ get_best_combination(JOIN *join)
|
||||
if (ftkey)
|
||||
{
|
||||
j->ref.items[0]=((Item_func*)(keyuse->val))->key_item();
|
||||
if (!keyuse->used_tables &&
|
||||
!(join->select_options & SELECT_DESCRIBE))
|
||||
if (!keyuse->used_tables)
|
||||
{
|
||||
// AFAIK key_buff is zeroed...
|
||||
// We don't need to free ft_tmp as the buffer will be freed atom.
|
||||
|
||||
Reference in New Issue
Block a user