MCPcopy Create free account
hub / github.com/MariaDB/server / add_ft_keys

Function add_ft_keys

sql/sql_select.cc:7503–7568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7501}
7502
7503static bool
7504add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
7505 JOIN_TAB *stat,COND *cond,table_map usable_tables)
7506{
7507 Item_func_match *cond_func=NULL;
7508
7509 if (!cond)
7510 return FALSE;
7511
7512 if (cond->type() == Item::FUNC_ITEM)
7513 {
7514 Item_func *func=(Item_func *)cond;
7515 Item_func::Functype functype= func->functype();
7516 if (functype == Item_func::FT_FUNC)
7517 cond_func=(Item_func_match *)cond;
7518 else if (func->argument_count() == 2)
7519 {
7520 Item *arg0=(Item *)(func->arguments()[0]),
7521 *arg1=(Item *)(func->arguments()[1]);
7522 if (arg1->const_item() && arg1->cols() == 1 &&
7523 arg0->type() == Item::FUNC_ITEM &&
7524 ((Item_func *) arg0)->functype() == Item_func::FT_FUNC &&
7525 ((functype == Item_func::GE_FUNC && arg1->val_real() > 0) ||
7526 (functype == Item_func::GT_FUNC && arg1->val_real() >=0)))
7527 cond_func= (Item_func_match *) arg0;
7528 else if (arg0->const_item() && arg0->cols() == 1 &&
7529 arg1->type() == Item::FUNC_ITEM &&
7530 ((Item_func *) arg1)->functype() == Item_func::FT_FUNC &&
7531 ((functype == Item_func::LE_FUNC && arg0->val_real() > 0) ||
7532 (functype == Item_func::LT_FUNC && arg0->val_real() >=0)))
7533 cond_func= (Item_func_match *) arg1;
7534 }
7535 }
7536 else if (cond->type() == Item::COND_ITEM)
7537 {
7538 List_iterator_fast<Item> li(*((Item_cond*) cond)->argument_list());
7539
7540 if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
7541 {
7542 Item *item;
7543 while ((item=li++))
7544 {
7545 if (add_ft_keys(keyuse_array,stat,item,usable_tables))
7546 return TRUE;
7547 }
7548 }
7549 }
7550
7551 if (!cond_func || cond_func->key == NO_SUCH_KEY ||
7552 !(usable_tables & cond_func->table->map))
7553 return FALSE;
7554
7555 KEYUSE keyuse;
7556 keyuse.table= cond_func->table;
7557 keyuse.val = cond_func;
7558 keyuse.key = cond_func->key;
7559 keyuse.keypart= FT_KEYPART;
7560 keyuse.used_tables=cond_func->key_item()->used_tables();

Callers 1

update_ref_and_keysFunction · 0.85

Calls 11

insert_dynamicFunction · 0.85
argumentsMethod · 0.80
argument_listMethod · 0.80
key_itemMethod · 0.80
typeMethod · 0.45
functypeMethod · 0.45
argument_countMethod · 0.45
const_itemMethod · 0.45
colsMethod · 0.45
val_realMethod · 0.45
used_tablesMethod · 0.45

Tested by

no test coverage detected