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


Public Member Functions | |
| QUICK_ROR_INTERSECT_SELECT (THD *thd, TABLE *table, bool retrieve_full_rows, MEM_ROOT *parent_alloc) | |
| ~QUICK_ROR_INTERSECT_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) |
| int | init_ror_merged_scan (bool reuse_handler) |
| bool | push_quick_back (QUICK_RANGE_SELECT *quick_sel_range) |
Public Attributes | |
| List< QUICK_RANGE_SELECT > | quick_selects |
| QUICK_RANGE_SELECT * | cpk_quick |
| MEM_ROOT | alloc |
| THD * | thd |
| bool | need_to_fetch_row |
| bool | scans_inited |
Definition at line 471 of file opt_range.h.
| QUICK_ROR_INTERSECT_SELECT::QUICK_ROR_INTERSECT_SELECT | ( | THD * | thd, | |
| TABLE * | table, | |||
| bool | retrieve_full_rows, | |||
| MEM_ROOT * | parent_alloc | |||
| ) |
Definition at line 1081 of file opt_range.cc.
References alloc, alloc_root(), bzero, st_table::file, QUICK_SELECT_I::head, QUICK_SELECT_I::index, init_sql_alloc(), QUICK_SELECT_I::last_rowid, MAX_KEY, st_table::record, handler::ref_length, and thd.
01085 : cpk_quick(NULL), thd(thd_param), need_to_fetch_row(retrieve_full_rows), 01086 scans_inited(FALSE) 01087 { 01088 index= MAX_KEY; 01089 head= table; 01090 record= head->record[0]; 01091 if (!parent_alloc) 01092 init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0); 01093 else 01094 bzero(&alloc, sizeof(MEM_ROOT)); 01095 last_rowid= (byte*)alloc_root(parent_alloc? parent_alloc : &alloc, 01096 head->file->ref_length); 01097 }
Here is the call graph for this function:

| QUICK_ROR_INTERSECT_SELECT::~QUICK_ROR_INTERSECT_SELECT | ( | ) |
Definition at line 1308 of file opt_range.cc.
References alloc, cpk_quick, DBUG_ENTER, DBUG_VOID_RETURN, List< T >::delete_elements(), st_table::file, free_root(), handler::ha_rnd_end(), QUICK_SELECT_I::head, handler::inited, MYF, need_to_fetch_row, handler::NONE, and quick_selects.
01309 { 01310 DBUG_ENTER("QUICK_ROR_INTERSECT_SELECT::~QUICK_ROR_INTERSECT_SELECT"); 01311 quick_selects.delete_elements(); 01312 delete cpk_quick; 01313 free_root(&alloc,MYF(0)); 01314 if (need_to_fetch_row && head->file->inited != handler::NONE) 01315 head->file->ha_rnd_end(); 01316 DBUG_VOID_RETURN; 01317 }
Here is the call graph for this function:

| void QUICK_ROR_INTERSECT_SELECT::add_info_string | ( | String * | str | ) | [virtual] |
Reimplemented from QUICK_SELECT_I.
Definition at line 8459 of file opt_range.cc.
References String::append(), cpk_quick, FALSE, QUICK_SELECT_I::head, QUICK_SELECT_I::index, st_table::key_info, st_key::name, quick, quick_selects, STRING_WITH_LEN, and TRUE.
08460 { 08461 bool first= TRUE; 08462 QUICK_RANGE_SELECT *quick; 08463 List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects); 08464 str->append(STRING_WITH_LEN("intersect(")); 08465 while ((quick= it++)) 08466 { 08467 KEY *key_info= head->key_info + quick->index; 08468 if (!first) 08469 str->append(','); 08470 else 08471 first= FALSE; 08472 str->append(key_info->name); 08473 } 08474 if (cpk_quick) 08475 { 08476 KEY *key_info= head->key_info + cpk_quick->index; 08477 str->append(','); 08478 str->append(key_info->name); 08479 } 08480 str->append(')'); 08481 }
Here is the call graph for this function:

| void QUICK_ROR_INTERSECT_SELECT::add_keys_and_lengths | ( | String * | key_names, | |
| String * | used_lengths | |||
| ) | [virtual] |
Implements QUICK_SELECT_I.
Definition at line 8547 of file opt_range.cc.
References String::append(), cpk_quick, FALSE, QUICK_SELECT_I::head, QUICK_SELECT_I::index, st_table::key_info, longlong2str, QUICK_SELECT_I::max_used_key_length, st_key::name, quick, quick_selects, and TRUE.
08549 { 08550 char buf[64]; 08551 uint length; 08552 bool first= TRUE; 08553 QUICK_RANGE_SELECT *quick; 08554 List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects); 08555 while ((quick= it++)) 08556 { 08557 KEY *key_info= head->key_info + quick->index; 08558 if (first) 08559 first= FALSE; 08560 else 08561 { 08562 key_names->append(','); 08563 used_lengths->append(','); 08564 } 08565 key_names->append(key_info->name); 08566 length= longlong2str(quick->max_used_key_length, buf, 10) - buf; 08567 used_lengths->append(buf, length); 08568 } 08569 08570 if (cpk_quick) 08571 { 08572 KEY *key_info= head->key_info + cpk_quick->index; 08573 key_names->append(','); 08574 key_names->append(key_info->name); 08575 length= longlong2str(cpk_quick->max_used_key_length, buf, 10) - buf; 08576 used_lengths->append(','); 08577 used_lengths->append(buf, length); 08578 } 08579 }
Here is the call graph for this function:

Reimplemented from QUICK_SELECT_I.
Definition at line 7438 of file opt_range.cc.
References check_if_key_used(), QUICK_SELECT_I::head, quick, and quick_selects.
07439 { 07440 QUICK_RANGE_SELECT *quick; 07441 List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects); 07442 while ((quick= it++)) 07443 { 07444 if (check_if_key_used(head, quick->index, *fields)) 07445 return 1; 07446 } 07447 return 0; 07448 }
Here is the call graph for this function:

| void QUICK_ROR_INTERSECT_SELECT::dbug_dump | ( | int | indent, | |
| bool | verbose | |||
| ) | [virtual] |
Implements QUICK_SELECT_I.
Definition at line 10830 of file opt_range.cc.
References cpk_quick, QUICK_RANGE_SELECT::dbug_dump(), DBUG_FILE, need_to_fetch_row, quick, and quick_selects.
10831 { 10832 List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects); 10833 QUICK_RANGE_SELECT *quick; 10834 fprintf(DBUG_FILE, "%*squick ROR-intersect select, %scovering\n", 10835 indent, "", need_to_fetch_row? "":"non-"); 10836 fprintf(DBUG_FILE, "%*smerged scans {\n", indent, ""); 10837 while ((quick= it++)) 10838 quick->dbug_dump(indent+2, verbose); 10839 if (cpk_quick) 10840 { 10841 fprintf(DBUG_FILE, "%*sclustered PK quick:\n", indent, ""); 10842 cpk_quick->dbug_dump(indent+2, verbose); 10843 } 10844 fprintf(DBUG_FILE, "%*s}\n", indent, ""); 10845 }
Here is the call graph for this function:

| int QUICK_ROR_INTERSECT_SELECT::get_next | ( | ) | [virtual] |
Implements QUICK_SELECT_I.
Definition at line 7724 of file opt_range.cc.
References cmp, handler::cmp_ref(), cpk_quick, DBUG_ENTER, DBUG_RETURN, base_list::elements, error, st_table::file, HA_ERR_RECORD_DELETED, QUICK_SELECT_I::head, QUICK_SELECT_I::last_rowid, memcpy, need_to_fetch_row, quick, quick_selects, st_table::record, handler::ref_length, List_iterator_fast< T >::rewind(), handler::rnd_pos(), and QUICK_RANGE_SELECT::row_in_ranges().
07725 { 07726 List_iterator_fast<QUICK_RANGE_SELECT> quick_it(quick_selects); 07727 QUICK_RANGE_SELECT* quick; 07728 int error, cmp; 07729 uint last_rowid_count=0; 07730 DBUG_ENTER("QUICK_ROR_INTERSECT_SELECT::get_next"); 07731 07732 do 07733 { 07734 /* Get a rowid for first quick and save it as a 'candidate' */ 07735 quick= quick_it++; 07736 error= quick->get_next(); 07737 if (cpk_quick) 07738 { 07739 while (!error && !cpk_quick->row_in_ranges()) 07740 error= quick->get_next(); 07741 } 07742 if (error) 07743 DBUG_RETURN(error); 07744 07745 quick->file->position(quick->record); 07746 memcpy(last_rowid, quick->file->ref, head->file->ref_length); 07747 last_rowid_count= 1; 07748 07749 while (last_rowid_count < quick_selects.elements) 07750 { 07751 if (!(quick= quick_it++)) 07752 { 07753 quick_it.rewind(); 07754 quick= quick_it++; 07755 } 07756 07757 do 07758 { 07759 if ((error= quick->get_next())) 07760 DBUG_RETURN(error); 07761 quick->file->position(quick->record); 07762 cmp= head->file->cmp_ref(quick->file->ref, last_rowid); 07763 } while (cmp < 0); 07764 07765 /* Ok, current select 'caught up' and returned ref >= cur_ref */ 07766 if (cmp > 0) 07767 { 07768 /* Found a row with ref > cur_ref. Make it a new 'candidate' */ 07769 if (cpk_quick) 07770 { 07771 while (!cpk_quick->row_in_ranges()) 07772 { 07773 if ((error= quick->get_next())) 07774 DBUG_RETURN(error); 07775 } 07776 } 07777 memcpy(last_rowid, quick->file->ref, head->file->ref_length); 07778 last_rowid_count= 1; 07779 } 07780 else 07781 { 07782 /* current 'candidate' row confirmed by this select */ 07783 last_rowid_count++; 07784 } 07785 } 07786 07787 /* We get here if we got the same row ref in all scans. */ 07788 if (need_to_fetch_row) 07789 error= head->file->rnd_pos(head->record[0], last_rowid); 07790 } while (error == HA_ERR_RECORD_DELETED); 07791 DBUG_RETURN(error); 07792 }
Here is the call graph for this function:

| int QUICK_ROR_INTERSECT_SELECT::get_type | ( | ) | [inline, virtual] |
Implements QUICK_SELECT_I.
Definition at line 484 of file opt_range.h.
References QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT.
00484 { return QS_TYPE_ROR_INTERSECT; }
| int QUICK_ROR_INTERSECT_SELECT::init | ( | ) | [virtual] |
Implements QUICK_SELECT_I.
Definition at line 1110 of file opt_range.cc.
References DBUG_ENTER, DBUG_RETURN, and QUICK_SELECT_I::last_rowid.
01111 { 01112 DBUG_ENTER("QUICK_ROR_INTERSECT_SELECT::init"); 01113 /* Check if last_rowid was successfully allocated in ctor */ 01114 DBUG_RETURN(!last_rowid); 01115 }
| int QUICK_ROR_INTERSECT_SELECT::init_ror_merged_scan | ( | bool | reuse_handler | ) | [virtual] |
Reimplemented from QUICK_SELECT_I.
Definition at line 1227 of file opt_range.cc.
References DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, FALSE, st_table::file, HA_EXTRA_KEYREAD_PRESERVE_FIELDS, handler::ha_rnd_init(), QUICK_SELECT_I::head, need_to_fetch_row, quick, quick_selects, st_table::record, and TRUE.
Referenced by reset().
01228 { 01229 List_iterator_fast<QUICK_RANGE_SELECT> quick_it(quick_selects); 01230 QUICK_RANGE_SELECT* quick; 01231 DBUG_ENTER("QUICK_ROR_INTERSECT_SELECT::init_ror_merged_scan"); 01232 01233 /* Initialize all merged "children" quick selects */ 01234 DBUG_ASSERT(!need_to_fetch_row || reuse_handler); 01235 if (!need_to_fetch_row && reuse_handler) 01236 { 01237 quick= quick_it++; 01238 /* 01239 There is no use of this->file. Use it for the first of merged range 01240 selects. 01241 */ 01242 if (quick->init_ror_merged_scan(TRUE)) 01243 DBUG_RETURN(1); 01244 quick->file->extra(HA_EXTRA_KEYREAD_PRESERVE_FIELDS); 01245 } 01246 while ((quick= quick_it++)) 01247 { 01248 if (quick->init_ror_merged_scan(FALSE)) 01249 DBUG_RETURN(1); 01250 quick->file->extra(HA_EXTRA_KEYREAD_PRESERVE_FIELDS); 01251 /* All merged scans share the same record buffer in intersection. */ 01252 quick->record= head->record[0]; 01253 } 01254 01255 if (need_to_fetch_row && head->file->ha_rnd_init(1)) 01256 { 01257 DBUG_PRINT("error", ("ROR index_merge rnd_init call failed")); 01258 DBUG_RETURN(1); 01259 } 01260 DBUG_RETURN(0); 01261 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool QUICK_ROR_INTERSECT_SELECT::push_quick_back | ( | QUICK_RANGE_SELECT * | quick_sel_range | ) |
Definition at line 1303 of file opt_range.cc.
References List< T >::push_back(), quick, and quick_selects.
Referenced by TRP_ROR_INTERSECT::make_quick().
01304 { 01305 return quick_selects.push_back(quick); 01306 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int QUICK_ROR_INTERSECT_SELECT::reset | ( | void | ) | [virtual] |
Implements QUICK_SELECT_I.
Definition at line 1273 of file opt_range.cc.
References DBUG_ENTER, DBUG_RETURN, init_ror_merged_scan(), quick, quick_selects, scans_inited, and TRUE.
01274 { 01275 DBUG_ENTER("QUICK_ROR_INTERSECT_SELECT::reset"); 01276 if (!scans_inited && init_ror_merged_scan(TRUE)) 01277 DBUG_RETURN(1); 01278 scans_inited= TRUE; 01279 List_iterator_fast<QUICK_RANGE_SELECT> it(quick_selects); 01280 QUICK_RANGE_SELECT *quick; 01281 while ((quick= it++)) 01282 quick->reset(); 01283 DBUG_RETURN(0); 01284 }
Here is the call graph for this function:

| bool QUICK_ROR_INTERSECT_SELECT::reverse_sorted | ( | ) | [inline, virtual] |
| bool QUICK_ROR_INTERSECT_SELECT::unique_key_range | ( | ) | [inline, virtual] |
Definition at line 506 of file opt_range.h.
Referenced by TRP_ROR_INTERSECT::make_quick(), QUICK_ROR_INTERSECT_SELECT(), and ~QUICK_ROR_INTERSECT_SELECT().
Definition at line 504 of file opt_range.h.
Referenced by add_info_string(), add_keys_and_lengths(), dbug_dump(), get_next(), TRP_ROR_INTERSECT::make_quick(), and ~QUICK_ROR_INTERSECT_SELECT().
Definition at line 508 of file opt_range.h.
Referenced by dbug_dump(), get_next(), init_ror_merged_scan(), and ~QUICK_ROR_INTERSECT_SELECT().
Definition at line 498 of file opt_range.h.
Referenced by add_info_string(), add_keys_and_lengths(), check_if_keys_used(), dbug_dump(), get_next(), init_ror_merged_scan(), push_quick_back(), reset(), and ~QUICK_ROR_INTERSECT_SELECT().
1.4.7

