MySQL 5.6.14 Source Code Document
|
Functions | |
bool | prepare_sum_aggregators (Item_sum **func_ptr, bool need_distinct) |
bool | setup_sum_funcs (THD *thd, Item_sum **func_ptr) |
bool | copy_funcs (Item **func_ptr, const THD *thd) |
void | setup_tmptable_write_func (JOIN_TAB *tab) |
Setup write_func of QEP_tmp_table object. | |
Next_select_func | setup_end_select_func (JOIN *join, JOIN_TAB *tab) |
enum_nested_loop_state | sub_select_op (JOIN *join, JOIN_TAB *join_tab, bool end_of_records) |
Accumulate full or partial join result in operation and send operation's result further. | |
enum_nested_loop_state | sub_select (JOIN *join, JOIN_TAB *join_tab, bool end_of_records) |
int | do_sj_dups_weedout (THD *thd, SJ_TMP_TABLE *sjtbl) |
int | report_handler_error (TABLE *table, int error) |
int | safe_index_read (JOIN_TAB *tab) |
int | join_read_const_table (JOIN_TAB *tab, POSITION *pos) |
void | join_read_key_unlock_row (st_join_table *tab) |
int | join_read_last_key (JOIN_TAB *tab) |
int | join_read_prev_same (READ_RECORD *info) |
int | join_init_quick_read_record (JOIN_TAB *tab) |
int | read_first_record_seq (JOIN_TAB *tab) |
int | join_init_read_record (JOIN_TAB *tab) |
Prepare table for reading rows and read first record. | |
int | join_materialize_derived (JOIN_TAB *tab) |
int | join_materialize_semijoin (JOIN_TAB *tab) |
int | join_read_first (JOIN_TAB *tab) |
int | join_read_last (JOIN_TAB *tab) |
void | pick_table_access_method (JOIN_TAB *tab) |
enum_nested_loop_state | end_send_group (JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), bool end_of_records) |
enum_nested_loop_state | end_write_group (JOIN *join, JOIN_TAB *join_tab, bool end_of_records) |
bool | cp_buffer_from_ref (THD *thd, TABLE *table, TABLE_REF *ref) |
bool | make_group_fields (JOIN *main_join, JOIN *curr_join) |
bool | alloc_group_fields (JOIN *join, ORDER *group) |
int | test_if_item_cache_changed (List< Cached_item > &list) |
bool | setup_copy_fields (THD *thd, TMP_TABLE_PARAM *param, Ref_ptr_array ref_pointer_array, List< Item > &res_selected_fields, List< Item > &res_all_fields, uint elements, List< Item > &all_fields) |
void | copy_fields (TMP_TABLE_PARAM *param) |
bool | change_to_use_tmp_fields (THD *thd, Ref_ptr_array ref_pointer_array, List< Item > &res_selected_fields, List< Item > &res_all_fields, uint elements, List< Item > &all_fields) |
bool | change_refs_to_tmp_fields (THD *thd, Ref_ptr_array ref_pointer_array, List< Item > &res_selected_fields, List< Item > &res_all_fields, uint elements, List< Item > &all_fields) |
void | JOIN::exec () |
int | JOIN::rollup_send_data (uint idx) |
int | JOIN::rollup_write_data (uint idx, TABLE *table) |
bool | st_join_table::prepare_scan () |
Prepare table to be scanned. | |
bool | st_join_table::use_order () const |
Use ordering provided by chosen index? | |
bool | st_join_table::sort_table () |
bool | st_join_table::remove_duplicates () |
enum_nested_loop_state | QEP_tmp_table::end_send () |
Finish rnd/index scan after accumulating records, switch ref_array, and send accumulated records further. |
Get a list of buffers for saveing last group.
Groups are saved in reverse order for easyer check loop.
Definition at line 3767 of file sql_executor.cc.
bool change_refs_to_tmp_fields | ( | THD * | thd, |
Ref_ptr_array | ref_pointer_array, | ||
List< Item > & | res_selected_fields, | ||
List< Item > & | res_all_fields, | ||
uint | elements, | ||
List< Item > & | all_fields | ||
) |
Change all sum_func refs to fields to point at fields in tmp table. Change all funcs to be fields in tmp table.
thd | THD pointer |
ref_pointer_array | array of pointers to top elements of filed list |
res_selected_fields | new list of items of select item list |
res_all_fields | new list of all items |
elements | number of elements in select item list |
all_fields | all fields list |
0 | ok |
1 | error |
Definition at line 4133 of file sql_executor.cc.
bool change_to_use_tmp_fields | ( | THD * | thd, |
Ref_ptr_array | ref_pointer_array, | ||
List< Item > & | res_selected_fields, | ||
List< Item > & | res_all_fields, | ||
uint | elements, | ||
List< Item > & | all_fields | ||
) |
Change all funcs and sum_funcs to fields in tmp table, and create new list of all items.
thd | THD pointer |
ref_pointer_array | array of pointers to top elements of filed list |
res_selected_fields | new list of items of select item list |
res_all_fields | new list of all items |
elements | number of elements in select item list |
all_fields | all fields list |
0 | ok |
!=0 | error |
Definition at line 4025 of file sql_executor.cc.
void copy_fields | ( | TMP_TABLE_PARAM * | param | ) |
Make a copy of all simple SELECT'ed items.
This is done at the start of a new group so that we can retrieve these later when the group changes.
Definition at line 3990 of file sql_executor.cc.
bool copy_funcs | ( | Item ** | func_ptr, |
const THD * | thd | ||
) |
Copy result of functions to record in tmp_table.
Uses the thread pointer to check for errors in some of the val_xxx() methods called by the save_in_result_field() function. TODO: make the Item::val_xxx() return error code
func_ptr | array of the function Items to copy to the tmp table |
thd | pointer to the current thread for error checking |
FALSE | if OK |
TRUE | on error |
Definition at line 545 of file sql_executor.cc.
int do_sj_dups_weedout | ( | THD * | thd, |
SJ_TMP_TABLE * | sjtbl | ||
) |
SemiJoinDuplicateElimination: Weed out duplicate row combinations
SYNPOSIS do_sj_dups_weedout() thd Thread handle sjtbl Duplicate weedout table
DESCRIPTION Try storing current record combination of outer tables (i.e. their rowids) in the temporary table. This records the fact that we've seen this record combination and also tells us if we've seen it before.
RETURN -1 Error 1 The row combination is a duplicate (discard it) 0 The row combination is not a duplicate (continue)
Definition at line 1334 of file sql_executor.cc.
|
virtual |
Finish rnd/index scan after accumulating records, switch ref_array, and send accumulated records further.
Implements QEP_operation.
Definition at line 4308 of file sql_executor.cc.
void JOIN::exec | ( | ) |
Execute select, executor entry point.
Definition at line 97 of file sql_executor.cc.
int join_init_read_record | ( | JOIN_TAB * | tab | ) |
Prepare table for reading rows and read first record.
Prior to reading the table following tasks are done, (in the order of execution): .) derived tables are materialized .) duplicates removed (tmp tables only) .) table is sorted with filesort (both non-tmp and tmp tables) After this have been done this function resets quick select, if it's present, sets up table reading functions, and reads first record.
0 | Ok |
-1 | End of records |
1 | Error |
Definition at line 2373 of file sql_executor.cc.
Reads content of constant table
tab | table |
pos | position of table in query plan |
0 | ok, one row was found or one NULL-complemented row was created |
-1 | ok, no row was found and no NULL-complemented row was created |
1 | error |
Definition at line 1791 of file sql_executor.cc.
void join_read_key_unlock_row | ( | st_join_table * | tab | ) |
Since join_read_key may buffer a record, do not unlock it if it was not used in this invocation of join_read_key(). Only count locks, thus remembering if the record was left unused, and unlock already when pruning the current value of TABLE_REF buffer.
Definition at line 2071 of file sql_executor.cc.
int join_read_last_key | ( | JOIN_TAB * | tab | ) |
This function is used when optimizing away ORDER BY in SELECT * FROM t1 WHERE a=1 ORDER BY a DESC,b DESC.
Definition at line 2222 of file sql_executor.cc.
allocate group fields or take prepared (cached).
main_join | join of current select |
curr_join | current join (join of current select or temporary copy of it) |
0 | ok |
1 | failed |
Definition at line 3743 of file sql_executor.cc.
void pick_table_access_method | ( | JOIN_TAB * | tab | ) |
Pick the appropriate access method functions
Sets the functions for the selected table access method
tab | Table reference to put access method |
Set up modified access function for pushed joins.
Already set to some non-default value in sql_select.cc TODO: Move these settings into pick_table_access_method() also
Definition at line 2657 of file sql_executor.cc.
bool JOIN_TAB::prepare_scan | ( | ) |
Prepare table to be scanned.
This function is the place to do any work on the table that needs to be done before table can be scanned. Currently it only materialized derived tables and semi-joined subqueries and binds buffer for current rowid.
Definition at line 1295 of file sql_executor.cc.
int report_handler_error | ( | TABLE * | table, |
int | error | ||
) |
Help function when we get some an error from the table handler.
Definition at line 1732 of file sql_executor.cc.
int JOIN::rollup_send_data | ( | uint | idx | ) |
Send all rollup levels higher than the current one to the client.
SAMPLE
idx | Level we are on:
|
0 | ok |
1 | If send_data_failed() |
Definition at line 323 of file sql_executor.cc.
int JOIN::rollup_write_data | ( | uint | idx, |
TABLE * | table_arg | ||
) |
Write all rollup levels higher than the current one to a temp table.
SAMPLE
idx | Level we are on:
|
table | reference to temp table |
0 | ok |
1 | if write_data_failed() |
Definition at line 364 of file sql_executor.cc.
bool setup_copy_fields | ( | THD * | thd, |
TMP_TABLE_PARAM * | param, | ||
Ref_ptr_array | ref_pointer_array, | ||
List< Item > & | res_selected_fields, | ||
List< Item > & | res_all_fields, | ||
uint | elements, | ||
List< Item > & | all_fields | ||
) |
Setup copy_fields to save fields at start of new group.
Setup copy_fields to save fields at start of new group
Only FIELD_ITEM:s and FUNC_ITEM:s needs to be saved between groups. Change old item_field to use a new field with points at saved fieldvalue This function is only called before use of send_result_set_metadata.
thd | THD pointer |
param | temporary table parameters |
ref_pointer_array | array of pointers to top elements of filed list |
res_selected_fields | new list of items of select item list |
res_all_fields | new list of all items |
elements | number of elements in select item list |
all_fields | all fields list |
0 | ok |
!=0 | error |
Definition at line 3843 of file sql_executor.cc.
Rows produced by a join sweep may end up in a temporary table or be sent to a client. Setup the function of the nested loop join algorithm which handles final fully constructed and matched records.
join | join to setup the function for. |
Definition at line 827 of file sql_executor.cc.
bool setup_sum_funcs | ( | THD * | thd, |
Item_sum ** | func_ptr | ||
) |
Call ::setup for all sum functions.
thd | thread handler |
func_ptr | sum function list |
FALSE | ok |
TRUE | error |
Definition at line 455 of file sql_executor.cc.
void setup_tmptable_write_func | ( | JOIN_TAB * | tab | ) |
Setup write_func of QEP_tmp_table object.
join_tab | JOIN_TAB of a tmp table |
Function sets up write_func according to how QEP_tmp_table object that is attached to the given join_tab will be used in the query.
Definition at line 761 of file sql_executor.cc.
Retrieve records ends with a given beginning from the result of a join.
SYNPOSIS sub_select() join pointer to the structure providing all context info for the query join_tab the first next table of the execution plan to be retrieved end_records true when we need to perform final steps of retrival
DESCRIPTION For a given partial join record consisting of records from the tables preceding the table join_tab in the execution plan, the function retrieves all matching full records from the result set and send them to the result set stream.
join | pointer to the structure providing all context info for the query |
join_tab | the first next table of the execution plan to be retrieved |
end_records | true when we need to perform final steps of retrival |
Definition at line 1198 of file sql_executor.cc.
Accumulate full or partial join result in operation and send operation's result further.
join | pointer to the structure providing all context info for the query |
join_tab | the JOIN_TAB object to which the operation is attached |
end_records | TRUE <=> all records were accumulated, send them further |
This function accumulates records, one by one, in QEP operation's buffer by calling op->put_record(). When there is no more records to save, in this case the end_of_records argument == true, function tells QEP operation to send records further by calling op->send_records(). When all records are sent this function passes 'end_of_records' signal further by calling sub_select() with end_of_records argument set to true. After that op->end_send() is called to tell QEP operation that it could end internal buffer scan.
Definition at line 1031 of file sql_executor.cc.
bool JOIN_TAB::use_order | ( | ) | const |
Use ordering provided by chosen index?
Check if access to this JOIN_TAB has to retrieve rows in sorted order as defined by the ordered index used to access this table.
Definition at line 2462 of file sql_executor.cc.