MySQL  8.0.17
Source Code Documentation
SELECT_LEX Class Reference

This class represents a query block, aka a query specification, which is a query consisting of a SELECT keyword, followed by a table list, optionally followed by a WHERE clause, a GROUP BY, etc. More...

#include <sql_lex.h>

Public Types

enum  Resolve_place {
  RESOLVE_NONE, RESOLVE_JOIN_NEST, RESOLVE_CONDITION, RESOLVE_HAVING,
  RESOLVE_SELECT_LIST
}
 Three fields used by semi-join transformations to know when semi-join is possible, and in which condition tree the subquery predicate is located. More...
 

Public Member Functions

Itemwhere_cond () const
 
void set_where_cond (Item *cond)
 
Itemhaving_cond () const
 
void set_having_cond (Item *cond)
 
void set_query_result (Query_result *result)
 
Query_resultquery_result () const
 
bool change_query_result (THD *thd, Query_result_interceptor *new_result, Query_result_interceptor *old_result)
 Change the Query_result object of the query block. More...
 
void set_base_options (ulonglong options_arg)
 Set base options for a query block (and active options too) More...
 
void add_base_options (ulonglong options)
 Add base options to a query block, also update active options. More...
 
void remove_base_options (ulonglong options)
 Remove base options from a query block. More...
 
void make_active_options (ulonglong added_options, ulonglong removed_options)
 Make active options from base options, supplied options and environment: More...
 
void add_active_options (ulonglong options)
 Adjust the active option set. More...
 
ulonglong active_options () const
 
void set_tables_readonly ()
 Set associated tables as read_only, ie. More...
 
table_map all_tables_map () const
 
 SELECT_LEX (Item *where, Item *having)
 
More...
 
SELECT_LEX_UNITmaster_unit () const
 
SELECT_LEX_UNITfirst_inner_unit () const
 
SELECT_LEXouter_select () const
 
SELECT_LEXnext_select () const
 
bool is_straight_join ()
 
SELECT_LEXlast_select ()
 
SELECT_LEXnext_select_in_list () const
 
void mark_as_dependent (SELECT_LEX *last, bool aggregate)
 Mark all query blocks from this to 'last' as dependent. More...
 
bool is_explicitly_grouped () const
 
bool is_implicitly_grouped () const
 
bool is_single_grouped () const
 True if this query block is implicitly grouped. More...
 
bool is_grouped () const
 
bool is_distinct () const
 
bool is_ordered () const
 
bool has_limit () const
 
bool has_ft_funcs () const
 
bool is_recursive () const
 
bool has_windows () const
 
void invalidate ()
 Invalidate by nulling out pointers to other SELECT_LEX_UNITs and SELECT_LEXes. More...
 
bool set_braces (bool value)
 
uint get_in_sum_expr () const
 
bool add_item_to_list (Item *item)
 
bool add_ftfunc_to_list (Item_func_match *func)
 
void add_order_to_list (ORDER *order)
 
TABLE_LISTadd_table_to_list (THD *thd, Table_ident *table, const char *alias, ulong table_options, thr_lock_type flags=TL_UNLOCK, enum_mdl_type mdl_type=MDL_SHARED_READ, List< Index_hint > *hints=0, List< String > *partition_names=0, LEX_STRING *option=0, Parse_context *pc=NULL)
 Add a table to list of used tables. More...
 
TABLE_LISTget_table_list () const
 
bool init_nested_join (THD *thd)
 Initialize a new table list for a nested join. More...
 
TABLE_LISTend_nested_join ()
 End a nested join table list. More...
 
TABLE_LISTnest_last_join (THD *thd, size_t table_cnt=2)
 Nest last join operations. More...
 
bool add_joined_table (TABLE_LIST *table)
 Add a table to the current join list. More...
 
TABLE_LISTconvert_right_join ()
 Convert a right join into equivalent left join. More...
 
List< Item > * get_item_list ()
 
bool check_view_privileges (THD *thd, ulong want_privilege_first, ulong want_privilege_next)
 Check privileges for the view tables merged into a query block. More...
 
bool setup_tables (THD *thd, TABLE_LIST *tables, bool select_insert)
 Set up table leaves in the query block based on list of tables. More...
 
bool resolve_placeholder_tables (THD *thd, bool apply_semijoin)
 Resolve derived table, view or table function references in query block. More...
 
void propagate_unique_test_exclusion ()
 Propagate exclusion from unique table check into all subqueries belonging to this query block. More...
 
bool add_ftfunc_list (List< Item_func_match > *ftfuncs)
 Add a list of full-text function elements into a query block. More...
 
void set_lock_for_table (const Lock_descriptor &descriptor, TABLE_LIST *table)
 
void set_lock_for_tables (thr_lock_type lock_type)
 Set lock for all tables in current query block. More...
 
void init_order ()
 
void cut_subtree ()
 
bool test_limit ()
 
ha_rows get_offset (THD *thd)
 Get offset for LIMIT. More...
 
ha_rows get_limit (THD *thd)
 
Get limit. More...
 
bool set_context (Name_resolution_context *outer_context)
 Assign a default name resolution object for this query block. More...
 
bool setup_base_ref_items (THD *thd)
 Setup the array containing references to base items. More...
 
void print (const THD *thd, String *str, enum_query_type query_type)
 
void print_select (const THD *thd, String *str, enum_query_type query_type)
 Print detail of the SELECT_LEX object. More...
 
void print_update (const THD *thd, String *str, enum_query_type query_type)
 Print detail of the UPDATE statement. More...
 
void print_delete (const THD *thd, String *str, enum_query_type query_type)
 Print detail of the DELETE statement. More...
 
void print_insert (const THD *thd, String *str, enum_query_type query_type)
 Print detail of the INSERT statement. More...
 
void print_hints (const THD *thd, String *str, enum_query_type query_type)
 Print detail of Hints. More...
 
bool print_error (const THD *thd, String *str)
 Print error. More...
 
void print_select_options (String *str)
 Print select options. More...
 
void print_update_options (String *str)
 Print UPDATE options. More...
 
void print_delete_options (String *str)
 Print DELETE options. More...
 
void print_insert_options (String *str)
 Print INSERT options. More...
 
void print_table_references (const THD *thd, String *str, TABLE_LIST *table_list, enum_query_type query_type)
 Print list of tables. More...
 
void print_item_list (const THD *thd, String *str, enum_query_type query_type)
 Print list of items in SELECT_LEX object. More...
 
void print_update_list (const THD *thd, String *str, enum_query_type query_type, List< Item > fields, List< Item > values)
 Print assignments list. More...
 
void print_insert_fields (const THD *thd, String *str, enum_query_type query_type)
 Print column list to be inserted into. More...
 
void print_insert_values (const THD *thd, String *str, enum_query_type query_type)
 Print list of values to be inserted. More...
 
void print_from_clause (const THD *thd, String *str, enum_query_type query_type)
 Print list of tables in FROM clause. More...
 
void print_where_cond (const THD *thd, String *str, enum_query_type query_type)
 Print list of conditions in WHERE clause. More...
 
void print_group_by (const THD *thd, String *str, enum_query_type query_type)
 Print list of items in GROUP BY clause. More...
 
void print_having (const THD *thd, String *str, enum_query_type query_type)
 Print list of items in HAVING clause. More...
 
void print_windows (const THD *thd, String *str, enum_query_type query_type)
 Print details of Windowing functions. More...
 
void print_order_by (const THD *thd, String *str, enum_query_type query_type)
 Print list of items in ORDER BY clause. More...
 
void print_limit (const THD *thd, String *str, enum_query_type query_type)
 
void fix_prepare_information (THD *thd)
 
bool accept (Select_lex_visitor *visitor)
 Accept function for SELECT and DELETE. More...
 
bool cleanup (THD *thd, bool full)
 Cleanup this subtree (this SELECT_LEX and all nested SELECT_LEXes and SELECT_LEX_UNITs). More...
 
void cleanup_all_joins ()
 
bool is_part_of_union () const
 Return true if this query block is part of a UNION. More...
 
bool is_empty_query () const
 
void set_empty_query ()
 Set query block as returning no data. More...
 
bool agg_func_used () const
 
bool json_agg_func_used () const
 
void set_agg_func_used (bool val)
 
void set_json_agg_func_used (bool val)
 
enum_explain_type type ()
 Lookup for SELECT_LEX type. More...
 
const char * get_type_str ()
 Lookup for a type string. More...
 
bool is_dependent () const
 
bool is_cacheable () const
 
void include_down (LEX *lex, SELECT_LEX_UNIT *outer)
 Include query block inside a query expression. More...
 
void include_neighbour (LEX *lex, SELECT_LEX *before)
 Include a query block next to another query block. More...
 
void include_standalone (SELECT_LEX_UNIT *sel, SELECT_LEX **ref)
 Include query block inside a query expression, but do not link. More...
 
void include_in_global (SELECT_LEX **plink)
 Include query block into global list. More...
 
void include_chain_in_global (SELECT_LEX **start)
 Include chain of query blocks into global list. More...
 
void renumber (LEX *lex)
 Renumber query blocks of contained query expressions. More...
 
bool apply_local_transforms (THD *thd, bool prune)
 Does permanent transformations which are local to a query block (which do not merge it to another block). More...
 
bool get_optimizable_conditions (THD *thd, Item **new_where, Item **new_having)
 Returns disposable copies of WHERE/HAVING/ON conditions. More...
 
bool validate_outermost_option (LEX *lex, const char *wrong_option) const
 Check if an option that can be used only for an outer-most query block is applicable to this query block. More...
 
bool validate_base_options (LEX *lex, ulonglong options) const
 Validate base options for a query block. More...
 
bool walk (Item_processor processor, enum_walk walk, uchar *arg)
 
bool merge_derived (THD *thd, TABLE_LIST *derived_table)
 Merge derived table into query block. More...
 
void clear_sj_expressions (NESTED_JOIN *nested_join)
 Remove semijoin condition for this query block. More...
 
bool build_sj_cond (THD *thd, NESTED_JOIN *nested_join, SELECT_LEX *subq_select, table_map outer_tables_map, Item **sj_cond)
 Build semijoin condition for th query block. More...
 
bool decorrelate_condition (TABLE_LIST *sj_nest, TABLE_LIST *join_nest)
 Decorrelate the WHERE clause or a join condition of a subquery used in an IN or EXISTS predicate. More...
 
bool decorrelate_join_conds (TABLE_LIST *sj_nest, List< TABLE_LIST > *join_list)
 Decorrelate join conditions for a subquery. More...
 
bool resolve_rollup_wfs (THD *thd)
 Replace group by field references inside window functions with references in the the presence of ROLLUP. More...
 
bool change_group_ref_for_func (THD *thd, Item *func, bool *changed)
 Replace occurrences of group by fields in a functions's arguments by ref items. More...
 
bool change_group_ref_for_cond (THD *thd, Item_cond *cond, bool *changed)
 Similar to change_group_ref_for_func, except we are looking into an AND or OR conditions instead of functions' arguments. More...
 
bool flatten_subqueries (THD *thd)
 Convert semi-join subquery predicates into semi-join join nests. More...
 
void set_sj_candidates (Mem_root_array< Item_exists_subselect *> *sj_cand)
 
bool has_sj_candidates () const
 
bool is_in_select_list (Item *i)
 
bool setup_conds (THD *thd)
 Resolve WHERE condition and join conditions. More...
 
bool prepare (THD *thd)
 Prepare query block for optimization. More...
 
bool optimize (THD *thd)
 Optimize a query block and all inner query expressions. More...
 
void reset_nj_counters (List< TABLE_LIST > *join_list=NULL)
 Set NESTED_JOIN::counter=0 in all nested joins in passed list. More...
 
bool check_only_full_group_by (THD *thd)
 Runs checks mandated by ONLY_FULL_GROUP_BY. More...
 
void merge_contexts (SELECT_LEX *inner)
 Merge name resolution context objects of a subquery into its parent. More...
 
Item_exists_subselect::enum_exec_method subquery_strategy (THD *thd) const
 Returns which subquery execution strategies can be used for this query block. More...
 
bool semijoin_enabled (THD *thd) const
 Returns whether semi-join is enabled for this query block. More...
 
void update_semijoin_strategies (THD *thd)
 Update available semijoin strategies for semijoin nests. More...
 
void remove_semijoin_candidate (Item_exists_subselect *sub_query)
 Removes pointer to a sub query from sj_candidates array. More...
 
Item ** add_hidden_item (Item *item)
 Add item to the hidden part of select list. More...
 
bool add_tables (THD *thd, const Mem_root_array< Table_ident *> *tables, ulong table_options, thr_lock_type lock_type, enum_mdl_type mdl_type)
 Add tables from an array to a list of used tables. More...
 
TABLE_LISTfind_table_by_name (const Table_ident *ident)
 Finds a (possibly unresolved) table reference in the from clause by name. More...
 

Static Public Member Functions

static void print_order (const THD *thd, String *str, ORDER *order, enum_query_type query_type)
 
static const char * get_type_str (enum_explain_type type)
 

Public Attributes

uint8 uncacheable
 result of this query can't be cached, bit field, can be : UNCACHEABLE_DEPENDENT UNCACHEABLE_RAND UNCACHEABLE_SIDEEFFECT More...
 
bool skip_local_transforms
 True: skip local transformations during prepare() call (used by INSERT) More...
 
enum sub_select_type linkage
 Describes context of this query block (e.g if it is a derived table). More...
 
bool no_table_names_allowed
 used for global order by More...
 
Name_resolution_context context
 Context for name resolution for all column references except columns from joined tables. More...
 
Name_resolution_contextfirst_context
 Pointer to first object in list of Name res context objects that have this query block as the base query block. More...
 
Resolve_place resolve_place
 Indicates part of query being resolved. More...
 
TABLE_LISTresolve_nest
 Used when resolving outer join condition. More...
 
bool semijoin_disallowed
 Disables semi-join flattening when resolving a subtree in which flattening is not allowed. More...
 
char * db
 
Item::cond_result cond_value
 Saved values of the WHERE and HAVING clauses. More...
 
Item::cond_result having_value
 
LEXparent_lex
 Reference to LEX that this query block belongs to. More...
 
enum olap_type olap
 Indicates whether this query block contains the WITH ROLLUP clause. More...
 
SQL_I_List< TABLE_LISTtable_list
 List of tables in FROM clause - use TABLE_LIST::next_local to traverse. More...
 
SQL_I_List< ORDERgroup_list
 GROUP BY clause. More...
 
Group_list_ptrsgroup_list_ptrs
 
List< Windowm_windows
 All windows defined on the select, both named and inlined. More...
 
List< Itemitem_list
 List of columns and expressions: SELECT: Columns and expressions in the SELECT list. More...
 
bool is_item_list_lookup
 
int hidden_group_field_count
 Number of GROUP BY expressions added to all_fields. More...
 
List< Item > & fields_list
 hold field list More...
 
List< Itemall_fields
 to store all expressions used in query More...
 
List< Item_func_match > * ftfunc_list
 Usually a pointer to ftfunc_list_alloc, but in UNION this is used to create fake select_lex that consolidates result fields of UNION. More...
 
List< Item_func_matchftfunc_list_alloc
 
JOINjoin
 After optimization it is pointer to corresponding JOIN. More...
 
List< TABLE_LISTtop_join_list
 join list of the top level More...
 
List< TABLE_LIST > * join_list
 list for the currently parsed join More...
 
TABLE_LISTembedding
 table embedding the above list More...
 
List< TABLE_LISTsj_nests
 List of semi-join nests generated for this query block. More...
 
TABLE_LISTleaf_tables
 Points to first leaf table of query block. More...
 
uint leaf_table_count
 Number of leaf tables in this query block. More...
 
uint derived_table_count
 Number of derived tables and views in this query block. More...
 
uint table_func_count
 Number of table functions in this query block. More...
 
uint materialized_derived_table_count
 Number of materialized derived tables and views in this query block. More...
 
bool has_sj_nests
 True if query block has semi-join nests merged into it. More...
 
bool has_aj_nests
 
uint partitioned_table_count
 Number of partitioned tables. More...
 
SQL_I_List< ORDERorder_list
 ORDER BY clause. More...
 
Group_list_ptrsorder_list_ptrs
 
Itemselect_limit
 LIMIT clause, NULL if no limit is given. More...
 
Itemoffset_limit
 LIMIT ... OFFSET clause, NULL if no offset is given. More...
 
Ref_item_array base_ref_items
 Array of pointers to "base" items; one each for every selected expression and referenced item in the query block. More...
 
uint select_n_having_items
 number of items in select_list and HAVING clause used to get number bigger then can be number of entries that will be added to all item list during split_sum_func More...
 
uint cond_count
 number of arguments of and/or/xor in where/having/on More...
 
uint between_count
 number of between predicates in where/having/on More...
 
uint max_equal_elems
 maximal number of elements in multiple equalities More...
 
uint select_n_where_fields
 Number of fields used in select list or where clause of current select and all inner subselects. More...
 
enum_parsing_context parsing_place
 Parse context: indicates where the current expression is being parsed. More...
 
uint in_sum_expr
 Parse context: is inside a set function if this is positive. More...
 
bool with_sum_func
 True if contains or aggregates set functions. More...
 
uint n_sum_items
 Number of Item_sum-derived objects in this SELECT. More...
 
uint n_child_sum_items
 Number of Item_sum-derived objects in children and descendant SELECTs. More...
 
uint select_number
 Query block number (used for EXPLAIN) More...
 
int nest_level
 Nesting level of query block, outer-most query block has level 0, its subqueries have level 1, etc. More...
 
Item_suminner_sum_func_list
 Circular linked list of sum func in nested selects. More...
 
uint with_wild
 Number of wildcards used in the SELECT list. More...
 
bool braces
 SELECT ... More...
 
bool having_fix_field
 true when having fix field called in processing of this query block More...
 
bool group_fix_field
 true when GROUP BY fix field called in processing of this query block More...
 
bool explicit_limit
 explicit LIMIT clause is used More...
 
bool subquery_in_having
 HAVING clause contains subquery => we can't close tables before query processing end even if we use temporary table. More...
 
bool first_execution
 This variable is required to ensure proper work of subqueries and stored procedures. More...
 
bool sj_pullout_done
 True when semi-join pull-out processing is complete. More...
 
bool exclude_from_table_unique_test
 exclude this query block from unique_table() check More...
 
bool allow_merge_derived
 Allow merge of immediate unnamed derived tables. More...
 
TABLE_LISTrecursive_reference
 If this query block is a recursive member of a recursive unit: the TABLE_LIST, in this recursive member, referencing the query name. More...
 
SELECT_LEX_UNITrecursive_dummy_unit
 To pass the first steps of resolution, a recursive reference is made to be a dummy derived table; after the temporary table is created based on the non-recursive members' types, the recursive reference is made to be a reference to the tmp table. More...
 
table_map select_list_tables
 The set of those tables whose fields are referenced in the select list of this select level. More...
 
table_map outer_join
 Bitmap of all inner tables from outer joins. More...
 
Opt_hints_qbopt_hints_qb
 Query-block-level hints, for this query block. More...
 
TABLE_LISTend_lateral_table
 
int hidden_order_field_count
 How many expressions are part of the order by but not select list. More...
 

Private Member Functions

void delete_unused_merged_columns (List< TABLE_LIST > *tables)
 Delete unused columns from merged tables. More...
 
void fix_prepare_information_for_order (THD *thd, SQL_I_List< ORDER > *list, Group_list_ptrs **list_ptrs)
 Helper for fix_prepare_information() More...
 
bool record_join_nest_info (List< TABLE_LIST > *tables)
 Record join nest info in the select block. More...
 
bool simplify_joins (THD *thd, List< TABLE_LIST > *join_list, bool top, bool in_sj, Item **new_conds, uint *changelog=NULL)
 Simplify joins replacing outer joins by inner joins whenever it's possible. More...
 
bool convert_subquery_to_semijoin (THD *thd, Item_exists_subselect *subq_pred)
 Convert a subquery predicate of this query block into a TABLE_LIST semi-join nest. More...
 
void remap_tables (THD *thd)
 Re-map table numbers for all tables in a query block. More...
 
bool resolve_subquery (THD *thd)
 Resolve predicate involving subquery. More...
 
bool resolve_rollup_item (THD *thd, Item *item)
 Resolve an item (and its tree) for rollup processing by replacing fields with references and updating properties (maybe_null, PROP_ROLLUP_FIELD). More...
 
bool resolve_rollup (THD *thd)
 Resolve items in SELECT list and ORDER BY list for rollup processing. More...
 
bool setup_wild (THD *thd)
 Expand all '*' in list of expressions with the matching column references. More...
 
bool setup_order_final (THD *thd)
 Do final setup of ORDER BY clause, after the query block is fully resolved. More...
 
bool setup_group (THD *thd)
 Resolve and set up the GROUP BY list. More...
 
void remove_redundant_subquery_clauses (THD *thd, int hidden_group_field_count)
 For a table subquery predicate (IN/ANY/ALL/EXISTS/etc): since it does not support LIMIT the following clauses are redundant: More...
 
void repoint_contexts_of_join_nests (List< TABLE_LIST > join_list)
 Go through a list of tables and join nests, recursively, and repoint its select_lex pointer. More...
 
void empty_order_list (SELECT_LEX *sl)
 Empty the ORDER list. More...
 
bool setup_join_cond (THD *thd, List< TABLE_LIST > *tables, bool in_update)
 Resolve join conditions for a join nest. More...
 
bool find_common_table_expr (THD *thd, Table_ident *table_id, TABLE_LIST *tl, Parse_context *pc, bool *found)
 Tries to match an identifier to the CTEs in scope; if matched, it modifies *table_name, *tl', and the matched with-list-element. More...
 

Private Attributes

SELECT_LEXnext
 Intrusive double-linked list of all query blocks within the same query expression. More...
 
SELECT_LEX ** prev
 
SELECT_LEX_UNITmaster
 The query expression containing this query block. More...
 
SELECT_LEX_UNITslave
 The first query expression contained within this query block. More...
 
SELECT_LEXlink_next
 Intrusive double-linked global list of query blocks. More...
 
SELECT_LEX ** link_prev
 
Query_resultm_query_result
 Result of this query block. More...
 
ulonglong m_base_options
 Options assigned from parsing and throughout resolving, should not be modified after resolving is done. More...
 
ulonglong m_active_options
 Active options. More...
 
Itemm_where_cond
 Condition to be evaluated after all tables in a query block are joined. More...
 
Itemm_having_cond
 Condition to be evaluated on grouped rows after grouping. More...
 
bool m_agg_func_used
 
bool m_json_agg_func_used
 
bool m_empty_query
 True if query block does not generate any rows before aggregation, determined during preparation (not optimization). More...
 
Mem_root_array< Item_exists_subselect * > * sj_candidates
 Pointer to collection of subqueries candidate for semi/antijoin conversion. More...
 

Static Private Attributes

static const char * type_str [static_cast< int >(enum_explain_type::EXPLAIN_total)]
 

Friends

class SELECT_LEX_UNIT
 

Detailed Description

This class represents a query block, aka a query specification, which is a query consisting of a SELECT keyword, followed by a table list, optionally followed by a WHERE clause, a GROUP BY, etc.

Member Enumeration Documentation

◆ Resolve_place

Three fields used by semi-join transformations to know when semi-join is possible, and in which condition tree the subquery predicate is located.

Enumerator
RESOLVE_NONE 
RESOLVE_JOIN_NEST 
RESOLVE_CONDITION 
RESOLVE_HAVING 
RESOLVE_SELECT_LIST 

Constructor & Destructor Documentation

◆ SELECT_LEX()

SELECT_LEX::SELECT_LEX ( Item where,
Item having 
)


Construct and initialize SELECT_LEX object.

Note
the group_by and order_by lists below will probably be added to the constructor when the parser is converted into a true bottom-up design.

SQL_I_LIST<ORDER> *group_by, SQL_I_LIST<ORDER> order_by

Member Function Documentation

◆ accept()

bool SELECT_LEX::accept ( Select_lex_visitor visitor)

Accept function for SELECT and DELETE.

Parameters
visitorSelect_lex_visitor Object

◆ active_options()

ulonglong SELECT_LEX::active_options ( ) const
inline
Returns
the active query options

◆ add_active_options()

void SELECT_LEX::add_active_options ( ulonglong  options)
inline

Adjust the active option set.

◆ add_base_options()

void SELECT_LEX::add_base_options ( ulonglong  options)
inline

Add base options to a query block, also update active options.

◆ add_ftfunc_to_list()

bool SELECT_LEX::add_ftfunc_to_list ( Item_func_match func)

◆ add_item_to_list()

bool SELECT_LEX::add_item_to_list ( Item item)

◆ add_order_to_list()

void SELECT_LEX::add_order_to_list ( ORDER order)

◆ add_tables()

bool SELECT_LEX::add_tables ( THD thd,
const Mem_root_array< Table_ident *> *  tables,
ulong  table_options,
thr_lock_type  lock_type,
enum_mdl_type  mdl_type 
)

Add tables from an array to a list of used tables.

Parameters
thdCurrent session.
tablesTables to add.
table_optionsA set of the following bits:
  • TL_OPTION_UPDATING : Table will be updated,
  • TL_OPTION_FORCE_INDEX : Force usage of index,
  • TL_OPTION_ALIAS : an alias in multi table DELETE.
lock_typeHow table should be locked.
mdl_typeType of metadata lock to acquire on the table.
Returns
true if error (reported), otherwise false.

◆ agg_func_used()

bool SELECT_LEX::agg_func_used ( ) const
inline

◆ all_tables_map()

table_map SELECT_LEX::all_tables_map ( ) const
inline
Returns
a map of all tables references in the query block

◆ cleanup()

bool SELECT_LEX::cleanup ( THD thd,
bool  full 
)

Cleanup this subtree (this SELECT_LEX and all nested SELECT_LEXes and SELECT_LEX_UNITs).

Cleanup after preparation or one round of execution.

Parameters
thdthread handle
fullif false only partial cleanup is done, JOINs and JOIN_TABs are kept to provide info for EXPLAIN CONNECTION; if true, complete cleanup is done, all JOINs are freed.
Returns
false if previous execution was successful, and true otherwise

◆ cleanup_all_joins()

void SELECT_LEX::cleanup_all_joins ( )

◆ cut_subtree()

void SELECT_LEX::cut_subtree ( )
inline

◆ find_table_by_name()

TABLE_LIST * SELECT_LEX::find_table_by_name ( const Table_ident ident)

Finds a (possibly unresolved) table reference in the from clause by name.

There is a hack in the parser which adorns table references with the current database. This function piggy-backs on that hack to find fully qualified table references without having to resolve the name.

Parameters
identThe table name, may be qualified or unqualified.
Return values
NULLIf not found.

◆ first_inner_unit()

SELECT_LEX_UNIT* SELECT_LEX::first_inner_unit ( ) const
inline

◆ fix_prepare_information()

void SELECT_LEX::fix_prepare_information ( THD thd)

◆ fix_prepare_information_for_order()

void SELECT_LEX::fix_prepare_information_for_order ( THD thd,
SQL_I_List< ORDER > *  list,
Group_list_ptrs **  list_ptrs 
)
private

Helper for fix_prepare_information()

◆ get_in_sum_expr()

uint SELECT_LEX::get_in_sum_expr ( ) const
inline

◆ get_item_list()

List<Item>* SELECT_LEX::get_item_list ( )
inline

◆ get_limit()

ha_rows SELECT_LEX::get_limit ( THD thd)


Get limit.

Evaluate limit item if necessary.

Returns
Limit of rows in result.

◆ get_offset()

ha_rows SELECT_LEX::get_offset ( THD thd)

Get offset for LIMIT.

Evaluate offset item if necessary.

Returns
Number of rows to skip.

◆ get_optimizable_conditions()

bool SELECT_LEX::get_optimizable_conditions ( THD thd,
Item **  new_where,
Item **  new_having 
)

Returns disposable copies of WHERE/HAVING/ON conditions.

This function returns a copy which can be thrashed during this execution of the statement. Only AND/OR items are trashable! If in conventional execution, no copy is created, the permanent clauses are returned instead, as trashing them is no problem.

Parameters
thdthread handle
[out]new_wherecopy of WHERE
[out]new_havingcopy of HAVING (if passed pointer is not NULL)

Copies of join (ON) conditions are placed in TABLE_LIST::m_join_cond_optim.

Returns
true if OOM

◆ get_table_list()

TABLE_LIST* SELECT_LEX::get_table_list ( ) const
inline

◆ get_type_str() [1/2]

const char* SELECT_LEX::get_type_str ( )
inline

Lookup for a type string.

◆ get_type_str() [2/2]

static const char* SELECT_LEX::get_type_str ( enum_explain_type  type)
inlinestatic

◆ has_ft_funcs()

bool SELECT_LEX::has_ft_funcs ( ) const
inline
Returns
true if query block references full-text functions

◆ has_limit()

bool SELECT_LEX::has_limit ( ) const
inline
Returns
true if this query block has a LIMIT clause

◆ has_sj_candidates()

bool SELECT_LEX::has_sj_candidates ( ) const
inline

◆ has_windows()

bool SELECT_LEX::has_windows ( ) const
inline
Returns
true if query block contains window functions

◆ having_cond()

Item* SELECT_LEX::having_cond ( ) const
inline

◆ include_chain_in_global()

void SELECT_LEX::include_chain_in_global ( SELECT_LEX **  start)

Include chain of query blocks into global list.

Parameters
start- Pointer to start of list

◆ include_down()

void SELECT_LEX::include_down ( LEX lex,
SELECT_LEX_UNIT outer 
)

Include query block inside a query expression.

Add this query block below the specified query expression.

Parameters
lexContaining LEX object
outerQuery expression that query block is added to.
Note
that this query block can never have any underlying query expressions, hence it is not necessary to e.g. renumber those, like e.g. SELECT_LEX_UNIT::include_down() does.

◆ include_in_global()

void SELECT_LEX::include_in_global ( SELECT_LEX **  plink)

Include query block into global list.

Parameters
plink- Pointer to start of list

◆ include_neighbour()

void SELECT_LEX::include_neighbour ( LEX lex,
SELECT_LEX before 
)

Include a query block next to another query block.

Add this query block after the specified query block.

Parameters
lexContaining LEX object
beforeQuery block that this object is added after.

◆ include_standalone()

void SELECT_LEX::include_standalone ( SELECT_LEX_UNIT outer,
SELECT_LEX **  ref 
)

Include query block inside a query expression, but do not link.

Include query block within the supplied unit.

Do not link the query block into the global chain of query blocks.

This function is exclusive for SELECT_LEX_UNIT::add_fake_select_lex() - use it with caution.

Parameters
outerQuery expression this node is included below.
refHandle to the caller's pointer to this node.

◆ init_order()

void SELECT_LEX::init_order ( )
inline

◆ invalidate()

void SELECT_LEX::invalidate ( )

Invalidate by nulling out pointers to other SELECT_LEX_UNITs and SELECT_LEXes.

◆ is_cacheable()

bool SELECT_LEX::is_cacheable ( ) const
inline

◆ is_dependent()

bool SELECT_LEX::is_dependent ( ) const
inline

◆ is_distinct()

bool SELECT_LEX::is_distinct ( ) const
inline
Returns
true if this query block contains DISTINCT at start of select list

◆ is_empty_query()

bool SELECT_LEX::is_empty_query ( ) const
inline
Returns
true if query block is found during preparation to produce no data. Notice that if query is implicitly grouped, an aggregation row will still be returned.

◆ is_explicitly_grouped()

bool SELECT_LEX::is_explicitly_grouped ( ) const
inline
Returns
true if query block is explicitly grouped (non-empty GROUP BY)

◆ is_grouped()

bool SELECT_LEX::is_grouped ( ) const
inline
Returns
true if this query block is explicitly or implicitly grouped.
Note
a query with DISTINCT is not considered to be aggregated.
in standard SQL, a query with HAVING is defined as grouped, however MySQL allows HAVING without any aggregation to be the same as WHERE.

◆ is_implicitly_grouped()

bool SELECT_LEX::is_implicitly_grouped ( ) const
inline
Returns
true if this query block is implicitly grouped, ie it is not explicitly grouped but contains references to set functions. The query will return max. 1 row (
See also
also is_single_grouped()).

◆ is_ordered()

bool SELECT_LEX::is_ordered ( ) const
inline
Returns
true if this query block contains an ORDER BY clause.
Note
returns false if ORDER BY has been eliminated, e.g if the query can return max. 1 row.

◆ is_part_of_union()

bool SELECT_LEX::is_part_of_union ( ) const
inline

Return true if this query block is part of a UNION.

◆ is_recursive()

bool SELECT_LEX::is_recursive ( ) const
inline
Returns
true if query block is a recursive member of a recursive unit

◆ is_single_grouped()

bool SELECT_LEX::is_single_grouped ( ) const
inline

True if this query block is implicitly grouped.

Note
Not reliable before name resolution.
Returns
true if this query block is implicitly grouped and returns exactly one row, which happens when it does not have a HAVING clause.
Remarks
This function is currently unused.

◆ is_straight_join()

bool SELECT_LEX::is_straight_join ( )
inline
Returns
true If STRAIGHT_JOIN applies to all tables.
false Else.

false for exmaple in t1 STRAIGHT_JOIN t2 JOIN t3.

◆ json_agg_func_used()

bool SELECT_LEX::json_agg_func_used ( ) const
inline

◆ last_select()

SELECT_LEX* SELECT_LEX::last_select ( )
inline

◆ make_active_options()

void SELECT_LEX::make_active_options ( ulonglong  added_options,
ulonglong  removed_options 
)

Make active options from base options, supplied options and environment:

Make active options from base options, supplied options, any statement options and the environment.

Parameters
added_optionsOptions that are added to the active options
removed_optionsOptions that are removed from the active options

◆ mark_as_dependent()

void SELECT_LEX::mark_as_dependent ( SELECT_LEX last,
bool  aggregate 
)

Mark all query blocks from this to 'last' as dependent.

Parameters
lastPointer to last SELECT_LEX struct, before which all SELECT_LEX are marked as as dependent.
aggregatetrue if the dependency is due to a set function, such as COUNT(*), which is aggregated within the query block 'last'. Such functions must have a dependency on all tables of the aggregating query block.
Note
last should be reachable from this SELECT_LEX

◆ master_unit()

SELECT_LEX_UNIT* SELECT_LEX::master_unit ( ) const
inline

◆ next_select()

SELECT_LEX* SELECT_LEX::next_select ( ) const
inline

◆ next_select_in_list()

SELECT_LEX* SELECT_LEX::next_select_in_list ( ) const
inline

◆ outer_select()

SELECT_LEX* SELECT_LEX::outer_select ( ) const
inline

◆ print()

void SELECT_LEX::print ( const THD thd,
String str,
enum_query_type  query_type 
)

◆ print_delete()

void SELECT_LEX::print_delete ( const THD thd,
String str,
enum_query_type  query_type 
)

Print detail of the DELETE statement.

Parameters
thdThread handler
[out]strString of output
query_typeOptions to print out string output

◆ print_delete_options()

void SELECT_LEX::print_delete_options ( String str)

Print DELETE options.

Parameters
[out]strString of output

◆ print_error()

bool SELECT_LEX::print_error ( const THD thd,
String str 
)

Print error.

Parameters
thdThread handler
[out]strString of output
Returns
Return values
falseIf there is no error
trueelse

◆ print_from_clause()

void SELECT_LEX::print_from_clause ( const THD thd,
String str,
enum_query_type  query_type 
)

Print list of tables in FROM clause.

Parameters
thdThread handler
[out]strString of output
query_typeOptions to print out string output

◆ print_group_by()

void SELECT_LEX::print_group_by ( const THD thd,
String str,
enum_query_type  query_type 
)

Print list of items in GROUP BY clause.

Parameters
thdThread handle
[out]strString of output
query_typeOptions to print out string output

◆ print_having()

void SELECT_LEX::print_having ( const THD thd,
String str,
enum_query_type  query_type 
)

Print list of items in HAVING clause.

Parameters
thdThread handle
[out]strString of output
query_typeOptions to print out string output

◆ print_hints()

void SELECT_LEX::print_hints ( const THD thd,
String str,
enum_query_type  query_type 
)

Print detail of Hints.

Parameters
thdThread handler
[out]strString of output
query_typeOptions to print out string output

◆ print_insert()

void SELECT_LEX::print_insert ( const THD thd,
String str,
enum_query_type  query_type 
)

Print detail of the INSERT statement.

Parameters
thdThread handler
[out]strString of output
query_typeOptions to print out string output

USES: 'INSERT INTO table (fields) VALUES values' syntax over 'INSERT INTO table SET field = value, ...'

◆ print_insert_fields()

void SELECT_LEX::print_insert_fields ( const THD thd,
String str,
enum_query_type  query_type 
)

Print column list to be inserted into.

Used in INSERT.

Parameters
thdThread handle
[out]strString of output
query_typeOptions to print out string output

◆ print_insert_options()

void SELECT_LEX::print_insert_options ( String str)

Print INSERT options.

Parameters
[out]strString of output

◆ print_insert_values()

void SELECT_LEX::print_insert_values ( const THD thd,
String str,
enum_query_type  query_type 
)

Print list of values to be inserted.

Used in INSERT.

Parameters
thdThread handle
[out]strString of output
query_typeOptions to print out string output

◆ print_item_list()

void SELECT_LEX::print_item_list ( const THD thd,
String str,
enum_query_type  query_type 
)

Print list of items in SELECT_LEX object.

Parameters
thdThread handle
[out]strString of output
query_typeOptions to print out string output
Note
that 'INTO variable' clauses are not printed

◆ print_limit()

void SELECT_LEX::print_limit ( const THD thd,
String str,
enum_query_type  query_type 
)

◆ print_order()

void SELECT_LEX::print_order ( const THD thd,
String str,
ORDER order,
enum_query_type  query_type 
)
static

◆ print_order_by()

void SELECT_LEX::print_order_by ( const THD thd,
String str,
enum_query_type  query_type 
)

Print list of items in ORDER BY clause.

Parameters
thdThread handle
[out]strString of output
query_typeOptions to print out string output

◆ print_select()

void SELECT_LEX::print_select ( const THD thd,
String str,
enum_query_type  query_type 
)

Print detail of the SELECT_LEX object.

Parameters
thdThread handler
query_typeOptions to print out string output
[out]strString of output.

◆ print_select_options()

void SELECT_LEX::print_select_options ( String str)

Print select options.

Parameters
[out]strString of output

◆ print_table_references()

void SELECT_LEX::print_table_references ( const THD thd,
String str,
TABLE_LIST table_list,
enum_query_type  query_type 
)

Print list of tables.

Parameters
thdThread handler
[out]strString of output
table_listTABLE_LIST object
query_typeOptions to print out string output

◆ print_update()

void SELECT_LEX::print_update ( const THD thd,
String str,
enum_query_type  query_type 
)

Print detail of the UPDATE statement.

Parameters
thdThread handler
[out]strString of output
query_typeOptions to print out string output

◆ print_update_list()

void SELECT_LEX::print_update_list ( const THD thd,
String str,
enum_query_type  query_type,
List< Item fields,
List< Item values 
)

Print assignments list.

Used in UPDATE and INSERT ... ON DUPLICATE KEY UPDATE ...

Parameters
thdThread handle
[out]strString of output
query_typeOptions to print out string output
fieldsList columns to be assigned.
valuesList of values.

◆ print_update_options()

void SELECT_LEX::print_update_options ( String str)

Print UPDATE options.

Parameters
[out]strString of output

◆ print_where_cond()

void SELECT_LEX::print_where_cond ( const THD thd,
String str,
enum_query_type  query_type 
)

Print list of conditions in WHERE clause.

Parameters
thdThread handle
[out]strString of output
query_typeOptions to print out string output

◆ print_windows()

void SELECT_LEX::print_windows ( const THD thd,
String str,
enum_query_type  query_type 
)

Print details of Windowing functions.

Parameters
thdThread handler
[out]strString of output
query_typeOptions to print out string output

◆ query_result()

Query_result* SELECT_LEX::query_result ( ) const
inline

◆ remove_base_options()

void SELECT_LEX::remove_base_options ( ulonglong  options)
inline

Remove base options from a query block.

Active options are also updated, and we assume here that "extra" options cannot override removed base options.

◆ remove_semijoin_candidate()

void SELECT_LEX::remove_semijoin_candidate ( Item_exists_subselect sub_query)

Removes pointer to a sub query from sj_candidates array.

Called from Item_subselect::clean_up_after_removal to clean the pointer to the subquery which is getting destroyed.

Parameters
sub_querythe sub_query whose pointer needs to be removed

◆ renumber()

void SELECT_LEX::renumber ( LEX lex)

Renumber query blocks of contained query expressions.

Renumber select_lex object, and apply renumbering recursively to contained objects.

Parameters
lexContaining LEX object

◆ semijoin_enabled()

bool SELECT_LEX::semijoin_enabled ( THD thd) const

Returns whether semi-join is enabled for this query block.

See also
Opt_hints_qb::semijoin_enabled for details on how hints affect this decision. If there are no hints for this query block, optimizer_switch setting determines whether semi-join is used.
Parameters
thdPointer to THD object for session. Used to access optimizer_switch
Returns
true if semijoin is enabled, false otherwise

◆ set_agg_func_used()

void SELECT_LEX::set_agg_func_used ( bool  val)
inline

◆ set_base_options()

void SELECT_LEX::set_base_options ( ulonglong  options_arg)
inline

Set base options for a query block (and active options too)

◆ set_braces()

bool SELECT_LEX::set_braces ( bool  value)

◆ set_context()

bool SELECT_LEX::set_context ( Name_resolution_context outer_context)

Assign a default name resolution object for this query block.

Set the name resolution context for the specified query block.

Parameters
outer_contextOuter name resolution context. NULL if none or it will be set later.

◆ set_empty_query()

void SELECT_LEX::set_empty_query ( )
inline

Set query block as returning no data.

◆ set_having_cond()

void SELECT_LEX::set_having_cond ( Item cond)
inline

◆ set_json_agg_func_used()

void SELECT_LEX::set_json_agg_func_used ( bool  val)
inline

◆ set_query_result()

void SELECT_LEX::set_query_result ( Query_result result)
inline

◆ set_sj_candidates()

void SELECT_LEX::set_sj_candidates ( Mem_root_array< Item_exists_subselect *> *  sj_cand)
inline

◆ set_tables_readonly()

void SELECT_LEX::set_tables_readonly ( )
inline

Set associated tables as read_only, ie.

they cannot be inserted into, updated or deleted from during this statement. Commonly used for query blocks that are part of derived tables or views that are materialized.

◆ set_where_cond()

void SELECT_LEX::set_where_cond ( Item cond)
inline

◆ setup_base_ref_items()

bool SELECT_LEX::setup_base_ref_items ( THD thd)

Setup the array containing references to base items.

◆ subquery_strategy()

Item_exists_subselect::enum_exec_method SELECT_LEX::subquery_strategy ( THD thd) const

Returns which subquery execution strategies can be used for this query block.

Parameters
thdPointer to THD object for session. Used to access optimizer_switch
Return values
EXEC_MATERIALIZATIONSubquery Materialization should be used
EXEC_EXISTSIn-to-exists execution should be used
EXEC_EXISTS_OR_MATA cost-based decision should be made

◆ test_limit()

bool SELECT_LEX::test_limit ( )

◆ type()

enum_explain_type SELECT_LEX::type ( )

Lookup for SELECT_LEX type.

◆ update_semijoin_strategies()

void SELECT_LEX::update_semijoin_strategies ( THD thd)

Update available semijoin strategies for semijoin nests.

Available semijoin strategies needs to be updated on every execution since optimizer_switch setting may have changed.

Parameters
thdPointer to THD object for session. Used to access optimizer_switch

◆ validate_base_options()

bool SELECT_LEX::validate_base_options ( LEX lex,
ulonglong  options_arg 
) const

Validate base options for a query block.

Parameters
lexLEX of current statement
options_argbase options for a SELECT statement.
Returns
false if success, true if validation failed

These options are supported, per DML statement:

SELECT: SELECT_STRAIGHT_JOIN SELECT_HIGH_PRIORITY SELECT_DISTINCT SELECT_ALL SELECT_SMALL_RESULT SELECT_BIG_RESULT OPTION_BUFFER_RESULT OPTION_FOUND_ROWS OPTION_SELECT_FOR_SHOW DELETE: OPTION_QUICK LOW_PRIORITY INSERT: LOW_PRIORITY HIGH_PRIORITY UPDATE: LOW_PRIORITY

Note that validation is only performed for SELECT statements.

◆ validate_outermost_option()

bool SELECT_LEX::validate_outermost_option ( LEX lex,
const char *  option 
) const

Check if an option that can be used only for an outer-most query block is applicable to this query block.

Parameters
lexLEX of current statement
optionoption name to output within the error message
Returns
false if valid, true if invalid, error is sent to client

◆ walk()

bool SELECT_LEX::walk ( Item_processor  processor,
enum_walk  walk,
uchar arg 
)

◆ where_cond()

Item* SELECT_LEX::where_cond ( ) const
inline

Friends And Related Function Documentation

◆ SELECT_LEX_UNIT

friend class SELECT_LEX_UNIT
friend

Member Data Documentation

◆ all_fields

List<Item> SELECT_LEX::all_fields

to store all expressions used in query

◆ allow_merge_derived

bool SELECT_LEX::allow_merge_derived

Allow merge of immediate unnamed derived tables.

◆ base_ref_items

Ref_item_array SELECT_LEX::base_ref_items

Array of pointers to "base" items; one each for every selected expression and referenced item in the query block.

All references to fields are to buffers associated with the primary input tables.

◆ between_count

uint SELECT_LEX::between_count

number of between predicates in where/having/on

◆ braces

bool SELECT_LEX::braces

SELECT ...

UNION (SELECT ... ) <- this braces

◆ cond_count

uint SELECT_LEX::cond_count

number of arguments of and/or/xor in where/having/on

◆ cond_value

Item::cond_result SELECT_LEX::cond_value

Saved values of the WHERE and HAVING clauses.

Allowed values are:

  • COND_UNDEF if the condition was not specified in the query or if it has not been optimized yet
  • COND_TRUE if the condition is always true
  • COND_FALSE if the condition is impossible
  • COND_OK otherwise

◆ context

Name_resolution_context SELECT_LEX::context

Context for name resolution for all column references except columns from joined tables.

◆ db

char* SELECT_LEX::db

◆ derived_table_count

uint SELECT_LEX::derived_table_count

Number of derived tables and views in this query block.

◆ embedding

TABLE_LIST* SELECT_LEX::embedding

table embedding the above list

◆ end_lateral_table

TABLE_LIST* SELECT_LEX::end_lateral_table

◆ exclude_from_table_unique_test

bool SELECT_LEX::exclude_from_table_unique_test

exclude this query block from unique_table() check

◆ explicit_limit

bool SELECT_LEX::explicit_limit

explicit LIMIT clause is used

◆ fields_list

List<Item>& SELECT_LEX::fields_list

hold field list

◆ first_context

Name_resolution_context* SELECT_LEX::first_context

Pointer to first object in list of Name res context objects that have this query block as the base query block.

Includes field "context" which is embedded in this query block.

◆ first_execution

bool SELECT_LEX::first_execution

This variable is required to ensure proper work of subqueries and stored procedures.

Generally, one should use the states of Query_arena to determine if it's a statement prepare or first execution of a stored procedure. However, in case when there was an error during the first execution of a stored procedure, the SP body is not expelled from the SP cache. Therefore, a deeply nested subquery might be left unoptimized. So we need this per-subquery variable to inidicate the optimization/execution state of every subquery. Prepared statements work OK in that regard, as in case of an error during prepare the PS is not created.

◆ ftfunc_list

List<Item_func_match>* SELECT_LEX::ftfunc_list

Usually a pointer to ftfunc_list_alloc, but in UNION this is used to create fake select_lex that consolidates result fields of UNION.

◆ ftfunc_list_alloc

List<Item_func_match> SELECT_LEX::ftfunc_list_alloc

◆ group_fix_field

bool SELECT_LEX::group_fix_field

true when GROUP BY fix field called in processing of this query block

◆ group_list

SQL_I_List<ORDER> SELECT_LEX::group_list

GROUP BY clause.

This list may be mutated during optimization (by remove_const()), so for prepared statements, we keep a copy of the ORDER.next pointers in group_list_ptrs, and re-establish the original list before each execution.

◆ group_list_ptrs

Group_list_ptrs* SELECT_LEX::group_list_ptrs

◆ has_aj_nests

bool SELECT_LEX::has_aj_nests
See also
has_sj_nests; counts antijoin nests.

◆ has_sj_nests

bool SELECT_LEX::has_sj_nests

True if query block has semi-join nests merged into it.

Notice that this is updated earlier than sj_nests, so check this if info is needed before the full resolver process is complete.

◆ having_fix_field

bool SELECT_LEX::having_fix_field

true when having fix field called in processing of this query block

◆ having_value

Item::cond_result SELECT_LEX::having_value

◆ hidden_group_field_count

int SELECT_LEX::hidden_group_field_count

Number of GROUP BY expressions added to all_fields.

◆ hidden_order_field_count

int SELECT_LEX::hidden_order_field_count

How many expressions are part of the order by but not select list.

◆ in_sum_expr

uint SELECT_LEX::in_sum_expr

Parse context: is inside a set function if this is positive.

◆ inner_sum_func_list

Item_sum* SELECT_LEX::inner_sum_func_list

Circular linked list of sum func in nested selects.

◆ is_item_list_lookup

bool SELECT_LEX::is_item_list_lookup

◆ item_list

List<Item> SELECT_LEX::item_list

List of columns and expressions: SELECT: Columns and expressions in the SELECT list.

UPDATE: Columns in the SET clause.

◆ join

JOIN* SELECT_LEX::join

After optimization it is pointer to corresponding JOIN.

This member should be changed only when THD::LOCK_query_plan mutex is taken.

◆ join_list

List<TABLE_LIST>* SELECT_LEX::join_list

list for the currently parsed join

◆ leaf_table_count

uint SELECT_LEX::leaf_table_count

Number of leaf tables in this query block.

◆ leaf_tables

TABLE_LIST* SELECT_LEX::leaf_tables

Points to first leaf table of query block.

After setup_tables() is done, this is a list of base tables and derived tables. After derived tables processing is done, this is a list of base tables only. Use TABLE_LIST::next_leaf to traverse the list.

◆ link_next

SELECT_LEX* SELECT_LEX::link_next
private

Intrusive double-linked global list of query blocks.

◆ link_prev

SELECT_LEX** SELECT_LEX::link_prev
private

◆ linkage

enum sub_select_type SELECT_LEX::linkage

Describes context of this query block (e.g if it is a derived table).

◆ m_active_options

ulonglong SELECT_LEX::m_active_options
private

Active options.

Derived from base options, modifiers added during resolving and values from session variable option_bits. Since the latter may change, active options are refreshed per execution of a statement.

◆ m_agg_func_used

bool SELECT_LEX::m_agg_func_used
private

◆ m_base_options

ulonglong SELECT_LEX::m_base_options
private

Options assigned from parsing and throughout resolving, should not be modified after resolving is done.

◆ m_empty_query

bool SELECT_LEX::m_empty_query
private

True if query block does not generate any rows before aggregation, determined during preparation (not optimization).

◆ m_having_cond

Item* SELECT_LEX::m_having_cond
private

Condition to be evaluated on grouped rows after grouping.

◆ m_json_agg_func_used

bool SELECT_LEX::m_json_agg_func_used
private

◆ m_query_result

Query_result* SELECT_LEX::m_query_result
private

Result of this query block.

◆ m_where_cond

Item* SELECT_LEX::m_where_cond
private

Condition to be evaluated after all tables in a query block are joined.

After all permanent transformations have been conducted by SELECT_LEX::prepare(), this condition is "frozen", any subsequent changes to it must be done with change_item_tree(), unless they only modify AND/OR items and use a copy created by SELECT_LEX::get_optimizable_conditions(). Same is true for 'having_cond'.

◆ m_windows

List<Window> SELECT_LEX::m_windows

All windows defined on the select, both named and inlined.

◆ master

SELECT_LEX_UNIT* SELECT_LEX::master
private

The query expression containing this query block.

◆ materialized_derived_table_count

uint SELECT_LEX::materialized_derived_table_count

Number of materialized derived tables and views in this query block.

◆ max_equal_elems

uint SELECT_LEX::max_equal_elems

maximal number of elements in multiple equalities

◆ n_child_sum_items

uint SELECT_LEX::n_child_sum_items

Number of Item_sum-derived objects in children and descendant SELECTs.

◆ n_sum_items

uint SELECT_LEX::n_sum_items

Number of Item_sum-derived objects in this SELECT.

◆ nest_level

int SELECT_LEX::nest_level

Nesting level of query block, outer-most query block has level 0, its subqueries have level 1, etc.

See also
also sql/item_sum.h.

◆ next

SELECT_LEX* SELECT_LEX::next
private

Intrusive double-linked list of all query blocks within the same query expression.

◆ no_table_names_allowed

bool SELECT_LEX::no_table_names_allowed

used for global order by

◆ offset_limit

Item* SELECT_LEX::offset_limit

LIMIT ... OFFSET clause, NULL if no offset is given.

◆ olap

enum olap_type SELECT_LEX::olap

Indicates whether this query block contains the WITH ROLLUP clause.

◆ opt_hints_qb

Opt_hints_qb* SELECT_LEX::opt_hints_qb

Query-block-level hints, for this query block.

◆ order_list

SQL_I_List<ORDER> SELECT_LEX::order_list

ORDER BY clause.

This list may be mutated during optimization (by remove_const()), so for prepared statements, we keep a copy of the ORDER.next pointers in order_list_ptrs, and re-establish the original list before each execution.

◆ order_list_ptrs

Group_list_ptrs* SELECT_LEX::order_list_ptrs

◆ outer_join

table_map SELECT_LEX::outer_join

Bitmap of all inner tables from outer joins.

◆ parent_lex

LEX* SELECT_LEX::parent_lex

Reference to LEX that this query block belongs to.

◆ parsing_place

enum_parsing_context SELECT_LEX::parsing_place

Parse context: indicates where the current expression is being parsed.

◆ partitioned_table_count

uint SELECT_LEX::partitioned_table_count

Number of partitioned tables.

◆ prev

SELECT_LEX** SELECT_LEX::prev
private

◆ recursive_dummy_unit

SELECT_LEX_UNIT* SELECT_LEX::recursive_dummy_unit

To pass the first steps of resolution, a recursive reference is made to be a dummy derived table; after the temporary table is created based on the non-recursive members' types, the recursive reference is made to be a reference to the tmp table.

Its dummy-derived-table unit is saved in this member, so that when the statement's execution ends, the reference can be restored to be a dummy derived table for the next execution, which is necessary if we have a prepared statement. WL#6570 should allow to remove this.

◆ recursive_reference

TABLE_LIST* SELECT_LEX::recursive_reference

If this query block is a recursive member of a recursive unit: the TABLE_LIST, in this recursive member, referencing the query name.

◆ resolve_nest

TABLE_LIST* SELECT_LEX::resolve_nest

Used when resolving outer join condition.

◆ resolve_place

Resolve_place SELECT_LEX::resolve_place

Indicates part of query being resolved.

◆ select_limit

Item* SELECT_LEX::select_limit

LIMIT clause, NULL if no limit is given.

◆ select_list_tables

table_map SELECT_LEX::select_list_tables

The set of those tables whose fields are referenced in the select list of this select level.

◆ select_n_having_items

uint SELECT_LEX::select_n_having_items

number of items in select_list and HAVING clause used to get number bigger then can be number of entries that will be added to all item list during split_sum_func

◆ select_n_where_fields

uint SELECT_LEX::select_n_where_fields

Number of fields used in select list or where clause of current select and all inner subselects.

◆ select_number

uint SELECT_LEX::select_number

Query block number (used for EXPLAIN)

◆ semijoin_disallowed

bool SELECT_LEX::semijoin_disallowed

Disables semi-join flattening when resolving a subtree in which flattening is not allowed.

The flag should be true while resolving items that are not on the AND-top-level of a condition tree.

◆ sj_candidates

Mem_root_array<Item_exists_subselect *>* SELECT_LEX::sj_candidates
private

Pointer to collection of subqueries candidate for semi/antijoin conversion.

Template parameter is "true": no need to run DTORs on pointers.

◆ sj_nests

List<TABLE_LIST> SELECT_LEX::sj_nests

List of semi-join nests generated for this query block.

◆ sj_pullout_done

bool SELECT_LEX::sj_pullout_done

True when semi-join pull-out processing is complete.

◆ skip_local_transforms

bool SELECT_LEX::skip_local_transforms

True: skip local transformations during prepare() call (used by INSERT)

◆ slave

SELECT_LEX_UNIT* SELECT_LEX::slave
private

The first query expression contained within this query block.

◆ subquery_in_having

bool SELECT_LEX::subquery_in_having

HAVING clause contains subquery => we can't close tables before query processing end even if we use temporary table.

◆ table_func_count

uint SELECT_LEX::table_func_count

Number of table functions in this query block.

◆ table_list

SQL_I_List<TABLE_LIST> SELECT_LEX::table_list

List of tables in FROM clause - use TABLE_LIST::next_local to traverse.

◆ top_join_list

List<TABLE_LIST> SELECT_LEX::top_join_list

join list of the top level

◆ type_str

const char * SELECT_LEX::type_str
staticprivate
Initial value:
= {
"NONE", "PRIMARY", "SIMPLE", "DERIVED",
"SUBQUERY", "UNION", "UNION RESULT", "MATERIALIZED"}
Note
The order of the elements of this array must correspond to the order of elements in type_enum

◆ uncacheable

uint8 SELECT_LEX::uncacheable

result of this query can't be cached, bit field, can be : UNCACHEABLE_DEPENDENT UNCACHEABLE_RAND UNCACHEABLE_SIDEEFFECT

◆ with_sum_func

bool SELECT_LEX::with_sum_func

True if contains or aggregates set functions.

Note
this is wrong when a locally found set function is aggregated in an outer query block.

◆ with_wild

uint SELECT_LEX::with_wild

Number of wildcards used in the SELECT list.

For example, SELECT *, t1.*, catalog.t2.* FROM t0, t1, t2; has 3 wildcards.


The documentation for this class was generated from the following files: