MySQL  8.0.27
Source Code Documentation
sql_resolver.cc File Reference

Implementation of name resolution stage. More...

#include "sql/sql_resolver.h"
#include <sys/types.h>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <unordered_map>
#include <utility>
#include <vector>
#include "field_types.h"
#include "lex_string.h"
#include "mem_root_deque.h"
#include "my_alloc.h"
#include "my_bitmap.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sqlcommand.h"
#include "my_sys.h"
#include "my_table_map.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "prealloced_array.h"
#include "sql/aggregate_check.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/check_stack.h"
#include "sql/current_thd.h"
#include "sql/derror.h"
#include "sql/enum_query_type.h"
#include "sql/error_handler.h"
#include "sql/field.h"
#include "sql/item.h"
#include "sql/item_cmpfunc.h"
#include "sql/item_func.h"
#include "sql/item_row.h"
#include "sql/item_subselect.h"
#include "sql/item_sum.h"
#include "sql/join_optimizer/join_optimizer.h"
#include "sql/mdl.h"
#include "sql/mem_root_array.h"
#include "sql/nested_join.h"
#include "sql/opt_hints.h"
#include "sql/opt_trace.h"
#include "sql/opt_trace_context.h"
#include "sql/parse_tree_nodes.h"
#include "sql/query_options.h"
#include "sql/query_result.h"
#include "sql/range_optimizer/partition_pruning.h"
#include "sql/range_optimizer/range_optimizer.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_cmd.h"
#include "sql/sql_const.h"
#include "sql/sql_derived.h"
#include "sql/sql_error.h"
#include "sql/sql_executor.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_optimizer.h"
#include "sql/sql_select.h"
#include "sql/sql_test.h"
#include "sql/sql_union.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/thd_raii.h"
#include "sql/thr_malloc.h"
#include "sql/visible_fields.h"
#include "sql/window.h"
#include "template_utils.h"
#include "thr_lock.h"

Classes

class  Semijoin_decorrelation
 Context object used by semijoin equality decorrelation code. More...
 
struct  Lifted_fields_map
 

Functions

static bool simplify_const_condition (THD *thd, Item **cond, bool remove_cond, bool *ret_cond_value)
 Try to replace a const condition with a simple constant. More...
 
static Itemcreate_rollup_switcher (THD *thd, Query_block *query_block, Item *item, int send_group_parts)
 
static void update_used_tables_for_join (mem_root_deque< TABLE_LIST * > *tables)
 Update used tables information for a JOIN expression. More...
 
static TABLE_LIST ** make_leaf_tables (TABLE_LIST **list, TABLE_LIST *tables)
 Make list of leaf tables of join table tree. More...
 
static void fix_tables_after_pullout (Query_block *parent_query_block, Query_block *removed_query_block, TABLE_LIST *tr, uint table_adjust, table_map lateral_deps)
 Update table reference information for conditions and expressions due to query blocks having been merged in from derived tables/views and due to semi-join transformation. More...
 
static bool decorrelate_equality (Semijoin_decorrelation &sj_decor, Item_func *func, bool *was_correlated)
 Try to decorrelate an (in)equality node. More...
 
static bool can_decorrelate_operator (Item_func *func, bool only_eq)
 
bool walk_join_list (mem_root_deque< TABLE_LIST * > &list, std::function< bool(TABLE_LIST *)> action)
 
static bool build_sj_exprs (THD *thd, mem_root_deque< Item * > *sj_outer_exprs, mem_root_deque< Item * > *sj_inner_exprs, Item_exists_subselect *subq_pred, Query_block *subq_query_block)
 Builds the list of SJ outer/inner expressions. More...
 
static bool replace_subcondition (THD *thd, Item **tree, Item *old_cond, Item *new_cond, bool do_fix_fields, bool *found_ptr=nullptr)
 Destructively replaces a sub-condition inside a condition tree. More...
 
void propagate_nullability (mem_root_deque< TABLE_LIST * > *tables, bool nullable)
 Propagate nullability into inner tables of outer join operation. More...
 
bool find_order_in_list (THD *thd, Ref_item_array ref_item_array, TABLE_LIST *tables, ORDER *order, mem_root_deque< Item * > *fields, bool is_group_field, bool is_window_order)
 Resolve an ORDER BY or GROUP BY column reference. More...
 
bool setup_order (THD *thd, Ref_item_array ref_item_array, TABLE_LIST *tables, mem_root_deque< Item * > *fields, ORDER *order)
 Resolve and setup list of expressions in ORDER BY clause. More...
 
static ReplaceResult wrap_grouped_expressions_for_rollup (Query_block *select, Item *item, Item *parent, unsigned argument_idx)
 Checks whether an item matches a grouped expression, creates an Item_rollup_group_item around it and replaces the reference to it with that item. More...
 
bool WalkAndReplace (THD *thd, Item *item, const function< ReplaceResult(Item *item, Item *parent, unsigned argument_idx)> &get_new_item)
 
bool validate_gc_assignment (const mem_root_deque< Item * > &fields, const mem_root_deque< Item * > &values, TABLE *table)
 validate_gc_assignment Check whether the other values except DEFAULT are assigned for generated columns. More...
 
static bool baptize_item (THD *thd, Item *item, int *field_no)
 Helper function to make names for columns of a derived table replacing a scalar or table subquery. More...
 
static bool update_context_to_derived (Item *expr, Query_block *new_derived)
 A minion of transform_grouped_to_derived. More...
 
static bool replace_aggregate_in_list (Item::Aggregate_replacement &info, bool was_hidden, mem_root_deque< Item * > *list, Ref_item_array *ref_item_array)
 A minion of transform_grouped_to_derived. More...
 
static bool collect_aggregates (Query_block *select, Item_sum::Collect_grouped_aggregate_info *aggregates)
 A minion of transform_grouped_to_derived. More...
 
static bool query_block_contains_subquery (Query_block *select, Query_expression *slu)
 A minion of transform_scalar_subqueries_to_join_with_derived. More...
 
static bool walk_join_conditions (mem_root_deque< TABLE_LIST * > &list, std::function< bool(Item **expr_p)> action, Item::Collect_scalar_subquery_info *info)
 
static void remember_transform (THD *thd, Query_block *select)
 Remember if this transform was performed. More...
 
bool is_correlated_predicate_eligible (Item *cor_pred)
 Called to check if the provided correlated predicate is eligible for transformation. More...
 
static bool extract_correlated_condition (THD *thd, Item **cond, Item **correlated_cond)
 Extracts the top level correlated condition in an OR condition. More...
 

Detailed Description

Implementation of name resolution stage.