#include <item_func.h>
Inheritance diagram for Item_func_match:


Public Member Functions | |
| Item_func_match (List< Item > &a, uint b) | |
| void | cleanup () |
| enum Functype | functype () const |
| const char * | func_name () const |
| void | update_used_tables () |
| table_map | not_null_tables () const |
| bool | fix_fields (THD *thd, Item **ref) |
| bool | eq (const Item *, bool binary_cmp) const |
| longlong | val_int () |
| double | val_real () |
| void | print (String *str) |
| bool | fix_index () |
| void | init_search (bool no_order) |
Public Attributes | |
| uint | key |
| uint | flags |
| bool | join_key |
| DTCollation | cmp_collation |
| FT_INFO * | ft_handler |
| TABLE * | table |
| Item_func_match * | master |
| Item * | concat |
| String | value |
| String | search_value |
Definition at line 1324 of file item_func.h.
Definition at line 1337 of file item_func.h.
01337 : Item_real_func(a), key(0), flags(b), 01338 join_key(0), ft_handler(0), table(0), master(0), concat(0) { }
| void Item_func_match::cleanup | ( | ) | [inline, virtual] |
Reimplemented from Item_result_field.
Definition at line 1339 of file item_func.h.
References Item_result_field::cleanup(), _ft_vft::close_search, concat, DBUG_ENTER, DBUG_VOID_RETURN, ft_handler, master, and st_ft_info::please.
01340 { 01341 DBUG_ENTER("Item_func_match"); 01342 Item_real_func::cleanup(); 01343 if (!master && ft_handler) 01344 ft_handler->please->close_search(ft_handler); 01345 ft_handler= 0; 01346 concat= 0; 01347 DBUG_VOID_RETURN; 01348 }
Here is the call graph for this function:

Reimplemented from Item_func.
Definition at line 4528 of file item_func.cc.
References Item::eq(), flags, Item_func::FT_FUNC, Item::FUNC_ITEM, key, Item_func::key_item(), table, and Item::type().
Referenced by setup_ftfuncs().
04529 { 04530 if (item->type() != FUNC_ITEM || 04531 ((Item_func*)item)->functype() != FT_FUNC || 04532 flags != ((Item_func_match*)item)->flags) 04533 return 0; 04534 04535 Item_func_match *ifm=(Item_func_match*) item; 04536 04537 if (key == ifm->key && table == ifm->table && 04538 key_item()->eq(ifm->key_item(), binary_cmp)) 04539 return 1; 04540 04541 return 0; 04542 }
Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from Item_func.
Definition at line 4389 of file item_func.cc.
References Item_func::agg_arg_collations_for_comparison(), Item_func::args, cmp_collation, Item::const_during_execution(), Item_func::const_item_cache, DBUG_ASSERT, ER_TABLE_CANT_HANDLE_FT, ER_WRONG_ARGUMENTS, st_table::field, Item::FIELD_ITEM, st_table::file, Item_func::fix_fields(), Item::fixed, flags, FT_BOOL, st_table::fulltext_searched, HA_CAN_FULLTEXT, handler::ha_table_flags(), join_key, key, LINT_INIT, Item::maybe_null, my_error(), MYF, NO_SUCH_KEY, PARAM_TABLE_BIT, Item::REF_ITEM, Field::table, table, TRUE, Item_ref::type(), Item::type(), Item::used_tables(), and Item_func::used_tables_cache.
04390 { 04391 DBUG_ASSERT(fixed == 0); 04392 Item *item; 04393 LINT_INIT(item); // Safe as arg_count is > 1 04394 04395 maybe_null=1; 04396 join_key=0; 04397 04398 /* 04399 const_item is assumed in quite a bit of places, so it would be difficult 04400 to remove; If it would ever to be removed, this should include 04401 modifications to find_best and auto_close as complement to auto_init code 04402 above. 04403 */ 04404 if (Item_func::fix_fields(thd, ref) || 04405 !args[0]->const_during_execution()) 04406 { 04407 my_error(ER_WRONG_ARGUMENTS,MYF(0),"AGAINST"); 04408 return TRUE; 04409 } 04410 04411 const_item_cache=0; 04412 for (uint i=1 ; i < arg_count ; i++) 04413 { 04414 item=args[i]; 04415 if (item->type() == Item::REF_ITEM) 04416 args[i]= item= *((Item_ref *)item)->ref; 04417 if (item->type() != Item::FIELD_ITEM) 04418 key=NO_SUCH_KEY; 04419 } 04420 /* 04421 Check that all columns come from the same table. 04422 We've already checked that columns in MATCH are fields so 04423 PARAM_TABLE_BIT can only appear from AGAINST argument. 04424 */ 04425 if ((used_tables_cache & ~PARAM_TABLE_BIT) != item->used_tables()) 04426 key=NO_SUCH_KEY; 04427 04428 if (key == NO_SUCH_KEY && !(flags & FT_BOOL)) 04429 { 04430 my_error(ER_WRONG_ARGUMENTS,MYF(0),"MATCH"); 04431 return TRUE; 04432 } 04433 table=((Item_field *)item)->field->table; 04434 if (!(table->file->ha_table_flags() & HA_CAN_FULLTEXT)) 04435 { 04436 my_error(ER_TABLE_CANT_HANDLE_FT, MYF(0)); 04437 return 1; 04438 } 04439 table->fulltext_searched=1; 04440 return agg_arg_collations_for_comparison(cmp_collation, 04441 args+1, arg_count-1, 0); 04442 }
Here is the call graph for this function:

| bool Item_func_match::fix_index | ( | ) |
Definition at line 4444 of file item_func.cc.
References Item_func::args, Field::eq(), ER, ER_FT_MATCHING_KEY_NOT_FOUND, err, Item_field::field, flags, st_key::flags, FT_BOOL, HA_FULLTEXT, Bitmap< 64 >::is_set(), key, st_table::key_info, st_table_share::keys, st_table::keys_in_use_for_query, MAX_KEY, my_message(), MYF, NO_SUCH_KEY, st_table::s, and table.
Referenced by setup_ftfuncs().
04445 { 04446 Item_field *item; 04447 uint ft_to_key[MAX_KEY], ft_cnt[MAX_KEY], fts=0, keynr; 04448 uint max_cnt=0, mkeys=0, i; 04449 04450 if (key == NO_SUCH_KEY) 04451 return 0; 04452 04453 if (!table) 04454 goto err; 04455 04456 for (keynr=0 ; keynr < table->s->keys ; keynr++) 04457 { 04458 if ((table->key_info[keynr].flags & HA_FULLTEXT) && 04459 (table->keys_in_use_for_query.is_set(keynr))) 04460 { 04461 ft_to_key[fts]=keynr; 04462 ft_cnt[fts]=0; 04463 fts++; 04464 } 04465 } 04466 04467 if (!fts) 04468 goto err; 04469 04470 for (i=1; i < arg_count; i++) 04471 { 04472 item=(Item_field*)args[i]; 04473 for (keynr=0 ; keynr < fts ; keynr++) 04474 { 04475 KEY *ft_key=&table->key_info[ft_to_key[keynr]]; 04476 uint key_parts=ft_key->key_parts; 04477 04478 for (uint part=0 ; part < key_parts ; part++) 04479 { 04480 if (item->field->eq(ft_key->key_part[part].field)) 04481 ft_cnt[keynr]++; 04482 } 04483 } 04484 } 04485 04486 for (keynr=0 ; keynr < fts ; keynr++) 04487 { 04488 if (ft_cnt[keynr] > max_cnt) 04489 { 04490 mkeys=0; 04491 max_cnt=ft_cnt[mkeys]=ft_cnt[keynr]; 04492 ft_to_key[mkeys]=ft_to_key[keynr]; 04493 continue; 04494 } 04495 if (max_cnt && ft_cnt[keynr] == max_cnt) 04496 { 04497 mkeys++; 04498 ft_cnt[mkeys]=ft_cnt[keynr]; 04499 ft_to_key[mkeys]=ft_to_key[keynr]; 04500 continue; 04501 } 04502 } 04503 04504 for (keynr=0 ; keynr <= mkeys ; keynr++) 04505 { 04506 // partial keys doesn't work 04507 if (max_cnt < arg_count-1 || 04508 max_cnt < table->key_info[ft_to_key[keynr]].key_parts) 04509 continue; 04510 04511 key=ft_to_key[keynr]; 04512 04513 return 0; 04514 } 04515 04516 err: 04517 if (flags & FT_BOOL) 04518 { 04519 key=NO_SUCH_KEY; 04520 return 0; 04521 } 04522 my_message(ER_FT_MATCHING_KEY_NOT_FOUND, 04523 ER(ER_FT_MATCHING_KEY_NOT_FOUND), MYF(0)); 04524 return 1; 04525 }
Here is the call graph for this function:

Here is the caller graph for this function:

| const char* Item_func_match::func_name | ( | ) | const [inline, virtual] |
| enum Functype Item_func_match::functype | ( | ) | const [inline, virtual] |
Reimplemented from Item_func.
Definition at line 1349 of file item_func.h.
References Item_func::FT_FUNC.
01349 { return FT_FUNC; }
| void Item_func_match::init_search | ( | bool | no_order | ) |
Definition at line 4328 of file item_func.cc.
References Item_func::args, String::charset(), cmp_collation, DTCollation::collation, concat, String::copy(), DBUG_ENTER, DBUG_VOID_RETURN, st_table::file, flags, handler::ft_handler, ft_handler, handler::ft_init_ext(), FT_SORTED, init_search(), join_key, key, Item_func::key_item(), String::length(), master, NO_SUCH_KEY, String::ptr(), List< T >::push_back(), Item::quick_fix_field(), search_value, String::set(), table, and Item_real_func::val_str().
Referenced by init_ftfuncs(), and init_search().
04329 { 04330 DBUG_ENTER("Item_func_match::init_search"); 04331 04332 /* Check if init_search() has been called before */ 04333 if (ft_handler) 04334 DBUG_VOID_RETURN; 04335 04336 if (key == NO_SUCH_KEY) 04337 { 04338 List<Item> fields; 04339 fields.push_back(new Item_string(" ",1, cmp_collation.collation)); 04340 for (uint i=1; i < arg_count; i++) 04341 fields.push_back(args[i]); 04342 concat=new Item_func_concat_ws(fields); 04343 /* 04344 Above function used only to get value and do not need fix_fields for it: 04345 Item_string - basic constant 04346 fields - fix_fields() was already called for this arguments 04347 Item_func_concat_ws - do not need fix_fields() to produce value 04348 */ 04349 concat->quick_fix_field(); 04350 } 04351 04352 if (master) 04353 { 04354 join_key=master->join_key=join_key|master->join_key; 04355 master->init_search(no_order); 04356 ft_handler=master->ft_handler; 04357 join_key=master->join_key; 04358 DBUG_VOID_RETURN; 04359 } 04360 04361 String *ft_tmp= 0; 04362 04363 // MATCH ... AGAINST (NULL) is meaningless, but possible 04364 if (!(ft_tmp=key_item()->val_str(&value))) 04365 { 04366 ft_tmp= &value; 04367 value.set("",0,cmp_collation.collation); 04368 } 04369 04370 if (ft_tmp->charset() != cmp_collation.collation) 04371 { 04372 uint dummy_errors; 04373 search_value.copy(ft_tmp->ptr(), ft_tmp->length(), ft_tmp->charset(), 04374 cmp_collation.collation, &dummy_errors); 04375 ft_tmp= &search_value; 04376 } 04377 04378 if (join_key && !no_order) 04379 flags|=FT_SORTED; 04380 ft_handler=table->file->ft_init_ext(flags, key, ft_tmp); 04381 04382 if (join_key) 04383 table->file->ft_handler=ft_handler; 04384 04385 DBUG_VOID_RETURN; 04386 }
Here is the call graph for this function:

Here is the caller graph for this function:

| table_map Item_func_match::not_null_tables | ( | ) | const [inline, virtual] |
| void Item_func_match::print | ( | String * | str | ) | [virtual] |
Reimplemented from Item_func.
Definition at line 4574 of file item_func.cc.
References String::append(), Item_func::args, flags, FT_BOOL, FT_EXPAND, Item::print(), Item_func::print_args(), and STRING_WITH_LEN.
04575 { 04576 str->append(STRING_WITH_LEN("(match ")); 04577 print_args(str, 1); 04578 str->append(STRING_WITH_LEN(" against (")); 04579 args[0]->print(str); 04580 if (flags & FT_BOOL) 04581 str->append(STRING_WITH_LEN(" in boolean mode")); 04582 else if (flags & FT_EXPAND) 04583 str->append(STRING_WITH_LEN(" with query expansion")); 04584 str->append(STRING_WITH_LEN("))")); 04585 }
Here is the call graph for this function:

| void Item_func_match::update_used_tables | ( | ) | [inline, virtual] |
| longlong Item_func_match::val_int | ( | void | ) | [inline, virtual] |
Reimplemented from Item_real_func.
Definition at line 1356 of file item_func.h.
References DBUG_ASSERT, Item::fixed, and val_real().
01356 { DBUG_ASSERT(fixed == 1); return val_real() != 0.0; }
Here is the call graph for this function:

| double Item_func_match::val_real | ( | ) | [virtual] |
Implements Item.
Definition at line 4545 of file item_func.cc.
References concat, DBUG_ASSERT, DBUG_ENTER, DBUG_RETURN, st_table::file, _ft_vft::find_relevance, Item::fixed, handler::ft_handler, ft_handler, _ft_vft::get_relevance, join_key, key, String::length(), NO_SUCH_KEY, NULL, st_table::null_row, st_ft_info::please, String::ptr(), st_table::record, table, and Item::val_str().
Referenced by val_int().
04546 { 04547 DBUG_ASSERT(fixed == 1); 04548 DBUG_ENTER("Item_func_match::val"); 04549 if (ft_handler == NULL) 04550 DBUG_RETURN(-1.0); 04551 04552 if (key != NO_SUCH_KEY && table->null_row) /* NULL row from an outer join */ 04553 DBUG_RETURN(0.0); 04554 04555 if (join_key) 04556 { 04557 if (table->file->ft_handler) 04558 DBUG_RETURN(ft_handler->please->get_relevance(ft_handler)); 04559 join_key=0; 04560 } 04561 04562 if (key == NO_SUCH_KEY) 04563 { 04564 String *a= concat->val_str(&value); 04565 if ((null_value= (a == 0))) 04566 DBUG_RETURN(0); 04567 DBUG_RETURN(ft_handler->please->find_relevance(ft_handler, 04568 (byte *)a->ptr(), a->length())); 04569 } 04570 DBUG_RETURN(ft_handler->please->find_relevance(ft_handler, 04571 table->record[0], 0)); 04572 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1333 of file item_func.h.
Referenced by cleanup(), init_search(), and val_real().
Definition at line 1327 of file item_func.h.
Referenced by eq(), fix_fields(), fix_index(), init_search(), and print().
Definition at line 1330 of file item_func.h.
Referenced by cleanup(), init_search(), and val_real().
Definition at line 1328 of file item_func.h.
Referenced by create_ref_for_key(), fix_fields(), init_search(), and val_real().
Definition at line 1327 of file item_func.h.
Referenced by add_ft_keys(), eq(), fix_fields(), fix_index(), init_search(), and val_real().
Definition at line 1331 of file item_func.h.
Referenced by add_ft_keys(), eq(), fix_fields(), fix_index(), init_search(), and val_real().
Definition at line 1334 of file item_func.h.
1.4.7

