My Project
|
#include <item_subselect.h>
Classes | |
struct | In2exists_info |
Public Member Functions | |
bool | in2exists_added_to_where () const |
bool | originally_dependent () const |
Is reliable only if IN->EXISTS has been done. | |
bool * | get_cond_guard (int i) |
void | set_cond_guard_var (int i, bool v) |
bool | have_guarded_conds () |
Item_in_subselect (Item *left_expr, st_select_lex *select_lex) | |
virtual void | cleanup () |
subs_type | substype () |
virtual void | reset () |
trans_res | select_transformer (JOIN *join) |
trans_res | select_in_like_transformer (JOIN *join, Comp_creator *func) |
trans_res | single_value_transformer (JOIN *join, Comp_creator *func) |
trans_res | row_value_transformer (JOIN *join) |
trans_res | single_value_in_to_exists_transformer (JOIN *join, Comp_creator *func) |
trans_res | row_value_in_to_exists_transformer (JOIN *join) |
bool | walk (Item_processor processor, bool walk_subquery, uchar *arg) |
virtual bool | exec () |
longlong | val_int () |
double | val_real () |
String * | val_str (String *) |
my_decimal * | val_decimal (my_decimal *) |
void | update_null_value () |
bool | val_bool () |
void | top_level_item () |
bool | is_top_level_item () |
bool | test_limit (st_select_lex_unit *unit) |
virtual void | print (String *str, enum_query_type query_type) |
bool | fix_fields (THD *thd, Item **ref) |
void | fix_after_pullout (st_select_lex *parent_select, st_select_lex *removed_select) |
bool | init_left_expr_cache () |
bool | finalize_exists_transform (SELECT_LEX *select_lex) |
bool | finalize_materialization_transform (JOIN *join) |
Public Attributes | |
Item * | left_expr |
bool * | pushed_cond_guards |
Item_func_not_all * | upper_item |
TABLE_LIST * | expr_join_nest |
Protected Attributes | |
List< Cached_item > * | left_expr_cache |
bool | left_expr_cache_filled |
Whether left_expr_cache holds a value. | |
bool | need_expr_cache |
Item * | expr |
Item_in_optimizer * | optimizer |
bool | was_null |
bool | abort_on_null |
Friends | |
class | Item_ref_null_helper |
class | Item_is_not_null_test |
class | Item_in_optimizer |
class | subselect_indexsubquery_engine |
class | subselect_hash_sj_engine |
Representation of IN subquery predicates of the form "left_expr IN (SELECT ...)".
This class has:
This class is not used directly, it is "wrapped" into Item_in_optimizer which provides some small bits of subquery evaluation.
bool Item_in_subselect::finalize_exists_transform | ( | SELECT_LEX * | select_lex | ) |
Once the decision to use IN->EXISTS has been taken, performs some last steps of this transformation.
bool Item_in_subselect::finalize_materialization_transform | ( | JOIN * | join | ) |
Once the decision to use materialization has been taken, performs some last steps of this transformation.
void Item_in_subselect::fix_after_pullout | ( | st_select_lex * | parent_select, |
st_select_lex * | removed_select | ||
) | [virtual] |
Fix used tables information for a subquery after query transformations. Common actions for all predicates involving subqueries. Most actions here involve re-resolving information for conditions and items belonging to the subquery. Notice that the usage information from underlying expressions is not propagated to the subquery predicate, as it belongs to inner layers of the query operator structure. However, when underlying expressions contain outer references into a select_lex on this level, the relevant information must be updated when these expressions are resolved.
Reimplemented from Item_subselect.
Initialize the cache of the left operand of the IN predicate.
TRUE | if a memory allocation error occurred |
FALSE | if success |
void Item_in_subselect::print | ( | String * | str, |
enum_query_type | query_type | ||
) | [virtual] |
This method is used for to:
For more information about view definition query, INFORMATION_SCHEMA query and why they should be generated from the Item-tree,
Reimplemented from Item_exists_subselect.
Reimplemented in Item_allany_subselect.
Item_subselect::trans_res Item_in_subselect::row_value_in_to_exists_transformer | ( | JOIN * | join | ) |
Tranform a (possibly non-correlated) IN subquery into a correlated EXISTS.
Item_subselect::trans_res Item_in_subselect::select_in_like_transformer | ( | JOIN * | join, |
Comp_creator * | func | ||
) |
Prepare IN/ALL/ANY/SOME subquery transformation and call appropriate transformation function.
To decide which transformation procedure (scalar or row) applicable here we have to call fix_fields() for left expression to be able to call cols() method on it. Also this method make arena management for underlying transformation methods.
join | JOIN object of transforming subquery |
func | creator of condition function of subquery |
RES_OK | OK |
RES_REDUCE | OK, and current subquery was reduced during transformation |
RES_ERROR | Error |
Item_subselect::trans_res Item_in_subselect::single_value_in_to_exists_transformer | ( | JOIN * | join, |
Comp_creator * | func | ||
) |
Transofrm an IN predicate into EXISTS via predicate injection.
The transformation injects additional predicates into the subquery (and makes the subquery correlated) as follows.
SELECT ie FROM ... HAVING subq_having AND trigcond(oe $cmp$ ref_or_null_helper<ie>)
the addition is wrapped into trigger only when we want to distinguish between NULL and FALSE results.
= If we don't need to distinguish between NULL and FALSE subquery:
SELECT 1 FROM ... WHERE (oe $cmp$ ie) AND subq_where
= If we need to distinguish between those:
SELECT 1 FROM ... WHERE subq_where AND trigcond((oe $cmp$ ie) OR (ie IS NULL)) HAVING trigcond(<is_not_null_test>(ie))
At JOIN::optimize() we will compare costs of materialization and EXISTS; if the former is cheaper we will switch to it.
join | Join object of the subquery (i.e. 'child' join). |
func | Subquery comparison creator |
RES_OK | Either subquery was transformed, or appopriate predicates where injected into it. |
RES_REDUCE | The subquery was reduced to non-subquery |
RES_ERROR | Error |
bool Item_in_subselect::val_bool | ( | ) | [virtual] |
Reimplemented from Item_exists_subselect.
my_decimal * Item_in_subselect::val_decimal | ( | my_decimal * | decimal_value | ) | [virtual] |
Return the result of EXISTS as a decimal value
Converts the true/false result into a decimal value. Note that currently this cannot be NULL, so if the query exection fails it will return 0.
decimal_value[out] | Buffer to hold the resulting decimal value |
Pointer | to the converted decimal. Can't be a NULL pointer, as currently EXISTS cannot return NULL. |
Reimplemented from Item_exists_subselect.
String * Item_in_subselect::val_str | ( | String * | str | ) | [virtual] |
Return the result of EXISTS as a string value
Converts the true/false result into a string value. Note that currently this cannot be NULL, so if the query exection fails it will return 0.
decimal_value[out] | buffer to hold the resulting string value |
Pointer | to the converted string. Can't be a NULL pointer, as currently EXISTS cannot return NULL. |
Reimplemented from Item_exists_subselect.
bool Item_in_subselect::need_expr_cache [protected] |
The need for expr cache may be optimized away,