#include <opt_range.h>
Inheritance diagram for QUICK_INDEX_MERGE_SELECT:


Public Member Functions | |
| QUICK_INDEX_MERGE_SELECT (THD *thd, TABLE *table) | |
| ~QUICK_INDEX_MERGE_SELECT () | |
| int | init () |
| int | reset (void) |
| int | get_next () |
| bool | reverse_sorted () |
| bool | unique_key_range () |
| int | get_type () |
| void | add_keys_and_lengths (String *key_names, String *used_lengths) |
| void | add_info_string (String *str) |
| bool | check_if_keys_used (List< Item > *fields) |
| void | dbug_dump (int indent, bool verbose) |
| bool | push_quick_back (QUICK_RANGE_SELECT *quick_sel_range) |
| int | read_keys_and_merge () |
Public Attributes | |
| List< QUICK_RANGE_SELECT > | quick_selects |
| QUICK_RANGE_SELECT * | pk_quick_select |
| bool | doing_pk_scan |
| MEM_ROOT | alloc |
| THD * | thd |
| READ_RECORD | read_record |
Definition at line 414 of file opt_range.h.
| QUICK_INDEX_MERGE_SELECT::QUICK_INDEX_MERGE_SELECT | ( | THD * | thd, | |
| TABLE * | table | |||
| ) |
Definition at line 1027 of file opt_range.cc.
References alloc, bzero, DBUG_ENTER, DBUG_VOID_RETURN, QUICK_SELECT_I::head, QUICK_SELECT_I::index, init_sql_alloc(), MAX_KEY, read_record, and thd.
01029 :pk_quick_select(NULL), thd(thd_param) 01030 { 01031 DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::QUICK_INDEX_MERGE_SELECT"); 01032 index= MAX_KEY; 01033 head= table; 01034 bzero(&read_record, sizeof(read_record)); 01035 init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0); 01036 DBUG_VOID_RETURN; 01037 }
Here is the call graph for this function:

| QUICK_INDEX_MERGE_SELECT::~QUICK_INDEX_MERGE_SELECT | ( | ) |
Definition at line 1066 of file opt_range.cc.
References alloc, DBUG_ENTER, DBUG_VOID_RETURN, List< T >::delete_elements(), free_root(), MYF, NULL, pk_quick_select, quick, quick_selects, and List_iterator_fast< T >::rewind().
01067 { 01068 List_iterator_fast<QUICK_RANGE_SELECT> quick_it(quick_selects); 01069 QUICK_RANGE_SELECT* quick; 01070 DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::~QUICK_INDEX_MERGE_SELECT"); 01071 quick_it.rewind(); 01072 while ((quick= quick_it++)) 01073 quick->file= NULL; 01074 quick_selects.delete_elements(); 01075 delete pk_quick_select; 01076 free_root(&alloc,MYF(0)); 01077 DBUG_VOID_RETURN; 01078 }
Here is the call graph for this function:

| void QUICK_INDEX_MERGE_SELECT::add_info_string | ( | String * | str | ) | [virtual] |
Reimplemented from QUICK_SELECT_I.
Definition at line 8437 of file opt_range.cc.
References QUICK_RANGE_SELECT::add_info_string(), String::append(), FALSE, pk_quick_select, quick, quick_selects, STRING_WITH_LEN, and TRUE.
08438 { 08439 QUICK_RANGE_SELECT *quick; 08440 bool first= TRUE; 08441 List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects); 08442 str->append(STRING_WITH_LEN("sort_union(")); 08443 while ((quick= it++)) 08444 { 08445 if (!first) 08446 str->append(','); 08447 else 08448 first= FALSE; 08449 quick->add_info_string(str); 08450 } 08451 if (pk_quick_select) 08452 { 08453 str->append(','); 08454 pk_quick_select->add_info_string(str); 08455 } 08456 str->append(')'); 08457 }
Here is the call graph for this function:

| void QUICK_INDEX_MERGE_SELECT::add_keys_and_lengths | ( | String * | key_names, | |
| String * | used_lengths | |||
| ) | [virtual] |
Implements QUICK_SELECT_I.
Definition at line 8512 of file opt_range.cc.
References String::append(), FALSE, QUICK_SELECT_I::head, QUICK_SELECT_I::index, st_table::key_info, longlong2str, QUICK_SELECT_I::max_used_key_length, st_key::name, pk_quick_select, quick, quick_selects, and TRUE.
08514 { 08515 char buf[64]; 08516 uint length; 08517 bool first= TRUE; 08518 QUICK_RANGE_SELECT *quick; 08519 08520 List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects); 08521 while ((quick= it++)) 08522 { 08523 if (first) 08524 first= FALSE; 08525 else 08526 { 08527 key_names->append(','); 08528 used_lengths->append(','); 08529 } 08530 08531 KEY *key_info= head->key_info + quick->index; 08532 key_names->append(key_info->name); 08533 length= longlong2str(quick->max_used_key_length, buf, 10) - buf; 08534 used_lengths->append(buf, length); 08535 } 08536 if (pk_quick_select) 08537 { 08538 KEY *key_info= head->key_info + pk_quick_select->index; 08539 key_names->append(','); 08540 key_names->append(key_info->name); 08541 length= longlong2str(pk_quick_select->max_used_key_length, buf, 10) - buf; 08542 used_lengths->append(','); 08543 used_lengths->append(buf, length); 08544 } 08545 }
Here is the call graph for this function:

Reimplemented from QUICK_SELECT_I.
Definition at line 7426 of file opt_range.cc.
References check_if_key_used(), QUICK_SELECT_I::head, quick, and quick_selects.
07427 { 07428 QUICK_RANGE_SELECT *quick; 07429 List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects); 07430 while ((quick= it++)) 07431 { 07432 if (check_if_key_used(head, quick->index, *fields)) 07433 return 1; 07434 } 07435 return 0; 07436 }
Here is the call graph for this function:

| void QUICK_INDEX_MERGE_SELECT::dbug_dump | ( | int | indent, | |
| bool | verbose | |||
| ) | [virtual] |
Implements QUICK_SELECT_I.
Definition at line 10814 of file opt_range.cc.
References QUICK_RANGE_SELECT::dbug_dump(), DBUG_FILE, pk_quick_select, quick, and quick_selects.
10815 { 10816 List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects); 10817 QUICK_RANGE_SELECT *quick; 10818 fprintf(DBUG_FILE, "%*squick index_merge select\n", indent, ""); 10819 fprintf(DBUG_FILE, "%*smerged scans {\n", indent, ""); 10820 while ((quick= it++)) 10821 quick->dbug_dump(indent+2, verbose); 10822 if (pk_quick_select) 10823 { 10824 fprintf(DBUG_FILE, "%*sclustered PK quick:\n", indent, ""); 10825 pk_quick_select->dbug_dump(indent+2, verbose); 10826 } 10827 fprintf(DBUG_FILE, "%*s}\n", indent, ""); 10828 }
Here is the call graph for this function:

| int QUICK_INDEX_MERGE_SELECT::get_next | ( | ) | [virtual] |
Implements QUICK_SELECT_I.
Definition at line 7677 of file opt_range.cc.
References DBUG_ENTER, DBUG_RETURN, doing_pk_scan, end_read_record(), QUICK_RANGE_SELECT::get_next(), HA_ERR_END_OF_FILE, QUICK_RANGE_SELECT::init(), pk_quick_select, st_read_record::read_record, read_record, QUICK_RANGE_SELECT::reset(), and TRUE.
07678 { 07679 int result; 07680 DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::get_next"); 07681 07682 if (doing_pk_scan) 07683 DBUG_RETURN(pk_quick_select->get_next()); 07684 07685 if ((result= read_record.read_record(&read_record)) == -1) 07686 { 07687 result= HA_ERR_END_OF_FILE; 07688 end_read_record(&read_record); 07689 /* All rows from Unique have been retrieved, do a clustered PK scan */ 07690 if (pk_quick_select) 07691 { 07692 doing_pk_scan= TRUE; 07693 if ((result= pk_quick_select->init()) || 07694 (result= pk_quick_select->reset())) 07695 DBUG_RETURN(result); 07696 DBUG_RETURN(pk_quick_select->get_next()); 07697 } 07698 } 07699 07700 DBUG_RETURN(result); 07701 }
Here is the call graph for this function:

| int QUICK_INDEX_MERGE_SELECT::get_type | ( | ) | [inline, virtual] |
Implements QUICK_SELECT_I.
Definition at line 425 of file opt_range.h.
References QUICK_SELECT_I::QS_TYPE_INDEX_MERGE.
00425 { return QS_TYPE_INDEX_MERGE; }
| int QUICK_INDEX_MERGE_SELECT::init | ( | ) | [virtual] |
Implements QUICK_SELECT_I.
Definition at line 1039 of file opt_range.cc.
References DBUG_ENTER, and DBUG_RETURN.
01040 { 01041 DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::init"); 01042 DBUG_RETURN(0); 01043 }
| bool QUICK_INDEX_MERGE_SELECT::push_quick_back | ( | QUICK_RANGE_SELECT * | quick_sel_range | ) |
Definition at line 1052 of file opt_range.cc.
References st_table::file, QUICK_SELECT_I::head, QUICK_SELECT_I::index, pk_quick_select, st_table_share::primary_key, handler::primary_key_is_clustered(), List< T >::push_back(), quick_selects, and st_table::s.
Referenced by TRP_INDEX_MERGE::make_quick().
01053 { 01054 /* 01055 Save quick_select that does scan on clustered primary key as it will be 01056 processed separately. 01057 */ 01058 if (head->file->primary_key_is_clustered() && 01059 quick_sel_range->index == head->s->primary_key) 01060 pk_quick_select= quick_sel_range; 01061 else 01062 return quick_selects.push_back(quick_sel_range); 01063 return 0; 01064 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge | ( | ) |
Definition at line 7581 of file opt_range.cc.
References bitmap_clear_all, st_table::column_bitmaps_set(), DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, doing_pk_scan, handler::extra(), FALSE, QUICK_RANGE_SELECT::file, st_table::file, QUICK_RANGE_SELECT::get_next(), HA_ERR_END_OF_FILE, HA_EXTRA_KEYREAD, HA_EXTRA_NO_KEYREAD, handler::ha_index_end(), QUICK_SELECT_I::head, QUICK_RANGE_SELECT::init(), init_read_record(), handler::inited, handler::NONE, pk_quick_select, handler::position(), st_table::prepare_for_position(), quick_selects, QUICK_RANGE_SELECT::range_end(), read_record, st_table::read_set, QUICK_SELECT_I::record, handler::ref, handler::ref_length, refpos_order_cmp(), QUICK_RANGE_SELECT::reset(), List_iterator_fast< T >::rewind(), QUICK_RANGE_SELECT::row_in_ranges(), st_table::tmp_set, and st_table::write_set.
Referenced by reset().
07582 { 07583 List_iterator_fast<QUICK_RANGE_SELECT> cur_quick_it(quick_selects); 07584 QUICK_RANGE_SELECT* cur_quick; 07585 int result; 07586 Unique *unique; 07587 MY_BITMAP *save_read_set, *save_write_set; 07588 handler *file= head->file; 07589 DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::read_keys_and_merge"); 07590 07591 /* We're going to just read rowids. */ 07592 save_read_set= head->read_set; 07593 save_write_set= head->write_set; 07594 file->extra(HA_EXTRA_KEYREAD); 07595 bitmap_clear_all(&head->tmp_set); 07596 head->column_bitmaps_set(&head->tmp_set, &head->tmp_set); 07597 head->prepare_for_position(); 07598 07599 cur_quick_it.rewind(); 07600 cur_quick= cur_quick_it++; 07601 DBUG_ASSERT(cur_quick != 0); 07602 07603 /* 07604 We reuse the same instance of handler so we need to call both init and 07605 reset here. 07606 */ 07607 if (cur_quick->init() || cur_quick->reset()) 07608 DBUG_RETURN(1); 07609 07610 unique= new Unique(refpos_order_cmp, (void *)file, 07611 file->ref_length, 07612 thd->variables.sortbuff_size); 07613 if (!unique) 07614 DBUG_RETURN(1); 07615 for (;;) 07616 { 07617 while ((result= cur_quick->get_next()) == HA_ERR_END_OF_FILE) 07618 { 07619 cur_quick->range_end(); 07620 cur_quick= cur_quick_it++; 07621 if (!cur_quick) 07622 break; 07623 07624 if (cur_quick->file->inited != handler::NONE) 07625 cur_quick->file->ha_index_end(); 07626 if (cur_quick->init() || cur_quick->reset()) 07627 DBUG_RETURN(1); 07628 } 07629 07630 if (result) 07631 { 07632 if (result != HA_ERR_END_OF_FILE) 07633 { 07634 cur_quick->range_end(); 07635 DBUG_RETURN(result); 07636 } 07637 break; 07638 } 07639 07640 if (thd->killed) 07641 DBUG_RETURN(1); 07642 07643 /* skip row if it will be retrieved by clustered PK scan */ 07644 if (pk_quick_select && pk_quick_select->row_in_ranges()) 07645 continue; 07646 07647 cur_quick->file->position(cur_quick->record); 07648 result= unique->unique_add((char*)cur_quick->file->ref); 07649 if (result) 07650 DBUG_RETURN(1); 07651 07652 } 07653 07654 DBUG_PRINT("info", ("ok")); 07655 /* ok, all row ids are in Unique */ 07656 result= unique->get(head); 07657 delete unique; 07658 doing_pk_scan= FALSE; 07659 /* index_merge currently doesn't support "using index" at all */ 07660 file->extra(HA_EXTRA_NO_KEYREAD); 07661 head->column_bitmaps_set(save_read_set, save_write_set); 07662 /* start table scan */ 07663 init_read_record(&read_record, thd, head, (SQL_SELECT*) 0, 1, 1); 07664 DBUG_RETURN(result); 07665 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int QUICK_INDEX_MERGE_SELECT::reset | ( | void | ) | [virtual] |
Implements QUICK_SELECT_I.
Definition at line 1045 of file opt_range.cc.
References DBUG_ENTER, DBUG_RETURN, and read_keys_and_merge().
01046 { 01047 DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::reset"); 01048 DBUG_RETURN(read_keys_and_merge()); 01049 }
Here is the call graph for this function:

| bool QUICK_INDEX_MERGE_SELECT::reverse_sorted | ( | ) | [inline, virtual] |
| bool QUICK_INDEX_MERGE_SELECT::unique_key_range | ( | ) | [inline, virtual] |
Definition at line 444 of file opt_range.h.
Referenced by TRP_INDEX_MERGE::make_quick(), QUICK_INDEX_MERGE_SELECT(), and ~QUICK_INDEX_MERGE_SELECT().
Definition at line 439 of file opt_range.h.
Referenced by add_info_string(), add_keys_and_lengths(), dbug_dump(), get_next(), push_quick_back(), read_keys_and_merge(), and ~QUICK_INDEX_MERGE_SELECT().
Definition at line 436 of file opt_range.h.
Referenced by add_info_string(), add_keys_and_lengths(), check_if_keys_used(), dbug_dump(), push_quick_back(), read_keys_and_merge(), and ~QUICK_INDEX_MERGE_SELECT().
Definition at line 449 of file opt_range.h.
Referenced by get_next(), QUICK_INDEX_MERGE_SELECT(), and read_keys_and_merge().
1.4.7

