My Project
|
Functions | |
bool | subquery_allows_materialization (Item_in_subselect *predicate, THD *thd, SELECT_LEX *select_lex, const SELECT_LEX *outer) |
bool | fix_inner_refs (THD *thd, List< Item > &all_fields, SELECT_LEX *select, Ref_ptr_array ref_pointer_array, ORDER *group_list) |
int | setup_order (THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, List< Item > &fields, List< Item > &all_fields, ORDER *order) |
int | JOIN::prepare (TABLE_LIST *tables, uint wind_num, Item *conds, uint og_num, ORDER *order, ORDER *group, Item *having, SELECT_LEX *select, SELECT_LEX_UNIT *unit) |
bool | JOIN::rollup_init () |
bool fix_inner_refs | ( | THD * | thd, |
List< Item > & | all_fields, | ||
SELECT_LEX * | select, | ||
Ref_ptr_array | ref_pointer_array, | ||
ORDER * | group_list | ||
) |
Fix fields referenced from inner selects.
thd | Thread handle |
all_fields | List of all fields used in select |
select | Current select |
ref_pointer_array | Array of references to Items used in current select |
group_list | GROUP BY list (is NULL by default) |
The function serves 3 purposes
If a field isn't already on the select list and the ref_pointer_array is provided then it is added to the all_fields list and the pointer to it is saved in the ref_pointer_array.
The class to access the outer field is determined by the following rules:
-#. If the outer field isn't used under an aggregate function then the Item_ref class should be used.
-#. If the outer field is used under an aggregate function and this function is, in turn, aggregated in the query block where the outer field was resolved or some query nested therein, then the Item_direct_ref class should be used. Also it should be used if we are grouping by a subquery containing the outer field.
The resolution is done here and not at the fix_fields() stage as it can be done only after aggregate functions are fixed and pulled up to selects where they are to be aggregated.
When the class is chosen it substitutes the original field in the Item_outer_ref object.
After this we proceed with fixing references (Item_outer_ref objects) to this field from inner subqueries.
true | An error occured. |
false | OK. |
int JOIN::prepare | ( | TABLE_LIST * | tables_init, |
uint | wild_num, | ||
Item * | conds_init, | ||
uint | og_num, | ||
ORDER * | order_init, | ||
ORDER * | group_init, | ||
Item * | having_init, | ||
SELECT_LEX * | select_lex_arg, | ||
SELECT_LEX_UNIT * | unit_arg | ||
) |
Prepare of whole select (including sub queries in future).
-1 | on error |
0 | on success |
bool JOIN::rollup_init | ( | ) |
Allocate memory needed for other rollup functions.
int setup_order | ( | THD * | thd, |
Ref_ptr_array | ref_pointer_array, | ||
TABLE_LIST * | tables, | ||
List< Item > & | fields, | ||
List< Item > & | all_fields, | ||
ORDER * | order | ||
) |
Change order to point at item in select list.
If item isn't a number and doesn't exists in the select list, add it to the the field list.
bool subquery_allows_materialization | ( | Item_in_subselect * | predicate, |
THD * | thd, | ||
SELECT_LEX * | select_lex, | ||
const SELECT_LEX * | outer | ||
) |
Check if the subquery predicate can be executed via materialization.
predicate | IN subquery predicate |
thd | THD |
select_lex | SELECT_LEX of the subquery |
outer | Parent SELECT_LEX (outer to subquery) |