29#ifndef SQL_LEX_INCLUDED
30#define SQL_LEX_INCLUDED
62#include "mysqld_error.h"
256#define TYPE_ENUM_FUNCTION 1
257#define TYPE_ENUM_PROCEDURE 2
258#define TYPE_ENUM_TRIGGER 3
259#define TYPE_ENUM_PROXY 4
287#define TL_OPTION_UPDATING 0x01
288#define TL_OPTION_IGNORE_LEAVES 0x02
289#define TL_OPTION_ALIAS 0x04
478#define INDEX_HINT_MASK_JOIN (1)
479#define INDEX_HINT_MASK_GROUP (1 << 1)
480#define INDEX_HINT_MASK_ORDER (1 << 2)
482#define INDEX_HINT_MASK_ALL \
483 (INDEX_HINT_MASK_JOIN | INDEX_HINT_MASK_GROUP | INDEX_HINT_MASK_ORDER)
663 for (
auto qt : query_terms<>()) {
664 if (qt->query_block() == qb)
return qt;
704 auto const setop = down_cast<Query_term_set_op *>(
m_query_term);
705 if (setop->m_last_distinct > 0)
706 return setop->m_children[setop->m_last_distinct]->query_block();
713 return down_cast<Query_term_set_op *>(
m_query_term)->m_last_distinct > 0;
957 bool optimize(
THD *thd,
TABLE *materialize_destination,
bool create_iterators,
958 bool finalize_access_paths);
1344 ulong table_options,
1644 const char *prefix);
1721 void cleanup(
bool full)
override;
1749 assert(
join ==
nullptr);
1829 bool optimize(
THD *thd,
bool finalize_access_paths);
2191 bool top,
bool in_sj,
Item **new_conds,
2192 uint *changelog =
nullptr);
2204 Item *join_cond,
bool left_outer,
2205 bool use_inner_join);
2209 bool reject_multiple_rows,
2210 Item *join_condition,
2211 Item *lifted_where_cond);
2219 bool added_card_check);
2270 Item **lifted_where);
2397 qt = down_cast<Query_term_unary *>(qt)->m_children[0];
2404 qt = down_cast<Query_term_unary *>(qt)->m_children[0];
2537 std::unique_ptr<malloc_unordered_map<std::string, Sroutine_hash_entry *>>
2590 *
this = std::move(*state);
2928 switch (accessed_table) {
2930 return "STMT_READS_TRANS_TABLE";
2933 return "STMT_READS_NON_TRANS_TABLE";
2936 return "STMT_READS_TEMP_TRANS_TABLE";
2939 return "STMT_READS_TEMP_NON_TRANS_TABLE";
2942 return "STMT_WRITES_TRANS_TABLE";
2945 return "STMT_WRITES_NON_TRANS_TABLE";
2948 return "STMT_WRITES_TEMP_TRANS_TABLE";
2951 return "STMT_WRITES_TEMP_NON_TRANS_TABLE";
2963#define BINLOG_DIRECT_ON \
2968#define BINLOG_DIRECT_OFF \
2973#define TRX_CACHE_EMPTY 0x33
2975#define TRX_CACHE_NOT_EMPTY 0xCC
2977#define IL_LT_REPEATABLE 0xAA
2979#define IL_GTE_REPEATABLE 0x55
3032 bool trx_cache_is_not_empty,
3033 uint tx_isolation) {
3034 bool unsafe =
false;
3036 if (in_multi_stmt_transaction_mode) {
3047 (
"RESULT %02X %02X %02X\n", condition,
3252 unsigned char yyGet() {
3268 unsigned char yyPeek()
const {
3277 unsigned char yyPeekn(
int n)
const {
3421 const char *end_ptr);
3486 const char *alias)
const {
4215 if (
unit ==
nullptr)
return;
4306 tr->restore_properties();
4347 bool copy_db_to(
char const **p_db,
size_t *p_db_length)
const;
4350 return copy_db_to(
const_cast<const char **
>(p_db), p_db_length);
4616 void reset(
const char *found_semicolon,
size_t length) {
4691 static void *
operator new(
size_t size)
noexcept {
4692 return (*THR_MALLOC)->Alloc(size);
4695 const std::nothrow_t &arg
4696 [[maybe_unused]] = std::nothrow)
noexcept {
4699 static void operator delete(
void *ptr [[maybe_unused]],
4700 size_t size [[maybe_unused]]) {
4703 static void operator delete(
4704 void *,
MEM_ROOT *,
const std::nothrow_t &)
noexcept {
4746 &valid_len, &len_error)) {
4749 hexbuf, string_val.
str + valid_len,
4750 static_cast<uint>(std::min<size_t>(string_val.
length - valid_len, 3)));
4771 std::string &invalid_sub_str) {
4776 &valid_len, &len_error)) {
4777 char printable_buff[32];
4779 printable_buff,
sizeof(printable_buff), string_val.
str + valid_len,
4780 static_cast<uint>(std::min<size_t>(string_val.
length - valid_len, 3)),
4782 invalid_sub_str = printable_buff;
4795 Item *item [[maybe_unused]],
4796 bool hidden [[maybe_unused]]) {
4798 if (
std::find(fields.begin(), fields.end(), item) != fields.end()) {
4801 assert(item->hidden == hidden);
4813 const char *legend);
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:571
uint32_t Access_bitmask
Definition: auth_acls.h:34
Data describing the table being created by CREATE TABLE or altered by ALTER TABLE.
Definition: sql_alter.h:204
Parser state for CTE subquery parser.
Definition: sql_lex.h:4668
Common_table_expr_parser_state()
Definition: sql_lex.cc:1154
PT_subquery * result
Definition: sql_lex.h:4672
Utility RAII class to save/modify/restore the condition_context information of a query block.
Definition: sql_lex.h:2411
enum_condition_context saved_value
Definition: sql_lex.h:2433
~Condition_context()
Definition: sql_lex.h:2427
Query_block * select
Definition: sql_lex.h:2432
Condition_context(Query_block *select_ptr, enum_condition_context new_type=enum_condition_context::NEITHER)
Definition: sql_lex.h:2413
Parser state for Derived table's condition parser.
Definition: sql_lex.h:4679
Item * result
Definition: sql_lex.h:4683
Derived_expr_parser_state()
Definition: sql_lex.cc:1157
Definition: event_parse_data.h:44
Parser state for single expression parser (.frm/DD stuff)
Definition: sql_lex.h:4658
Expression_parser_state()
Definition: sql_lex.cc:1151
Item * result
Definition: sql_lex.h:4662
Parser state for generated column expression parser (.frm/DD stuff)
Definition: sql_lex.h:4648
Value_generator * result
Definition: sql_lex.h:4652
Gcol_expr_parser_state()
Definition: sql_lex.cc:1148
Definition: sql_lex.h:486
LEX_CSTRING key_name
Definition: sql_lex.h:496
void print(const THD *thd, String *str)
Print an index hint.
Definition: sql_lex.cc:2658
index_clause_map clause
Definition: sql_lex.h:491
enum index_hint_type type
Definition: sql_lex.h:489
Index_hint(const char *str, uint length)
Definition: sql_lex.h:498
Definition: item_cmpfunc.h:2421
Definition: item_subselect.h:417
Definition: item_func.h:3345
Definition: item_func.h:3396
This class is used to implement operations like SET @variable or @variable:= expression.
Definition: item_func.h:3155
A wrapper Item that normally returns its parameter, but becomes NULL when processing rows for rollup.
Definition: item_func.h:1614
A wrapper Item that contains a number of aggregate items, one for each level of rollup (see Item_roll...
Definition: item_sum.h:2715
Definition: item_subselect.h:80
Class Item_sum is the base class used for special expressions that SQL calls 'set functions'.
Definition: item_sum.h:399
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
cond_result
Definition: item.h:922
@ COND_UNDEF
Definition: item.h:922
Definition: sql_optimizer.h:133
Definition: key_spec.h:67
Definition: sql_lex.h:3634
LEX_COLUMN(const String &x, const Access_bitmask &y)
Definition: sql_lex.h:3638
String column
Definition: sql_lex.h:3636
Access_bitmask rights
Definition: sql_lex.h:3637
Definition: sql_lex.h:3646
List< LEX_USER > * role_list
Definition: sql_lex.h:3655
void cleanup()
Definition: sql_lex.cc:5117
bool grant_as_used
Definition: sql_lex.h:3652
role_enum role_type
Definition: sql_lex.h:3653
LEX_USER * user
Definition: sql_lex.h:3654
LEX_GRANT_AS()
Definition: sql_lex.cc:5124
Definition: sql_list.h:434
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
Storage for name strings.
Definition: item.h:288
Global level hints.
Definition: opt_hints.h:350
Query block level hints.
Definition: opt_hints.h:372
Definition: parse_tree_nodes.h:1606
Represents the WITH clause: WITH [...], [...] SELECT ..., ^^^^^^^^^^^^^^^^^.
Definition: parse_tree_nodes.h:336
Base class for all top-level nodes of SQL statements.
Definition: parse_tree_nodes.h:159
Internal state of the parser.
Definition: sql_lexer_parser_state.h:44
Lex_input_stream m_lip
Definition: sql_lexer_parser_state.h:79
void add_comment()
Signal that the current query has a comment.
Definition: sql_lexer_parser_state.h:73
void reset(const char *found_semicolon, size_t length)
Definition: sql_lexer_parser_state.h:67
Yacc_state m_yacc
Definition: sql_lexer_parser_state.h:80
Parser_state()
Definition: sql_lex.h:4600
Parser_input m_input
Definition: sql_lexer_parser_state.h:78
bool has_comment() const
Check whether the current query has a comment.
Definition: sql_lexer_parser_state.h:75
bool m_comment
True if current query contains comments.
Definition: sql_lexer_parser_state.h:88
bool init(THD *thd, const char *buff, size_t length)
Object initializer.
Definition: sql_lexer_parser_state.h:63
PSI_digest_locker * m_digest_psi
Current performance digest instrumentation.
Definition: sql_lex.h:4629
Parser state for partition expression parser (.frm/DD stuff)
Definition: sql_lex.h:4638
Partition_expr_parser_state()
Definition: sql_lex.cc:1145
partition_info * result
Definition: sql_lex.h:4642
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
RAII class to ease the call of LEX::mark_broken() if error.
Definition: sql_lex.h:4462
~Prepare_error_tracker()
Definition: sql_lex.cc:136
THD *const thd
Definition: sql_lex.h:4468
Prepare_error_tracker(THD *thd_arg)
Definition: sql_lex.h:4464
Definition: protocol.h:33
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1156
void print_update_list(const THD *thd, String *str, enum_query_type query_type, const mem_root_deque< Item * > &fields, const mem_root_deque< Item * > &values)
Print assignments list.
Definition: sql_lex.cc:3241
void print_delete(const THD *thd, String *str, enum_query_type query_type)
Print detail of the DELETE statement.
Definition: sql_lex.cc:3010
void add_base_options(ulonglong options)
Add base options to a query block, also update active options.
Definition: sql_lex.h:1204
uint n_scalar_subqueries
Keep track for allocation of base_ref_items: scalar subqueries may be replaced by a field during scal...
Definition: sql_lex.h:2068
void label_children() override
Set the correct value of Query_term::m_sibling_idx recursively for set operations.
Definition: sql_lex.h:1175
void qbPrint(int level, std::ostringstream &buf) const
Minion of debugPrint.
Definition: query_term.cc:388
Query_block * next
Intrusive linked list of all query blocks within the same query expression.
Definition: sql_lex.h:2319
void cleanup_all_joins()
Definition: sql_union.cc:2095
uint select_number
Query block number (used for EXPLAIN)
Definition: sql_lex.h:2004
bool subquery_in_having
HAVING clause contains subquery => we can't close tables before query processing end even if we use t...
Definition: sql_lex.h:2160
Query_term_type term_type() const override
Get the node tree type.
Definition: sql_lex.h:1170
void print_where_cond(const THD *thd, String *str, enum_query_type query_type)
Print list of conditions in WHERE clause.
Definition: sql_lex.cc:3328
Item * where_cond() const
Definition: sql_lex.h:1182
bool is_grouped() const
Definition: sql_lex.h:1279
void print_insert_options(String *str)
Print INSERT options.
Definition: sql_lex.cc:3169
bool m_json_agg_func_used
Definition: sql_lex.h:2382
mem_root_deque< mem_root_deque< Item * > * > * row_value_list
The VALUES items of a table value constructor.
Definition: sql_lex.h:1892
bool is_dependent() const
Definition: sql_lex.h:1776
mem_root_deque< Item * > * get_fields_list()
Definition: sql_lex.h:1369
bool with_sum_func
True if contains or aggregates set functions.
Definition: sql_lex.h:2154
Ref_item_array m_saved_base_items
A backup of the items in base_ref_items at the end of preparation, so that base_ref_items can be rest...
Definition: sql_lex.h:2367
bool is_explicitly_grouped() const
Definition: sql_lex.h:1262
Item * m_where_cond
Condition to be evaluated after all tables in a query block are joined.
Definition: sql_lex.h:2356
olap_type olap
Indicates whether this query block contains the WITH ROLLUP clause.
Definition: sql_lex.h:2096
Item::cond_result having_value
Definition: sql_lex.h:2015
Item::cond_result cond_value
Saved values of the WHERE and HAVING clauses.
Definition: sql_lex.h:2014
bool setup_base_ref_items(THD *thd)
Setup the array containing references to base items.
Definition: sql_lex.cc:2482
uint get_in_sum_expr() const
Definition: sql_lex.h:1339
void print_values(const THD *thd, String *str, enum_query_type query_type, const mem_root_deque< mem_root_deque< Item * > * > &values, const char *prefix)
Print list of values, used in INSERT and for general VALUES clause.
Definition: sql_lex.cc:3282
bool group_fix_field
true when GROUP BY fix field called in processing of this query block
Definition: sql_lex.h:2147
void print_item_list(const THD *thd, String *str, enum_query_type query_type)
Print list of items in Query_block object.
Definition: sql_lex.cc:3217
Resolve_place resolve_place
Indicates part of query being resolved.
Definition: sql_lex.h:2033
bool m_right_joins
True if query block has right joins.
Definition: sql_lex.h:2376
Query_block(MEM_ROOT *mem_root, Item *where, Item *having)
Construct and initialize Query_block object.
Definition: sql_lex.cc:2154
bool is_implicitly_grouped() const
Definition: sql_lex.h:1269
Item * m_having_cond
Condition to be evaluated on grouped rows after grouping.
Definition: sql_lex.h:2359
MaterializePathParameters::QueryBlock setup_materialize_query_block(AccessPath *childPath, TABLE *dst_table)
Make materialization parameters for a query block given its input path and destination table,...
Definition: sql_union.cc:1349
uint cond_count
Number of predicates after preparation.
Definition: sql_lex.h:2051
Query_result * m_query_result
Result of this query block.
Definition: sql_lex.h:2331
void cleanup(bool full) override
Cleanup this subtree (this Query_block and all nested Query_blockes and Query_expressions).
Definition: sql_union.cc:2066
bool absorb_limit_of(Query_block *block)
end of overridden methods from Query_term
Definition: query_term.cc:460
Table_ref * end_lateral_table
Last table for LATERAL join, used by table functions.
Definition: sql_lex.h:1981
void print_hints(const THD *thd, String *str, enum_query_type query_type)
Print detail of Hints.
Definition: sql_lex.cc:3090
bool accept(Select_lex_visitor *visitor)
Accept function for SELECT and DELETE.
Definition: sql_lex.cc:3455
uint max_equal_elems
Maximal number of elements in multiple equalities.
Definition: sql_lex.h:2055
uint table_func_count
Number of table functions in this query block.
Definition: sql_lex.h:2087
Mem_root_array< Item_exists_subselect * > * sj_candidates
Pointer to collection of subqueries candidate for semi/antijoin conversion.
Definition: sql_lex.h:2310
bool having_fix_field
true when having fix field called in processing of this query block
Definition: sql_lex.h:2145
bool has_aj_nests
Definition: sql_lex.h:2375
uint hidden_items_from_optimization
Hidden items added during optimization.
Definition: sql_lex.h:2179
Query_block * link_next
Intrusive double-linked global list of query blocks.
Definition: sql_lex.h:2327
void invalidate()
Invalidate by nulling out pointers to other Query_expressions and Query_blockes.
Definition: sql_lex.cc:2474
Opt_hints_qb * opt_hints_qb
Query-block-level hints, for this query block.
Definition: sql_lex.h:1928
Query_block * query_block() const override
The query_block which holds the ORDER BY and LIMIT information for this set operation.
Definition: sql_lex.h:1172
Query_block ** link_prev
Definition: sql_lex.h:2328
uint with_wild
Number of wildcards used in the SELECT list.
Definition: sql_lex.h:2080
Name_resolution_context context
Context for name resolution for all column references except columns from joined tables.
Definition: sql_lex.h:1953
Item ** where_cond_ref()
Definition: sql_lex.h:1183
void make_active_options(ulonglong added_options, ulonglong removed_options)
Make active options from base options, supplied options and environment:
Definition: sql_lex.cc:2337
void set_empty_query()
Set query block as returning no data.
Definition: sql_lex.h:1748
Query_expression * slave
The first query expression contained within this query block.
Definition: sql_lex.h:2324
bool is_item_list_lookup
Definition: sql_lex.h:2142
void mark_as_dependent(Query_block *last, bool aggregate)
Mark all query blocks from this to 'last' as dependent.
Definition: sql_lex.cc:2373
Table_ref * leaf_tables
Points to first leaf table of query block.
Definition: sql_lex.h:1979
bool save_order_properties(THD *thd, SQL_I_List< ORDER > *list, Group_list_ptrs **list_ptrs)
Helper for save_properties()
Definition: sql_lex.cc:4246
Item_sum * inner_sum_func_list
Circular linked list of aggregate functions in nested query blocks.
Definition: sql_lex.h:1995
Item ** having_cond_ref()
Definition: sql_lex.h:1186
bool first_execution
This variable is required to ensure proper work of subqueries and stored procedures.
Definition: sql_lex.h:2131
Item * having_cond() const
Definition: sql_lex.h:1185
void print_delete_options(String *str)
Print DELETE options.
Definition: sql_lex.cc:3161
bool add_ftfunc_to_list(Item_func_match *func)
Definition: sql_lex.cc:2466
void print_having(const THD *thd, String *str, enum_query_type query_type)
Print list of items in HAVING clause.
Definition: sql_lex.cc:3358
bool walk(Item_processor processor, enum_walk walk, uchar *arg)
Definition: sql_lex.cc:4694
bool m_agg_func_used
Definition: sql_lex.h:2381
Query_expression * first_inner_query_expression() const
Definition: sql_lex.h:1248
uint materialized_derived_table_count
Number of materialized derived tables and views in this query block.
Definition: sql_lex.h:2071
List< Item_func_match > * ftfunc_list
A pointer to ftfunc_list_alloc, list of full text search functions.
Definition: sql_lex.h:1888
uint in_sum_expr
Parse context: is inside a set function if this is positive.
Definition: sql_lex.h:2020
enum_condition_context condition_context
Definition: sql_lex.h:2099
void set_right_joins()
Definition: sql_lex.h:1765
auto visible_fields()
Wrappers over fields / get_fields_list() that hide items where item->hidden, meant for range-based fo...
Definition: sql_lex.h:1373
uint n_sum_items
Number of Item_sum-derived objects in this SELECT.
Definition: sql_lex.h:2062
Query_block * outer_query_block() const
Definition: sql_lex.h:1249
void renumber(LEX *lex)
Renumber query blocks of contained query expressions.
Definition: sql_lex.cc:4420
mem_root_deque< Table_ref * > * m_current_table_nest
Pointer to the set of table references in the currently active join.
Definition: sql_lex.h:1970
List< Window > m_windows
All windows defined on the select, both named and inlined.
Definition: sql_lex.h:1883
Table_ref * find_table_by_name(const Table_ident *ident)
Finds a (possibly unresolved) table reference in the from clause by name.
Definition: sql_lex.cc:4765
uint leaf_table_count
Number of leaf tables in this query block.
Definition: sql_lex.h:2083
void set_having_cond(Item *cond)
Definition: sql_lex.h:1187
bool m_use_select_limit
If true, use select_limit to limit number of rows selected.
Definition: sql_lex.h:2167
bool has_limit() const
Definition: sql_lex.h:1313
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 bl...
Definition: sql_lex.cc:4599
void destroy()
Destroy contained objects, in particular temporary tables which may have their own mem_roots.
Definition: sql_union.cc:2106
uint derived_table_count
Number of derived tables and views in this query block.
Definition: sql_lex.h:2085
bool is_ordered() const
Definition: sql_lex.h:1290
void destroy_tree() override
Destroy the query term tree structure.
Definition: sql_lex.h:1176
uint partitioned_table_count
Number of partitioned tables.
Definition: sql_lex.h:2073
Prealloced_array< Item_rollup_group_item *, 4 > rollup_group_items
Definition: sql_lex.h:1922
void print_insert_fields(const THD *thd, String *str, enum_query_type query_type)
Print column list to be inserted into.
Definition: sql_lex.cc:3262
bool json_agg_func_used() const
Definition: sql_lex.h:1758
bool get_optimizable_conditions(THD *thd, Item **new_where, Item **new_having)
Returns disposable copies of WHERE/HAVING/ON conditions.
Definition: sql_lex.cc:4497
uint between_count
Number of between predicates in where/having/on.
Definition: sql_lex.h:2053
Query_result * query_result() const
Definition: sql_lex.h:1189
void include_in_global(Query_block **plink)
Include query block into global list.
Definition: sql_lex.cc:4436
bool agg_func_used() const
Definition: sql_lex.h:1757
Resolve_place
Three fields used by semi-join transformations to know when semi-join is possible,...
Definition: sql_lex.h:2026
@ RESOLVE_HAVING
Definition: sql_lex.h:2030
@ RESOLVE_NONE
Definition: sql_lex.h:2027
@ RESOLVE_SELECT_LIST
Definition: sql_lex.h:2031
@ RESOLVE_JOIN_NEST
Definition: sql_lex.h:2028
@ RESOLVE_CONDITION
Definition: sql_lex.h:2029
void include_chain_in_global(Query_block **start)
Include chain of query blocks into global list.
Definition: sql_lex.cc:4447
SQL_I_List< ORDER > order_list
ORDER BY clause.
Definition: sql_lex.h:1907
char * db
Definition: sql_lex.h:1930
List< Item_func_match > ftfunc_list_alloc
Definition: sql_lex.h:1889
static const char * get_type_str(enum_explain_type type)
Definition: sql_lex.h:1772
void remove_base_options(ulonglong options)
Remove base options from a query block.
Definition: sql_lex.h:1215
enum_explain_type type() const
Lookup for Query_block type.
Definition: sql_lex.cc:4317
Item * offset_limit
LIMIT ... OFFSET clause, NULL if no offset is given.
Definition: sql_lex.h:1986
void set_sj_candidates(Mem_root_array< Item_exists_subselect * > *sj_cand)
Definition: sql_lex.h:1444
void print_order_by(const THD *thd, String *str, enum_query_type query_type) const
Print list of items in ORDER BY clause.
Definition: sql_lex.cc:3396
static const char * type_str[static_cast< int >(enum_explain_type::EXPLAIN_total)]
Definition: sql_lex.h:2391
Query_expression * master
The query expression containing this query block.
Definition: sql_lex.h:2322
Ref_item_array base_ref_items
Array of pointers to "base" items; one each for every selected expression and referenced item in the ...
Definition: sql_lex.h:2002
int hidden_order_field_count
How many expressions are part of the order by but not select list.
Definition: sql_lex.h:2313
enum_parsing_context parsing_place
Parse context: indicates where the current expression is being parsed.
Definition: sql_lex.h:2018
void init_order()
Definition: sql_lex.h:1459
uint8 uncacheable
result of this query can't be cached, bit field, can be : UNCACHEABLE_DEPENDENT UNCACHEABLE_RAND UNCA...
Definition: sql_lex.h:2113
ulonglong m_base_options
Options assigned from parsing and throughout resolving, should not be modified after resolving is don...
Definition: sql_lex.h:2337
bool source_table_is_one_row() const
Definition: sql_lex.h:1780
void include_down(LEX *lex, Query_expression *outer)
Include query block inside a query expression.
Definition: sql_lex.cc:4371
void include_standalone(Query_expression *sel)
Include query block inside a query expression, but do not link.
Definition: sql_lex.cc:4408
Group_list_ptrs * group_list_ptrs
Definition: sql_lex.h:1918
uint saved_cond_count
Number of arguments of and/or/xor in where/having/on.
Definition: sql_lex.h:2049
Subquery_strategy subquery_strategy(const THD *thd) const
Returns which subquery execution strategies can be used for this query block.
Definition: sql_lex.cc:4520
Query_block * next_query_block() const
Definition: sql_lex.h:1250
Name_resolution_context * first_context
Pointer to first object in list of Name res context objects that have this query block as the base qu...
Definition: sql_lex.h:1960
void include_neighbour(LEX *lex, Query_block *before)
Include a query block next to another query block.
Definition: sql_lex.cc:4389
bool is_table_value_constructor
If set, the query block is of the form VALUES row_list.
Definition: sql_lex.h:2102
Item * get_derived_expr(uint expr_index)
Returns an expression from the select list of the query block using the field's index in a derived ta...
Definition: sql_derived.cc:1255
bool semijoin_enabled(const THD *thd) const
Returns whether semi-join is enabled for this query block.
Definition: sql_lex.cc:4546
Query_expression * master_query_expression() const
Definition: sql_lex.h:1247
void update_semijoin_strategies(THD *thd)
Update available semijoin strategies for semijoin nests.
Definition: sql_lex.cc:4551
uint select_n_having_items
Number of items in the select list, HAVING clause and ORDER BY clause.
Definition: sql_lex.h:2047
Table_ref * get_table_list() const
Definition: sql_lex.h:1364
void print_update(const THD *thd, String *str, enum_query_type query_type)
Print detail of the UPDATE statement.
Definition: sql_lex.cc:2973
bool is_simple_query_block() const
Definition: sql_lex.h:1735
void print_table_references(const THD *thd, String *str, Table_ref *table_list, enum_query_type query_type)
Print list of tables.
Definition: sql_lex.cc:3183
bool has_tables() const
Definition: sql_lex.h:1259
void debugPrint(int level, std::ostringstream &buf) const override
Query_term methods overridden.
Definition: query_term.cc:438
bool m_internal_limit
If true, limit object is added internally.
Definition: sql_lex.h:2170
int hidden_group_field_count
Number of GROUP BY expressions added to all_fields.
Definition: sql_lex.h:2362
bool is_recursive() const
Definition: sql_lex.h:1319
void print_windows(const THD *thd, String *str, enum_query_type query_type)
Print details of Windowing functions.
Definition: sql_lex.cc:3374
bool no_table_names_allowed
used for global order by
Definition: sql_lex.h:2175
bool validate_base_options(LEX *lex, ulonglong options) const
Validate base options for a query block.
Definition: sql_lex.cc:4636
void set_where_cond(Item *cond)
Definition: sql_lex.h:1184
Item * select_limit
LIMIT clause, NULL if no limit is given.
Definition: sql_lex.h:1984
ulonglong active_options() const
Definition: sql_lex.h:1228
bool save_properties(THD *thd)
Save properties of a prepared statement needed for repeated optimization.
Definition: sql_lex.cc:4269
Table_ref * embedding
table embedding the above list
Definition: sql_lex.h:1972
bool open_result_tables(THD *, int) override
Open tmp tables for the tree of set operation query results, by recursing.
Definition: query_term.cc:452
table_map select_list_tables
The set of those tables whose fields are referenced in the select list of this select level.
Definition: sql_lex.h:1946
bool m_was_implicitly_grouped
Used by nested scalar_to_derived transformations.
Definition: sql_lex.h:2137
bool has_sj_nests
True if query block has semi-join nests merged into it.
Definition: sql_lex.h:2374
Prealloced_array< Item_rollup_sum_switcher *, 4 > rollup_sums
Definition: sql_lex.h:1924
SQL_I_List< ORDER > group_list
GROUP BY clause.
Definition: sql_lex.h:1917
SQL_I_List< Table_ref > m_table_list
List of tables in FROM clause - use Table_ref::next_local to traverse.
Definition: sql_lex.h:1898
uint select_n_where_fields
Number of fields used in select list or where clause of current select and all inner subselects.
Definition: sql_lex.h:2040
bool skip_local_transforms
True: skip local transformations during prepare() call (used by INSERT)
Definition: sql_lex.h:2140
void print_limit(const THD *thd, String *str, enum_query_type query_type) const
Definition: sql_lex.cc:2627
const char * get_type_str()
Lookup for a type string.
Definition: sql_lex.h:1771
Table_ref * resolve_nest
Used when resolving outer join condition.
Definition: sql_lex.h:2345
bool is_empty_query() const
Definition: sql_lex.h:1744
void print_query_block(const THD *thd, String *str, enum_query_type query_type)
Print detail of the Query_block object.
Definition: sql_lex.cc:2950
mem_root_deque< Table_ref * > m_table_nest
Set of table references contained in outer-most join nest.
Definition: sql_lex.h:1968
bool set_context(Name_resolution_context *outer_context)
Assign a default name resolution object for this query block.
Definition: sql_lex.cc:2171
void set_json_agg_func_used(bool val)
Definition: sql_lex.h:1762
bool allow_merge_derived
Allow merge of immediate unnamed derived tables.
Definition: sql_lex.h:2379
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.
Definition: sql_lex.cc:2197
void print_select_options(String *str)
Print select options.
Definition: sql_lex.cc:3136
void set_query_result(Query_result *result)
Definition: sql_lex.h:1188
mem_root_deque< Table_ref * > sj_nests
List of semi-join nests generated for this query block.
Definition: sql_lex.h:1895
Table_ref * recursive_reference
If this query block is a recursive member of a recursive unit: the Table_ref, in this recursive membe...
Definition: sql_lex.h:1937
bool add_item_to_list(Item *item)
Definition: sql_lex.cc:2457
void print(const THD *thd, String *str, enum_query_type query_type)
Definition: sql_lex.cc:2911
bool exclude_from_table_unique_test
exclude this query block from unique_table() check
Definition: sql_lex.h:2173
bool sj_pullout_done
True when semi-join pull-out processing is complete.
Definition: sql_lex.h:2134
int nest_level
Nesting level of query block, outer-most query block has level 0, its subqueries have level 1,...
Definition: sql_lex.h:2093
const char * operator_string() const override
Get the node type description.
Definition: sql_lex.h:1171
Group_list_ptrs * order_list_ptrs
Definition: sql_lex.h:1908
uint n_child_sum_items
Number of Item_sum-derived objects in children and descendant SELECTs.
Definition: sql_lex.h:2064
bool save_cmd_properties(THD *thd)
Save prepared statement properties for a query block and underlying query expressions.
Definition: sql_lex.cc:4786
void set_agg_func_used(bool val)
Definition: sql_lex.h:1760
bool print_error(const THD *thd, String *str)
Print error.
Definition: sql_lex.cc:3115
bool is_cacheable() const
Definition: sql_lex.h:1777
ha_rows get_offset(const THD *thd) const
Get offset for LIMIT.
Definition: sql_lex.cc:2436
void add_active_options(ulonglong options)
Adjust the active option set.
Definition: sql_lex.h:1225
ha_rows get_limit(const THD *thd) const
Get limit.
Definition: sql_lex.cc:2443
Item * clone_expression(THD *thd, Item *item, Table_ref *derived_table)
Creates a clone for the given expression by re-parsing the expression.
Definition: sql_derived.cc:778
void set_base_options(ulonglong options_arg)
Set base options for a query block (and active options too)
Definition: sql_lex.h:1194
void print_update_options(String *str)
Print UPDATE options.
Definition: sql_lex.cc:3154
void print_insert(const THD *thd, String *str, enum_query_type query_type)
Print detail of the INSERT statement.
Definition: sql_lex.cc:3042
table_map all_tables_map() const
Definition: sql_lex.h:1243
bool right_joins() const
Definition: sql_lex.h:1764
JOIN * join
After optimization it is pointer to corresponding JOIN.
Definition: sql_lex.h:1966
ulonglong m_active_options
Active options.
Definition: sql_lex.h:2343
void restore_cmd_properties()
Restore prepared statement properties for this query block and all underlying query expressions so th...
Definition: sql_lex.cc:4807
void cut_subtree()
Definition: sql_lex.h:1471
bool has_sj_candidates() const
Definition: sql_lex.h:1448
void print_from_clause(const THD *thd, String *str, enum_query_type query_type)
Print list of tables in FROM clause.
Definition: sql_lex.cc:3310
bool m_empty_query
True if query block does not generate any rows before aggregation, determined during preparation (not...
Definition: sql_lex.h:2388
table_map outer_join
Bitmap of all inner tables from outer joins.
Definition: sql_lex.h:1947
size_t m_added_non_hidden_fields
Definition: sql_lex.h:1856
Query_block * next_select_in_list() const
Definition: sql_lex.h:1254
void print_group_by(const THD *thd, String *str, enum_query_type query_type)
Print list of items in GROUP BY clause.
Definition: sql_lex.cc:3343
auto visible_fields() const
Definition: sql_lex.h:1374
bool can_skip_distinct() const
Based on the structure of the query at resolution time, it is possible to conclude that DISTINCT is u...
Definition: sql_lex.h:1307
bool is_distinct() const
Definition: sql_lex.h:1282
void set_tables_readonly()
Set associated tables as read_only, ie.
Definition: sql_lex.h:1236
mem_root_deque< Item * > fields
All expressions needed after join and filtering, ie., select list, group by list, having clause,...
Definition: sql_lex.h:1878
LEX * parent_lex
Reference to LEX that this query block belongs to.
Definition: sql_lex.h:1940
bool test_limit()
Definition: sql_lex.cc:2409
bool has_windows() const
Definition: sql_lex.h:1335
bool has_ft_funcs() const
Definition: sql_lex.h:1316
This class represents a query expression (one query block or several query blocks combined with UNION...
Definition: sql_lex.h:623
bool is_executed() const
Check state of execution of the contained query expression.
Definition: sql_lex.h:1041
bool merge_heuristic(const LEX *lex) const
True if heuristics suggest to merge this query expression.
Definition: sql_lex.cc:3831
Query_block * non_simple_result_query_block() const
Return the query block iff !is_simple() holds.
Definition: sql_lex.h:655
void reset_executed()
Reset this query expression for repeated evaluation within same execution.
Definition: sql_lex.h:1020
void change_to_access_path_without_in2exists(THD *thd)
Definition: sql_union.cc:1993
unique_ptr_destroy_only< RowIterator > m_root_iterator
An iterator you can read from to get all records for this query.
Definition: sql_lex.h:741
Query_expression(enum_parsing_context parsing_context)
Construct and initialize Query_expression object.
Definition: sql_lex.cc:2103
void set_explain_marker_from(THD *thd, const Query_expression *u)
Definition: sql_lex.cc:2429
void set_prepared()
Definition: sql_lex.h:1006
bool executed
Query expression has been executed.
Definition: sql_lex.h:728
bool walk(Item_processor processor, enum_walk walk, uchar *arg)
Definition: sql_union.cc:1985
void clear_root_access_path()
Definition: sql_lex.h:875
void set_explain_marker(THD *thd, enum_parsing_context m)
Definition: sql_lex.cc:2423
bool has_top_level_distinct() const
Definition: sql_lex.h:711
unique_ptr_destroy_only< RowIterator > release_root_iterator()
Definition: sql_lex.h:865
void exclude_tree()
Exclude subtree of current unit from tree of SELECTs.
Definition: sql_lex.cc:2282
Query_term_set_op * set_operation() const
Convenience method to avoid down casting, i.e.
Definition: sql_lex.h:651
bool optimize(THD *thd, TABLE *materialize_destination, bool create_iterators, bool finalize_access_paths)
If and only if materialize_destination is non-nullptr, it means that the caller intends to materializ...
Definition: sql_union.cc:982
void set_executed()
Definition: sql_lex.h:1014
enum_parsing_context explain_marker
Marker for subqueries in WHERE, HAVING, ORDER BY, GROUP BY and SELECT item lists.
Definition: sql_lex.h:724
Query_term * find_blocks_query_term(const Query_block *qb) const
Definition: sql_lex.h:662
enum_parsing_context get_explain_marker(const THD *thd) const
Definition: sql_lex.cc:2417
Query_expression * next_query_expression() const
Definition: sql_lex.h:859
Query_term * query_term() const
Getter for m_query_term, q.v.
Definition: sql_lex.h:644
Query_expression * next
Intrusive double-linked list of all query expressions immediately contained within the same query blo...
Definition: sql_lex.h:628
Query_block * global_parameters() const
Return the query block holding the top level ORDER BY, LIMIT and OFFSET.
Definition: sql_lex.h:806
bool explain_query_term(THD *explain_thd, const THD *query_thd, Query_term *qt)
Definition: sql_union.cc:1501
Query_block * slave
The first query block in this query expression.
Definition: sql_lex.h:637
bool change_query_result(THD *thd, Query_result_interceptor *result, Query_result_interceptor *old_result)
Change the query result object used to return the final result of the unit, replacing occurrences of ...
Definition: sql_union.cc:1925
size_t num_visible_fields() const
Definition: sql_union.cc:1959
bool is_simple() const
Definition: sql_lex.h:771
bool optimized
All query blocks in query expression are optimized.
Definition: sql_lex.h:727
Query_block * outer_query_block() const
Definition: sql_lex.h:853
void exclude_level()
Exclude this unit and immediately contained query_block objects.
Definition: sql_lex.cc:2220
Query_block * first_query_block() const
Definition: sql_lex.h:856
Query_block * master
The query block wherein this query expression is contained, NULL if the query block is the outer-most...
Definition: sql_lex.h:635
Query_block * last_distinct() const
Return the Query_block of the last query term in a n-ary set operation that is the right side of the ...
Definition: sql_lex.h:703
bool prepare_query_term(THD *thd, Query_term *qts, Query_result *common_result, ulonglong added_options, ulonglong create_options, int level, Mem_root_array< bool > &nullable)
Prepare the query term nodes and their associated post processing query blocks (i....
Definition: sql_union.cc:414
enum_clean_state cleaned
cleanliness state
Definition: sql_lex.h:781
bool prepare(THD *thd, Query_result *result, mem_root_deque< Item * > *insert_field_list, ulonglong added_options, ulonglong removed_options)
Prepares all query blocks of a query expression.
Definition: sql_union.cc:691
bool check_materialized_derived_query_blocks(THD *thd)
Sets up query blocks belonging to the query expression of a materialized derived table.
Definition: sql_derived.cc:907
Query_expression ** prev
Definition: sql_lex.h:629
void set_query_term(Query_term *qt)
Setter for m_query_term, q.v.
Definition: sql_lex.h:646
ha_rows offset_limit_cnt
Definition: sql_lex.h:811
Query_term * m_query_term
Definition: sql_lex.h:640
AccessPath * m_root_access_path
Definition: sql_lex.h:742
bool has_any_limit() const
Checks if this query expression has limit defined.
Definition: sql_lex.cc:3765
bool ExecuteIteratorQuery(THD *thd)
Definition: sql_union.cc:1669
void set_optimized()
Definition: sql_lex.h:1010
void cleanup(bool full)
Cleanup this query expression object after preparation or one round of execution.
Definition: sql_union.cc:1834
friend bool parse_view_definition(THD *thd, Table_ref *view_ref)
Parse a view definition.
Definition: sql_view.cc:1208
mem_root_deque< Item * > * get_unit_column_types()
Get column type information for this query expression.
Definition: sql_union.cc:1955
Query_block * create_post_processing_block(Query_term_set_op *term)
Create a block to be used for ORDERING and LIMIT/OFFSET processing of a query term,...
Definition: sql_lex.cc:742
RowIterator * root_iterator() const
Definition: sql_lex.h:864
bool is_leaf_block(Query_block *qb)
Definition: sql_lex.cc:764
bool force_create_iterators(THD *thd)
Ensures that there are iterators created for the access paths created by optimize(),...
Definition: sql_union.cc:1176
Query_block * first_recursive
First query block (in this UNION) which references the CTE.
Definition: sql_lex.h:828
bool prepared
All query blocks in query expression are prepared.
Definition: sql_lex.h:726
void assert_not_fully_clean()
Asserts that none of {this unit and its children units} is fully cleaned up.
Definition: sql_union.cc:1890
void renumber_selects(LEX *lex)
Renumber query blocks of a query expression according to supplied LEX.
Definition: sql_lex.cc:3847
bool accept(Select_lex_visitor *visitor)
Definition: sql_lex.cc:3425
Query_result * query_result() const
Definition: sql_lex.h:862
ha_rows send_records
Definition: sql_lex.h:1076
enum_parsing_context place() const
If unit is a subquery, which forms an object of the upper level (an Item_subselect,...
Definition: sql_lex.cc:4688
mem_root_deque< Item * > types
Definition: sql_lex.h:793
Mem_root_array< MaterializePathParameters::QueryBlock > m_query_blocks_to_materialize
If there is an unfinished materialization (see optimize()), contains one element for each query block...
Definition: sql_lex.h:749
void accumulate_used_tables(table_map map)
If unit is a subquery, which forms an object of the upper level (an Item_subselect,...
Definition: sql_lex.cc:4680
ha_rows select_limit_cnt
Definition: sql_lex.h:811
void create_access_paths(THD *thd)
Convert the executor structures to a set of access paths, storing the result in m_root_access_path.
Definition: sql_union.cc:1417
void print(const THD *thd, String *str, enum_query_type query_type)
Definition: sql_lex.cc:2615
Table_ref * derived_table
If this query expression is underlying of a derived table, the derived table.
Definition: sql_lex.h:823
void restore_cmd_properties()
Loop over all query blocks and restore information needed for optimization, including binding data fo...
Definition: sql_lex.cc:3870
bool finalize(THD *thd)
For any non-finalized query block, finalize it so that we are allowed to create iterators.
Definition: sql_union.cc:1164
Query_terms< order, visit_leaves > query_terms() const
Return iterator object over query terms rooted in m_query_term, using either post order visiting (def...
Definition: sql_lex.h:688
bool set_limit(THD *thd, Query_block *provider)
Set limit and offset for query expression object.
Definition: sql_lex.cc:3746
bool m_reject_multiple_rows
This query expression represents a scalar subquery and we need a run-time check that the cardinality ...
Definition: sql_lex.h:844
bool ClearForExecution()
Do everything that would be needed before running Init() on the root iterator.
Definition: sql_union.cc:1635
Item_subselect * item
Points to subquery if this query expression is used in one, otherwise NULL.
Definition: sql_lex.h:813
enum_clean_state
Values for Query_expression::cleaned.
Definition: sql_lex.h:774
@ UC_PART_CLEAN
Unit were cleaned, except JOIN and JOIN_TABs were kept for possible EXPLAIN.
Definition: sql_lex.h:776
@ UC_CLEAN
Unit completely cleaned, all underlying JOINs were freed.
Definition: sql_lex.h:778
@ UC_DIRTY
Unit isn't cleaned.
Definition: sql_lex.h:775
void invalidate()
Invalidate by nulling out pointers to other Query expressions and Query blocks.
Definition: sql_lex.cc:2322
bool can_materialize_directly_into_result() const
Whether there is a chance that optimize() is capable of materializing directly into a result table if...
Definition: sql_union.cc:666
PT_with_clause * m_with_clause
The WITH clause which is the first part of this query expression.
Definition: sql_lex.h:818
bool explain(THD *explain_thd, const THD *query_thd)
Explain query starting from this unit.
Definition: sql_union.cc:1567
bool is_mergeable() const
Return true if query expression can be merged into an outer query, based on technical constraints.
Definition: sql_lex.cc:3802
Query_result * m_query_result
Object to which the result for this query expression is sent.
Definition: sql_lex.h:733
bool is_prepared() const
Check state of preparation of the contained query expression.
Definition: sql_lex.h:1033
table_map m_lateral_deps
If 'this' is body of lateral derived table: map of tables in the same FROM clause as this derived tab...
Definition: sql_lex.h:838
bool is_optimized() const
Check state of optimization of the contained query expression.
Definition: sql_lex.h:1035
void set_query_result(Query_result *res)
Set new query result object for this query expression.
Definition: sql_lex.h:906
void include_down(LEX *lex, Query_block *outer)
Include a query expression below a query block.
Definition: sql_lex.cc:3778
void destroy()
Destroy contained objects, in particular temporary tables which may have their own mem_roots.
Definition: sql_union.cc:1865
mem_root_deque< Item * > * get_field_list()
Get field list for this query expression.
Definition: sql_union.cc:1974
Mem_root_array< MaterializePathParameters::QueryBlock > release_query_blocks_to_materialize()
See optimize().
Definition: sql_lex.h:901
bool execute(THD *thd)
Execute a query expression that may be a UNION and/or have an ordered result.
Definition: sql_union.cc:1809
bool clear_correlated_query_blocks()
Empties all correlated query blocks defined within the query expression; that is, correlated CTEs def...
Definition: sql_union.cc:1621
bool save_cmd_properties(THD *thd)
Save prepared statement properties for a query expression and underlying query blocks.
Definition: sql_lex.cc:3859
AccessPath * root_access_path() const
Definition: sql_lex.h:868
uint8 uncacheable
result of this query can't be cached, bit field, can be : UNCACHEABLE_DEPENDENT UNCACHEABLE_RAND UNCA...
Definition: sql_lex.h:765
bool unfinished_materialization() const
See optimize().
Definition: sql_lex.h:895
void clear_execution()
Clear execution state, needed before new execution of prepared statement.
Definition: sql_lex.h:1025
bool is_recursive() const
Definition: sql_lex.h:1093
Definition: query_result.h:174
Definition: sql_union.h:40
Definition: query_result.h:54
Definition: sql_lex.h:2507
bool is_mixed_stmt_unsafe(bool in_multi_stmt_transaction_mode, bool binlog_direct, bool trx_cache_is_not_empty, uint tx_isolation)
Definition: sql_lex.h:3026
bool uses_stored_routines() const
true if the parsed tree contains references to stored procedures or functions, false otherwise
Definition: sql_lex.h:3073
void set_stmt_row_injection()
Flag the statement as a row injection.
Definition: sql_lex.h:2874
std::unique_ptr< malloc_unordered_map< std::string, Sroutine_hash_entry * > > sroutines
Definition: sql_lex.h:2538
void set_stmt_unsafe(enum_binlog_stmt_unsafe unsafe_type)
Flag the current (top-level) statement as unsafe.
Definition: sql_lex.h:2825
static const char * stmt_accessed_table_string(enum_stmt_accessed_table accessed_table)
Definition: sql_lex.h:2926
enum_binlog_stmt_type
Enumeration listing special types of statements.
Definition: sql_lex.h:3089
@ BINLOG_STMT_TYPE_ROW_INJECTION
The statement is a row injection (i.e., either a BINLOG statement or a row event executed by the slav...
Definition: sql_lex.h:3094
@ BINLOG_STMT_TYPE_COUNT
The last element of this enumeration type.
Definition: sql_lex.h:3097
Table_ref ** query_tables_last
Definition: sql_lex.h:2521
bool is_stmt_unsafe_with_mixed_mode() const
Definition: sql_lex.h:3079
void reset_query_tables_list(bool init)
Definition: sql_lex.cc:3520
static const int BINLOG_STMT_UNSAFE_ALL_FLAGS
This has all flags from 0 (inclusive) to BINLOG_STMT_FLAG_COUNT (exclusive) set.
Definition: sql_lex.h:2798
~Query_tables_list()=default
enum_sql_command sql_command
SQL command for this statement.
Definition: sql_lex.h:2517
void set_stmt_unsafe_flags(uint32 flags)
Set the bits of binlog_stmt_flags determining the type of unsafeness of the current statement.
Definition: sql_lex.h:2840
uint32 get_stmt_unsafe_flags() const
Return a binary combination of all unsafe warnings for the statement.
Definition: sql_lex.h:2853
void set_stmt_unsafe_with_mixed_mode()
Definition: sql_lex.h:3078
Query_tables_list()=default
bool is_stmt_unsafe() const
Determine if this statement is marked as unsafe.
Definition: sql_lex.h:2812
bool is_stmt_unsafe(enum_binlog_stmt_unsafe unsafe)
Definition: sql_lex.h:2814
uint table_count
Number of tables which were open by open_tables() and to be locked by lock_tables().
Definition: sql_lex.h:2577
uint32 stmt_accessed_table_flag
Bit field that determines the type of tables that are about to be be accessed while executing a state...
Definition: sql_lex.h:3121
enum_stmt_accessed_table
Definition: sql_lex.h:2881
@ STMT_READS_TEMP_TRANS_TABLE
Definition: sql_lex.h:2896
@ STMT_WRITES_TEMP_TRANS_TABLE
Definition: sql_lex.h:2913
@ STMT_WRITES_TRANS_TABLE
Definition: sql_lex.h:2905
@ STMT_WRITES_TEMP_NON_TRANS_TABLE
Definition: sql_lex.h:2917
@ STMT_READS_TRANS_TABLE
Definition: sql_lex.h:2886
@ STMT_READS_TEMP_NON_TRANS_TABLE
Definition: sql_lex.h:2901
@ STMT_ACCESS_TABLE_COUNT
Definition: sql_lex.h:2922
@ STMT_READS_NON_TRANS_TABLE
Definition: sql_lex.h:2891
@ STMT_WRITES_NON_TRANS_TABLE
Definition: sql_lex.h:2909
bool stmt_unsafe_with_mixed_mode
This flag is set to true if statement is unsafe to be binlogged in STATEMENT format,...
Definition: sql_lex.h:3134
uint sroutines_list_own_elements
Definition: sql_lex.h:2550
void mark_as_requiring_prelocking(Table_ref **tables_own_last)
Definition: sql_lex.h:2603
bool is_stmt_row_injection() const
Determine if this statement is a row injection.
Definition: sql_lex.h:2864
enum_lock_tables_state lock_tables_state
Definition: sql_lex.h:2565
void set_query_tables_list(Query_tables_list *state)
Definition: sql_lex.h:2589
void set_using_match()
Definition: sql_lex.h:3075
bool stmt_accessed_table(enum_stmt_accessed_table accessed_table)
Checks if a type of table is about to be accessed while executing a statement.
Definition: sql_lex.h:3003
SQL_I_List< Sroutine_hash_entry > sroutines_list
Definition: sql_lex.h:2548
void destroy_query_tables_list()
Definition: sql_lex.cc:3564
Sroutine_hash_entry ** sroutines_list_own_last
Definition: sql_lex.h:2549
bool using_match
It will be set true if 'MATCH () AGAINST' is used in the statement.
Definition: sql_lex.h:3126
void set_stmt_accessed_table(enum_stmt_accessed_table accessed_table)
Sets the type of table that is about to be accessed while executing a statement.
Definition: sql_lex.h:2984
static const int binlog_stmt_unsafe_errcode[BINLOG_STMT_UNSAFE_COUNT]
Maps elements of enum_binlog_stmt_unsafe to error codes.
Definition: sql_lex.h:2804
enum_binlog_stmt_unsafe
All types of unsafe statements.
Definition: sql_lex.h:2633
@ BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION
Using some functions is unsafe (e.g., UUID).
Definition: sql_lex.h:2665
@ BINLOG_STMT_UNSAFE_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE
Mixing self-logging and non-self-logging engines in a statement is unsafe.
Definition: sql_lex.h:2678
@ BINLOG_STMT_UNSAFE_COUNT
Definition: sql_lex.h:2792
@ BINLOG_STMT_UNSAFE_XA
XA transactions and statements.
Definition: sql_lex.h:2765
@ BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC
CREATE TABLE...SELECT on a table with auto-increment column is unsafe because which rows are replaced...
Definition: sql_lex.h:2734
@ BINLOG_STMT_UNSAFE_DEFAULT_EXPRESSION_IN_SUBSTATEMENT
If a substatement inserts into or updates a table that has a column with an unsafe DEFAULT expression...
Definition: sql_lex.h:2772
@ BINLOG_STMT_UNSAFE_NOWAIT
Definition: sql_lex.h:2760
@ BINLOG_STMT_UNSAFE_FULLTEXT_PLUGIN
Using a plugin is unsafe.
Definition: sql_lex.h:2758
@ BINLOG_STMT_UNSAFE_INSERT_TWO_KEYS
INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEYS is unsafe.
Definition: sql_lex.h:2747
@ BINLOG_STMT_UNSAFE_AUTOINC_NOT_FIRST
INSERT into auto-inc field which is not the first part in composed primary key.
Definition: sql_lex.h:2753
@ BINLOG_STMT_UNSAFE_CREATE_SELECT_WITH_GIPK
Generating invisible primary key for a table created using CREATE TABLE... SELECT....
Definition: sql_lex.h:2789
@ BINLOG_STMT_UNSAFE_NONTRANS_AFTER_TRANS
Mixing transactional and non-transactional statements are unsafe if non-transactional reads or writes...
Definition: sql_lex.h:2672
@ BINLOG_STMT_UNSAFE_SYSTEM_VARIABLE
Using most system variables is unsafe, because slave may run with different options than master.
Definition: sql_lex.h:2661
@ BINLOG_STMT_UNSAFE_INSERT_IGNORE_SELECT
INSERT...IGNORE SELECT is unsafe because which rows are ignored depends on the order that rows are re...
Definition: sql_lex.h:2691
@ BINLOG_STMT_UNSAFE_MIXED_STATEMENT
Statements that read from both transactional and non-transactional tables and write to any of them ar...
Definition: sql_lex.h:2684
@ BINLOG_STMT_UNSAFE_AUTOINC_COLUMNS
Inserting into an autoincrement column in a stored routine is unsafe.
Definition: sql_lex.h:2652
@ BINLOG_STMT_UNSAFE_SKIP_LOCKED
Definition: sql_lex.h:2759
@ BINLOG_STMT_UNSAFE_CREATE_IGNORE_SELECT
CREATE TABLE... IGNORE... SELECT is unsafe because which rows are ignored depends on the order that r...
Definition: sql_lex.h:2719
@ BINLOG_STMT_UNSAFE_ACL_TABLE_READ_IN_DML_DDL
DML or DDL statement that reads a ACL table is unsafe, because the row are read without acquiring SE ...
Definition: sql_lex.h:2780
@ BINLOG_STMT_UNSAFE_INSERT_SELECT_UPDATE
INSERT...SELECT...UPDATE is unsafe because which rows are updated depends on the order that rows are ...
Definition: sql_lex.h:2698
@ BINLOG_STMT_UNSAFE_LIMIT
SELECT..LIMIT is unsafe because the set of rows returned cannot be predicted.
Definition: sql_lex.h:2638
@ BINLOG_STMT_UNSAFE_REPLACE_SELECT
INSERT...REPLACE SELECT is unsafe because which rows are replaced depends on the order that rows are ...
Definition: sql_lex.h:2712
@ BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT
CREATE TABLE...REPLACE... SELECT is unsafe because which rows are replaced depends on the order that ...
Definition: sql_lex.h:2726
@ BINLOG_STMT_UNSAFE_UDF
Using a UDF (user-defined function) is unsafe.
Definition: sql_lex.h:2656
@ BINLOG_STMT_UNSAFE_UPDATE_IGNORE
UPDATE...IGNORE is unsafe because which rows are ignored depends on the order that rows are updated.
Definition: sql_lex.h:2741
@ BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT
Query that writes to a table with auto_inc column after selecting from other tables are unsafe as the...
Definition: sql_lex.h:2705
@ BINLOG_STMT_UNSAFE_SYSTEM_TABLE
Access to log tables is unsafe because slave and master probably log different things.
Definition: sql_lex.h:2643
Query_tables_list & operator=(Query_tables_list &&)=default
Table_ref * query_tables
Definition: sql_lex.h:2519
@ START_SROUTINES_HASH_SIZE
Definition: sql_lex.h:2536
bool requires_prelocking()
Definition: sql_lex.h:2602
void chop_off_not_own_tables()
Definition: sql_lex.h:2610
Table_ref * first_not_own_table()
Definition: sql_lex.h:2607
Table_ref ** query_tables_own_last
Definition: sql_lex.h:2528
bool get_using_match()
Definition: sql_lex.h:3076
uint32 binlog_stmt_flags
Bit field indicating the type of statement.
Definition: sql_lex.h:3115
bool is_query_tables_locked() const
Definition: sql_lex.h:2566
enum_lock_tables_state
Locking state of tables in this particular statement.
Definition: sql_lex.h:2564
@ LTS_LOCKED
Definition: sql_lex.h:2564
@ LTS_NOT_LOCKED
Definition: sql_lex.h:2564
void add_to_query_tables(Table_ref *table)
Definition: sql_lex.h:2598
Common base class for n-ary set operations, including unary.
Definition: query_term.h:402
Query term tree structure.
Definition: query_term.h:209
virtual Query_block * query_block() const =0
The query_block which holds the ORDER BY and LIMIT information for this set operation.
Query_term_set_op * m_parent
Back pointer to the node whose child we are, or nullptr (root term).
Definition: query_term.h:272
virtual Query_term_type term_type() const =0
Get the node tree type.
Containing class for iterator over the query term tree.
Definition: query_term.h:579
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:82
Simple intrusive linked list.
Definition: sql_list.h:46
Base class for secondary engine execution context objects.
Definition: sql_lex.h:2446
virtual ~Secondary_engine_execution_context()=default
Destructs the secondary engine execution context object.
Abstract base class for traversing the Query_block tree.
Definition: select_lex_visitor.h:40
Context object used by semijoin equality decorrelation code.
Definition: sql_resolver.cc:2551
This class represent server options as set by the parser.
Definition: sql_servers.h:71
Representation of an SQL command.
Definition: sql_cmd.h:65
Structure that represents element in the set of stored routines used by statement or routine.
Definition: sp.h:224
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:168
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Class representing a table function.
Definition: table_function.h:53
Definition: sql_lex.h:294
Table_ident(Query_expression *s)
This constructor is used only for the case when we create a derived table.
Definition: sql_lex.h:315
void change_db(const char *db_name)
Definition: sql_lex.h:334
Query_expression * sel
Definition: sql_lex.h:298
Table_ident(Protocol *protocol, const LEX_CSTRING &db_arg, const LEX_CSTRING &table_arg, bool force)
Definition: sql_lex.cc:153
Table_ident(const LEX_CSTRING &table_arg)
Definition: sql_lex.h:305
bool is_table_function() const
Definition: sql_lex.h:331
bool is_derived_table() const
Definition: sql_lex.h:333
Table_ident(LEX_CSTRING &table_arg, Table_function *table_func_arg)
Definition: sql_lex.h:325
LEX_CSTRING table
Definition: sql_lex.h:297
Table_function * table_function
Definition: sql_lex.h:299
LEX_CSTRING db
Definition: sql_lex.h:296
Table_ident(const LEX_CSTRING &db_arg, const LEX_CSTRING &table_arg)
Definition: sql_lex.h:303
Table_ref * first_leaf_table()
Return first leaf table of a base table or a view/derived table.
Definition: table.h:3219
Table_ref ** prev_global
Definition: table.h:3487
Table_ref * next_leaf
Definition: table.h:3677
Table_ref * next_global
Definition: table.h:3487
Used for storing information associated with generated column, default values generated from expressi...
Definition: field.h:483
Represents the (explicit) window of a SQL 2003 section 7.11 <window clause>, or the implicit (inlined...
Definition: window.h:105
The internal state of the syntax parser.
Definition: sql_lexer_yacc_state.h:246
Yacc_state()
Definition: sql_lexer_yacc_state.h:248
void reset()
Definition: sql_lexer_yacc_state.h:252
thr_lock_type m_lock_type
Type of lock to be used for tables being added to the statement's table list in table_factor,...
Definition: sql_lexer_yacc_state.h:321
uchar * yacc_yyvs
Bison internal semantic value stack, yyvs, when dynamically allocated using my_yyoverflow().
Definition: sql_lexer_yacc_state.h:296
enum_mdl_type m_mdl_type
The type of requested metadata lock for tables added to the statement table list.
Definition: sql_lexer_yacc_state.h:327
~Yacc_state()
Definition: sql_lexer_yacc_state.h:269
uchar * yacc_yyss
Bison internal state stack, yyss, when dynamically allocated using my_yyoverflow().
Definition: sql_lexer_yacc_state.h:290
void reset_before_substatement()
Reset part of the state which needs resetting before parsing substatement.
Definition: sql_lexer_yacc_state.h:281
uchar * yacc_yyls
Bison internal location value stack, yyls, when dynamically allocated using my_yyoverflow().
Definition: sql_lexer_yacc_state.h:302
The class hold dynamic table statistics for a table.
Definition: table_stats.h:103
void invalidate_cache(void)
Definition: table_stats.h:216
The class hold dynamic table statistics for a table.
Definition: tablespace_stats.h:64
void invalidate_cache(void)
Definition: tablespace_stats.h:111
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:110
Definition: partition_info.h:209
sp_head represents one instance of a stored program.
Definition: sp_head.h:380
Definition: sp_head.h:120
The class represents parse-time context, which keeps track of declared variables/parameters,...
Definition: sp_pcontext.h:252
static MEM_ROOT mem_root
Definition: client_plugin.cc:110
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:31
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
Acl_type
Definition: sql_lex.h:261
uint to_uint(enum_sp_type val)
Definition: sql_lex.h:246
const char * index_hint_type_name[]
Definition: sql_lex.cc:133
enum_sp_data_access
Definition: sql_lex.h:205
void print_derived_column_names(const THD *thd, String *str, const Create_col_name_list *column_names)
Prints into 'str' a comma-separated list of column names, enclosed in parenthesis.
Definition: sql_lex.cc:2088
bool db_is_default_db(const char *db, size_t db_len, const THD *thd)
Definition: sql_lex.cc:2819
bool check_select_for_locking_clause(THD *)
sub_select_type
Definition: sql_lex.h:461
#define TYPE_ENUM_PROCEDURE
Definition: sql_lex.h:257
enum_alter_user_attribute
Definition: sql_lex.h:280
void binlog_unsafe_map_init()
Definition: sql_lex.cc:5017
Bounds_checked_array< Item * > Ref_item_array
Definition: sql_lex.h:1125
longlong to_longlong(enum_sp_type val)
Definition: sql_lex.h:242
enum_view_create_mode
Definition: sql_lex.h:274
bool walk_join_list(mem_root_deque< Table_ref * > &list, std::function< bool(Table_ref *)> action)
Definition: sql_resolver.cc:2777
bool is_union() const
Definition: sql_lex.h:2394
uint binlog_unsafe_map[256]
Definition: sql_lex.cc:4922
void lex_end(LEX *lex)
Call this function after preparation and execution of a query.
Definition: sql_lex.cc:535
enum_sp_type to_sp_type(longlong val)
Definition: sql_lex.h:234
struct struct_slave_connection LEX_SLAVE_CONNECTION
enum_explain_type
Query_block type enum.
Definition: sql_lex.h:1131
#define TYPE_ENUM_FUNCTION
Definition: sql_lex.h:256
int MYSQLlex(union YYSTYPE *, struct YYLTYPE *, class THD *)
yylex() function implementation for the main parser
Definition: sql_lex.cc:1301
const LEX_STRING null_lex_str
LEX_STRING constant for null-string to be used in parser and other places.
Definition: sql_lex.cc:89
enum_sp_type
enum_sp_type defines type codes of stored programs.
Definition: sql_lex.h:222
void lex_free(void)
Definition: sql_lex.cc:175
bool is_set_operation() const
Definition: sql_lex.h:2401
constexpr const int MAX_SELECT_NESTING
Definition: sql_lex.h:137
void trim_whitespace(const CHARSET_INFO *cs, LEX_STRING *str)
Definition: sql_lex.cc:2057
bool is_lex_native_function(const LEX_STRING *name)
Check if name is a sql function.
Definition: sql_lex.cc:965
uchar index_clause_map
Definition: sql_lex.h:472
bool lex_init(void)
Definition: sql_lexer.cc:1263
enum_sp_suid_behaviour
Definition: sql_lex.h:199
const size_t INITIAL_LEX_PLUGIN_LIST_SIZE
Definition: sql_lex.h:136
bool is_keyword(const char *name, size_t len)
Definition: sql_lex.cc:950
const LEX_CSTRING sp_data_access_name[]
Definition: sql_lex.h:267
enum_keep_diagnostics
Definition: sql_lex.h:191
bool lex_start(THD *thd)
Call lex_start() before every query that is to be prepared and executed.
Definition: sql_lex.cc:511
@ SP_READS_SQL_DATA
Definition: sql_lex.h:209
@ SP_MODIFIES_SQL_DATA
Definition: sql_lex.h:210
@ SP_NO_SQL
Definition: sql_lex.h:208
@ SP_DEFAULT_ACCESS
Definition: sql_lex.h:206
@ SP_CONTAINS_SQL
Definition: sql_lex.h:207
@ UNSPECIFIED_TYPE
Definition: sql_lex.h:462
@ DERIVED_TABLE_TYPE
Definition: sql_lex.h:464
@ GLOBAL_OPTIONS_TYPE
Definition: sql_lex.h:463
@ ALTER_USER_COMMENT_NOT_USED
@ EXPLAIN_INTERSECT_RESULT
@ EXPLAIN_total
fake type, total number of all valid types
@ NO_COMMENT
Not parsing comments.
Definition: sql_lex.h:3157
@ DISCARD_COMMENT
Parsing comments that need to be discarded.
Definition: sql_lex.h:3173
@ PRESERVE_COMMENT
Parsing comments that need to be preserved.
Definition: sql_lex.h:3164
@ SP_IS_SUID
Definition: sql_lex.h:202
@ SP_IS_DEFAULT_SUID
Definition: sql_lex.h:200
@ SP_IS_NOT_SUID
Definition: sql_lex.h:201
@ DA_KEEP_UNSPECIFIED
keep semantics is unspecified
Definition: sql_lex.h:196
@ DA_KEEP_DIAGNOSTICS
keep the diagnostics area
Definition: sql_lex.h:193
@ DA_KEEP_PARSE_ERROR
keep diagnostics area after parse error
Definition: sql_lex.h:195
@ DA_KEEP_COUNTS
keep @warning_count / @error_count
Definition: sql_lex.h:194
@ DA_KEEP_NOTHING
keep nothing
Definition: sql_lex.h:192
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:216
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.
Definition: sql_select.cc:4167
bool optimize(THD *thd, bool finalize_access_paths)
Optimize a query block and all inner query expressions.
Definition: sql_select.cc:1993
bool check_column_privileges(THD *thd)
Check privileges for all columns referenced from query block.
Definition: sql_select.cc:2036
bool check_privileges_for_subqueries(THD *thd)
Check privileges for column references in subqueries of a query block.
Definition: sql_select.cc:2141
bool transform_scalar_subqueries_to_join_with_derived(THD *thd)
Transform eligible scalar subqueries in the SELECT list, WHERE condition, HAVING condition or JOIN co...
Definition: sql_resolver.cc:7539
Item * single_visible_field() const
Definition: sql_resolver.cc:4875
void delete_unused_merged_columns(mem_root_deque< Table_ref * > *tables)
Delete unused columns from merged tables.
Definition: sql_resolver.cc:5238
bool check_only_full_group_by(THD *thd)
Runs checks mandated by ONLY_FULL_GROUP_BY.
Definition: sql_resolver.cc:4589
void clear_sj_expressions(NESTED_JOIN *nested_join)
Remove semijoin condition for this query block.
Definition: sql_resolver.cc:2422
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 blo...
Definition: sql_resolver.cc:748
void replace_referenced_item(Item *const old_item, Item *const new_item)
Replace item in select list and preserve its reference count.
Definition: sql_resolver.cc:7070
bool record_join_nest_info(mem_root_deque< Table_ref * > *tables)
Record join nest info in the select block.
Definition: sql_resolver.cc:2199
void fix_after_pullout(Query_block *parent_query_block, Query_block *removed_query_block)
Definition: sql_resolver.cc:2381
bool transform_grouped_to_derived(THD *thd, bool *break_off)
Minion of transform_scalar_subqueries_to_join_with_derived.
Definition: sql_resolver.cc:6088
bool decorrelate_condition(Semijoin_decorrelation &sj_decor, Table_ref *join_nest)
Decorrelate the WHERE clause or a join condition of a subquery used in an IN or EXISTS predicate.
Definition: sql_resolver.cc:2732
bool transform_subquery_to_derived(THD *thd, Table_ref **out_tl, Query_expression *subs_query_expression, Item_subselect *subq, bool use_inner_join, bool reject_multiple_rows, Item *join_condition, Item *lifted_where_cond)
Converts a subquery to a derived table and inserts it into the FROM clause of the owning query block.
Definition: sql_resolver.cc:7102
bool setup_conds(THD *thd)
Resolve WHERE condition and join conditions.
Definition: sql_resolver.cc:1666
bool add_ftfunc_list(List< Item_func_match > *ftfuncs)
Add full-text function elements from a list into this query block.
Definition: sql_resolver.cc:4040
bool setup_join_cond(THD *thd, mem_root_deque< Table_ref * > *tables, bool in_update)
Resolve join conditions for a join nest.
Definition: sql_resolver.cc:1727
void remove_hidden_items()
Remove hidden items from select list.
Definition: sql_resolver.cc:5282
void remap_tables(THD *thd)
Re-map table numbers for all tables in a query block.
Definition: sql_resolver.cc:1248
void repoint_contexts_of_join_nests(mem_root_deque< Table_ref * > join_list)
Go through a list of tables and join nests, recursively, and repoint its query_block pointer.
Definition: sql_resolver.cc:4055
bool decorrelate_derived_scalar_subquery_post(THD *thd, Table_ref *derived, Lifted_fields_map *lifted_where_fields, bool added_card_check)
See explanation in companion method decorrelate_derived_scalar_subquery_pre.
Definition: sql_resolver.cc:6990
void propagate_unique_test_exclusion()
Propagate exclusion from table uniqueness test into subqueries.
Definition: sql_resolver.cc:4022
bool convert_subquery_to_semijoin(THD *thd, Item_exists_subselect *subq_pred)
Convert a subquery predicate of this query block into a Table_ref semi-join nest.
Definition: sql_resolver.cc:2957
void fix_after_pullout(Query_block *parent_query_block, Query_block *removed_query_block)
Fix used tables information for a subquery after query transformations.
Definition: sql_resolver.cc:2367
bool lift_fulltext_from_having_to_select_list(THD *thd)
Copies all non-aggregated calls to the full-text search MATCH function from the HAVING clause to the ...
Definition: sql_resolver.cc:7812
bool setup_wild(THD *thd)
Expand all '*' in list of expressions with the matching column references.
Definition: sql_resolver.cc:1610
bool remove_aggregates(THD *thd, Query_block *select)
A minion of transform_grouped_to_derived.
Definition: sql_resolver.cc:5890
bool prepare_values(THD *thd)
Prepare a table value constructor query block for optimization.
Definition: sql_resolver.cc:666
bool resolve_placeholder_tables(THD *thd, bool apply_semijoin)
Resolve derived table, view, table function information for a query block.
Definition: sql_resolver.cc:1281
bool simplify_joins(THD *thd, mem_root_deque< Table_ref * > *join_list, bool top, bool in_sj, Item **new_conds, uint *changelog=nullptr)
Simplify joins replacing outer joins by inner joins whenever it's possible.
Definition: sql_resolver.cc:1916
void update_used_tables()
Update used tables information for all local expressions.
Definition: sql_resolver.cc:853
bool 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...
Definition: sql_resolver.cc:4105
bool resolve_limits(THD *thd)
Resolve OFFSET and LIMIT clauses.
Definition: sql_resolver.cc:891
bool build_sj_cond(THD *thd, NESTED_JOIN *nested_join, Query_block *subq_query_block, table_map outer_tables_map, Item **sj_cond)
Build semijoin condition for th query block.
Definition: sql_resolver.cc:2446
int group_list_size() const
Definition: sql_resolver.cc:4737
bool empty_order_list(Query_block *sl)
Empty the ORDER list.
Definition: sql_resolver.cc:4187
bool prepare(THD *thd, mem_root_deque< Item * > *insert_field_list)
Prepare query block for optimization.
Definition: sql_resolver.cc:179
void reset_nj_counters(mem_root_deque< Table_ref * > *join_list=nullptr)
Set NESTED_JOIN::counter=0 in all nested joins in passed list.
Definition: sql_resolver.cc:1783
bool check_view_privileges(THD *thd, Access_bitmask want_privilege_first, Access_bitmask want_privilege_next)
Check privileges for views that are merged into query block.
Definition: sql_resolver.cc:1129
bool resolve_rollup_wfs(THD *thd)
Replace group by field references inside window functions with references in the presence of ROLLUP.
Definition: sql_resolver.cc:5121
bool field_list_is_empty() const
Definition: sql_resolver.cc:4891
Item ** add_hidden_item(Item *item)
Add item to the hidden part of select list.
Definition: sql_resolver.cc:5273
void merge_contexts(Query_block *inner)
Merge name resolution context objects of a subquery into its parent.
Definition: sql_resolver.cc:4072
bool transform_table_subquery_to_join_with_derived(THD *thd, Item_exists_subselect *subq_pred)
Replace a table subquery ([NOT] {IN, EXISTS}) with a join to a derived table.
Definition: sql_resolver.cc:5422
bool flatten_subqueries(THD *thd)
Convert semi-join subquery predicates into semi-join join nests.
Definition: sql_resolver.cc:3776
bool replace_subquery_in_expr(THD *thd, Item::Css_info *subquery, Table_ref *tr, Item **expr)
A minion of transform_scalar_subqueries_to_join_with_derived.
Definition: sql_resolver.cc:6564
size_t num_visible_fields() const
Definition: sql_resolver.cc:4887
ORDER * find_in_group_list(Item *item, int *rollup_level) const
Finds a group expression matching the given item, or nullptr if none.
Definition: sql_resolver.cc:4701
bool resolve_table_value_constructor_values(THD *thd)
Resolve the rows of a table value constructor and aggregate the type of each column across rows.
Definition: sql_resolver.cc:5298
bool merge_derived(THD *thd, Table_ref *derived_table)
Merge derived table into query block.
Definition: sql_resolver.cc:3427
bool setup_tables(THD *thd, Table_ref *tables, bool select_insert)
Resolve and prepare information about tables for one query block.
Definition: sql_resolver.cc:1166
bool supported_correlated_scalar_subquery(THD *thd, Item::Css_info *subquery, Item **lifted_where)
Called when the scalar subquery is correlated.
Definition: sql_resolver.cc:7312
bool replace_item_in_expression(Item **expr, bool was_hidden, Item::Item_replacement *info, Item_transformer transformer)
Minion of transform_grouped_to_derived.
Definition: sql_resolver.cc:6007
bool setup_order_final(THD *thd)
Do final setup of ORDER BY clause, after the query block is fully resolved.
Definition: sql_resolver.cc:4623
bool nest_derived(THD *thd, Item *join_cond, mem_root_deque< Table_ref * > *join_list, Table_ref *new_derived_table)
Push the generated derived table to the correct location inside a join nest.
Definition: sql_resolver.cc:6712
bool setup_group(THD *thd)
Resolve and set up the GROUP BY list.
Definition: sql_resolver.cc:4668
bool resolve_subquery(THD *thd)
Resolve predicate involving subquery.
Definition: sql_resolver.cc:1365
Table_ref * synthesize_derived(THD *thd, Query_expression *unit, Item *join_cond, bool left_outer, bool use_inner_join)
Create a new Table_ref object for this query block, for either: 1) a derived table which will replace...
Definition: sql_resolver.cc:5794
bool push_conditions_to_derived_tables(THD *thd)
Pushes parts of the WHERE condition of this query block to materialized derived tables.
Definition: sql_resolver.cc:617
bool decorrelate_derived_scalar_subquery_pre(THD *thd, Table_ref *derived, Item *lifted_where, Lifted_fields_map *lifted_where_fields, bool *added_card_check)
We have a correlated scalar subquery, so we must do several things:
Definition: sql_resolver.cc:6814
bool resolve_rollup(THD *thd)
Resolve items in SELECT list and ORDER BY list for rollup processing.
Definition: sql_resolver.cc:5026
Item * resolve_rollup_item(THD *thd, Item *item)
Resolve an item (and its tree) for rollup processing by replacing items matching grouped expressions ...
Definition: sql_resolver.cc:4937
bool is_row_count_valid_for_semi_join()
Check if the offset and limit are valid for a semijoin.
Definition: sql_resolver.cc:1333
void mark_item_as_maybe_null_if_rollup_item(Item *item)
Marks occurrences of group by fields in a function's arguments as nullable, so that we do not optimiz...
Definition: sql_resolver.cc:4862
bool add_joined_table(Table_ref *table)
Add a table to the current join list.
Definition: sql_parse.cc:6315
void set_lock_for_tables(thr_lock_type lock_type)
Set lock for all tables in current query block.
Definition: sql_parse.cc:6346
bool find_common_table_expr(THD *thd, Table_ident *table_id, Table_ref *tl, Parse_context *pc, bool *found)
Tries to match an identifier to the CTEs in scope; if matched, it modifies *table_name,...
Definition: sql_parse.cc:5730
Table_ref * end_nested_join()
End a nested join table list.
Definition: sql_parse.cc:6230
bool init_nested_join(THD *thd)
Initialize a new table list for a nested join.
Definition: sql_parse.cc:6203
Table_ref * nest_join(THD *thd, Query_block *select, Table_ref *embedding, mem_root_deque< Table_ref * > *jlist, size_t table_cnt, const char *legend)
Plumbing for nest_last_join, q.v.
Definition: sql_parse.cc:6257
Table_ref * add_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=nullptr, List< String > *partition_names=nullptr, LEX_STRING *option=nullptr, Parse_context *pc=nullptr)
Add a table to list of used tables.
Definition: sql_parse.cc:5940
void set_lock_for_table(const Lock_descriptor &descriptor, Table_ref *table)
Definition: sql_parse.cc:6323
Table_ref * nest_last_join(THD *thd, size_t table_cnt=2)
Nest last join operations.
Definition: sql_parse.cc:6297
struct PSI_digest_locker PSI_digest_locker
Definition: psi_statement_bits.h:112
static int flags[50]
Definition: hp_test1.cc:40
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:177
Item *(Item::* Item_transformer)(uchar *arg)
Type for transformers used by Item::transform and Item::compile.
Definition: item.h:723
Subquery_strategy
Strategy which will be used to handle this subquery: flattening to a semi-join, conversion to a deriv...
Definition: item_subselect.h:395
constexpr const LEX_CSTRING EMPTY_CSTR
Definition: lex_string.h:48
constexpr const LEX_CSTRING NULL_CSTR
Definition: lex_string.h:47
A better implementation of the UNIX ctype(3) library.
#define STRING_WITH_LEN(X)
Definition: m_string.h:315
Various macros useful for communicating with memory debuggers, such as Valgrind.
void TRASH(void *ptr, size_t length)
Put bad content in memory to be sure it will segfault if dereferenced.
Definition: memory_debugging.h:71
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:489
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1140
Header for compiler-dependent features.
#define MY_ASSERT_UNREACHABLE()
Definition: my_compiler.h:76
#define DBUG_EXECUTE_IF(keyword, a1)
Definition: my_dbug.h:171
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:181
#define DBUG_TRACE
Definition: my_dbug.h:146
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
uint8_t uint8
Definition: my_inttypes.h:63
unsigned char uchar
Definition: my_inttypes.h:52
long long int longlong
Definition: my_inttypes.h:55
#define MYF(v)
Definition: my_inttypes.h:97
uint32_t uint32
Definition: my_inttypes.h:67
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
enum_sql_command
Definition: my_sqlcommand.h:46
@ SQLCOM_UPDATE
Definition: my_sqlcommand.h:51
@ SQLCOM_LOAD
Definition: my_sqlcommand.h:77
@ SQLCOM_INSERT
Definition: my_sqlcommand.h:52
@ SQLCOM_INSERT_SELECT
Definition: my_sqlcommand.h:53
@ SQLCOM_REPLACE
Definition: my_sqlcommand.h:87
@ SQLCOM_UPDATE_MULTI
Definition: my_sqlcommand.h:122
@ SQLCOM_REPLACE_SELECT
Definition: my_sqlcommand.h:88
Common header for many mysys elements.
uint64_t nesting_map
Definition: my_table_map.h:31
uint64_t table_map
Definition: my_table_map.h:30
uint32 my_thread_id
Definition: my_thread_local.h:34
static bool backup
Definition: myisampack.cc:195
static bool column_names
Definition: mysql.cc:160
static const CHARSET_INFO * charset_info
Definition: mysql.cc:233
Common definition between mysql server & client.
char * octet2hex(char *to, const char *str, unsigned int len)
Definition: password.cc:139
static char * where
Definition: mysqldump.cc:140
static bool create_options
Definition: mysqldump.cc:115
const char * collation
Definition: audit_api_message_emit.cc:184
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1052
Definition: buf0block_hint.cc:30
Definition: commit_order_queue.h:34
const byte * find(const Pages *pages, const page_id_t &page_id) noexcept
Find a doublewrite copy of a page.
Definition: buf0dblwr.cc:3564
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
Definition: options.cc:49
const char * db_name
Definition: rules_table_service.cc:55
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2870
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2892
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2878
enum_parsing_context
Names for different query parse tree parts.
Definition: parse_tree_node_base.h:58
@ CTX_NONE
Empty value.
Definition: parse_tree_node_base.h:59
#define UNCACHEABLE_DEPENDENT
Definition: parse_tree_node_base.h:47
olap_type
Definition: parser_yystype.h:179
@ UNSPECIFIED_OLAP_TYPE
Definition: parser_yystype.h:179
enum_yes_no_unknown
Definition: parser_yystype.h:163
struct result result
Definition: result.h:34
Performance schema instrumentation interface.
#define SELECT_DISTINCT
Definition: query_options.h:52
#define OPTION_NO_CONST_TABLES
Definition: query_options.h:78
Query_term_type
This class hierarchy is used to represent SQL structures between <query expression> and <query specif...
Definition: query_term.h:89
@ QT_UNARY
Represents a query primary with parentesized query expression body with order by clause and/or limit/...
Definition: query_term.h:96
@ QT_EXCEPT
Definition: query_term.h:100
@ QT_UNION
Definition: query_term.h:101
@ QT_INTERSECT
Represents the three set operations.
Definition: query_term.h:99
@ QT_QUERY_BLOCK
Represents Query specification, table value constructor and explicit table.
Definition: query_term.h:92
Visit_leaves
Query term iterator template argument type: whether to visit leaf nodes.
Definition: query_term.h:107
@ VL_VISIT_LEAVES
Definition: query_term.h:107
Visit_order
Query term iterator template argument type: how to visit nodes in tree.
Definition: query_term.h:105
@ QTC_POST_ORDER
Definition: query_term.h:105
required string type
Definition: replication_group_member_actions.proto:34
repeated Action action
Definition: replication_group_member_actions.proto:43
"public" interface to sys_var - server configuration variables.
enum_var_type
Definition: set_var.h:90
enum_tx_isolation
Definition: handler.h:3029
@ ISO_REPEATABLE_READ
Definition: handler.h:3032
index_hint_type
Definition: table.h:1390
role_enum
Definition: sql_admin.h:225
my_lex_states
Definition: sql_chars.h:38
File containing constants that can be used throughout the server.
constexpr const uint8_t CONTEXT_ANALYSIS_ONLY_PREPARE
Don't evaluate this subquery during statement prepare even if it's a constant one.
Definition: sql_const.h:173
enum_walk
Enumeration for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:287
bool(Item::*)(unsigned char *) Item_processor
Processor type for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:305
constexpr const uint8_t CONTEXT_ANALYSIS_ONLY_VIEW
Special Query_block::prepare mode: changing of query is prohibited.
Definition: sql_const.h:181
enum_condition_context
Enumeration for Query_block::condition_context.
Definition: sql_const.h:311
Contains classes representing SQL-data change statements.
enum_duplicates
Definition: sql_data_change.h:48
bool walk_item(Item *item, Select_lex_visitor *visitor)
Definition: sql_lex.cc:3411
#define IL_GTE_REPEATABLE
Definition: sql_lex.h:2975
#define TRX_CACHE_EMPTY
Definition: sql_lex.h:2969
#define IL_LT_REPEATABLE
Definition: sql_lex.h:2973
void assert_consistent_hidden_flags(const mem_root_deque< Item * > &fields, Item *item, bool hidden)
In debug mode, verify that we're not adding an item twice to the fields list with inconsistent hidden...
Definition: sql_lex.h:4789
#define BINLOG_DIRECT_OFF
Definition: sql_lex.h:2966
#define BINLOG_DIRECT_ON
Definition: sql_lex.h:2963
bool is_invalid_string(const LEX_CSTRING &string_val, const CHARSET_INFO *charset_info)
(End of group GROUP_PARSER)
Definition: sql_lex.h:4736
bool accept_for_order(SQL_I_List< ORDER > orders, Select_lex_visitor *visitor)
Definition: sql_lex.cc:3417
#define TRX_CACHE_NOT_EMPTY
Definition: sql_lex.h:2971
bool accept_for_join(mem_root_deque< Table_ref * > *tables, Select_lex_visitor *visitor)
Definition: sql_lex.cc:3439
bool accept_table(Table_ref *t, Select_lex_visitor *visitor)
Definition: sql_lex.cc:3447
enum_mdl_type
Type of metadata lock request.
Definition: sql_lexer_yacc_state.h:106
@ MDL_SHARED_READ
Definition: sql_lexer_yacc_state.h:169
static const Query_options options
Definition: sql_show_processlist.cc:69
Our own string classes, used pervasively throughout the executor.
size_t convert_to_printable(char *to, size_t to_len, const char *from, size_t from_len, const CHARSET_INFO *from_cs, size_t nbytes=0)
Convert string to printable ASCII string.
Definition: sql_string.cc:1018
bool validate_string(const CHARSET_INFO *cs, const char *str, size_t length, size_t *valid_length, bool *length_error)
Check if an input byte sequence is a valid character string of a given charset.
Definition: sql_string.cc:1125
case opt name
Definition: sslopt-case.h:33
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:193
Definition: m_ctype.h:385
const char * csname
Definition: m_ctype.h:390
Definition: handler.h:3632
Struct to hold information about the table that should be created.
Definition: handler.h:3045
Minion class under Collect_scalar_subquery_info.
Definition: item.h:2771
Structure to hold parameters for CHANGE MASTER, START SLAVE, and STOP SLAVE.
Definition: sql_lex.h:350
Prealloced_array< ulong, 2 > repl_ignore_server_ids
Definition: sql_lex.h:404
LEX_MASTER_INFO & operator=(const LEX_MASTER_INFO &)
char * relay_log_name
Definition: sql_lex.h:400
char * ssl_key
Definition: sql_lex.h:387
char * ssl_ca
Definition: sql_lex.h:387
@ LEX_MI_UNCHANGED
Definition: sql_lex.h:380
@ LEX_MI_ENABLE
Definition: sql_lex.h:382
@ LEX_MI_DISABLE
Definition: sql_lex.h:381
enum LEX_MASTER_INFO::@171 repl_ignore_server_ids_opt
char * log_file_name
Definition: sql_lex.h:358
char * user
Definition: sql_lex.h:358
enum LEX_MASTER_INFO::@172 require_table_primary_key_check
Identifies what is the slave policy on primary keys in tables.
void set_unspecified()
Sets all fields to their "unspecified" value.
Definition: sql_lex.cc:4917
ulonglong pos
Definition: sql_lex.h:362
float heartbeat_period
Definition: sql_lex.h:360
char * view_id
Definition: sql_lex.h:365
enum LEX_MASTER_INFO::@171 m_gtid_only
uint port
Definition: sql_lex.h:359
enum LEX_MASTER_INFO::@170 gtid_until_condition
enum LEX_MASTER_INFO::@171 retry_count_opt
bool privilege_checks_none
Flag that is set to true whenever PRIVILEGE_CHECKS_USER is set to NULL as a part of a CHANGE MASTER T...
Definition: sql_lex.h:409
void initialize()
Initializes everything to zero/NULL/empty.
Definition: sql_lex.cc:4880
enum enum_tls_ciphersuites tls_ciphersuites
Definition: sql_lex.h:397
ulong retry_count
Definition: sql_lex.h:363
char * ssl_cert
Definition: sql_lex.h:387
enum LEX_MASTER_INFO::@173 assign_gtids_to_anonymous_transactions_type
enum LEX_MASTER_INFO::@171 heartbeat_opt
ulong server_id
Definition: sql_lex.h:363
char * ssl_crl
Definition: sql_lex.h:388
char * network_namespace
Definition: sql_lex.h:358
bool until_after_gaps
Definition: sql_lex.h:371
char * compression_algorithm
Definition: sql_lex.h:402
bool slave_until
Definition: sql_lex.h:372
LEX_MASTER_INFO()
Definition: sql_lex.h:355
uint connect_retry
Definition: sql_lex.h:359
enum LEX_MASTER_INFO::@171 port_opt
enum LEX_MASTER_INFO::@171 get_public_key
enum LEX_MASTER_INFO::@171 auto_position
enum_tls_ciphersuites
Definition: sql_lex.h:392
@ SPECIFIED_STRING
Definition: sql_lex.h:395
@ UNSPECIFIED
Definition: sql_lex.h:393
@ SPECIFIED_NULL
Definition: sql_lex.h:394
char * password
Definition: sql_lex.h:358
@ LEX_MI_ANONYMOUS_TO_GTID_LOCAL
Definition: sql_lex.h:440
@ LEX_MI_ANONYMOUS_TO_GTID_UUID
Definition: sql_lex.h:441
@ LEX_MI_ANONYMOUS_TO_GTID_OFF
Definition: sql_lex.h:439
@ LEX_MI_ANONYMOUS_TO_GTID_UNCHANGED
Definition: sql_lex.h:438
@ UNTIL_SQL_BEFORE_GTIDS
Definition: sql_lex.h:368
@ UNTIL_SQL_AFTER_GTIDS
Definition: sql_lex.h:369
LEX_MASTER_INFO(const LEX_MASTER_INFO &)
char * host
Definition: sql_lex.h:358
char * tls_version
Definition: sql_lex.h:388
char * ssl_cipher
Definition: sql_lex.h:387
bool for_channel
Definition: sql_lex.h:373
const char * assign_gtids_to_anonymous_transactions_manual_uuid
Definition: sql_lex.h:444
char * gtid
Definition: sql_lex.h:364
const char * privilege_checks_username
Username and hostname parts of the PRIVILEGE_CHECKS_USER, when it's set to a user.
Definition: sql_lex.h:414
char * ssl_capath
Definition: sql_lex.h:387
char * ssl_crlpath
Definition: sql_lex.h:388
char * bind_addr
Definition: sql_lex.h:358
enum LEX_MASTER_INFO::@171 ssl
uint zstd_compression_level
Definition: sql_lex.h:403
const char * channel
Definition: sql_lex.h:366
@ LEX_MI_PK_CHECK_GENERATE
Definition: sql_lex.h:434
@ LEX_MI_PK_CHECK_STREAM
Definition: sql_lex.h:431
@ LEX_MI_PK_CHECK_ON
Definition: sql_lex.h:432
@ LEX_MI_PK_CHECK_OFF
Definition: sql_lex.h:433
@ LEX_MI_PK_CHECK_UNCHANGED
Definition: sql_lex.h:430
int sql_delay
Definition: sql_lex.h:361
enum LEX_MASTER_INFO::@171 m_source_connection_auto_failover
char * tls_ciphersuites_string
Definition: sql_lex.h:398
int require_row_format
Flag indicating if row format should be enforced for this channel event stream.
Definition: sql_lex.h:419
char * public_key_path
Definition: sql_lex.h:399
const char * privilege_checks_hostname
Definition: sql_lex.h:414
enum LEX_MASTER_INFO::@171 ssl_verify_server_cert
ulong relay_log_pos
Definition: sql_lex.h:401
Definition: sql_lex.h:457
bool all
Definition: sql_lex.h:458
The LEX object currently serves three different purposes:
Definition: sql_lex.h:3710
void set_uncacheable(Query_block *curr_query_block, uint8 cause)
Set the current query as uncacheable.
Definition: sql_lex.h:4279
LEX_USER * grant_user
Definition: sql_lex.h:3770
bool binlog_need_explicit_defaults_ts
Definition: sql_lex.h:4197
uint grant_tot_col
Definition: sql_lex.h:3957
LEX_STRING prepared_stmt_code
Definition: sql_lex.h:4021
const char * x509_issuer
Definition: sql_lex.h:3763
bool all_privileges
Definition: sql_lex.h:4029
bool is_exec_started() const
Definition: sql_lex.h:4109
bool use_only_table_context
During name resolution search only in the table list given by Name_resolution_context::first_name_res...
Definition: sql_lex.h:4182
bool ignore_unknown_user
refers to optional IGNORE UNKNOWN USER clause in REVOKE sql.
Definition: sql_lex.h:3987
std::vector< uint > reparse_derived_table_params_at
If currently re-parsing a condition that is being pushed down to a derived table, this has the positi...
Definition: sql_lex.h:3946
void restore_backup_query_tables_list(Query_tables_list *backup)
Definition: sql_lex.cc:4194
uint8 create_view_check
Definition: sql_lex.h:3968
Prealloced_array< plugin_ref, INITIAL_LEX_PLUGIN_LIST_SIZE > Plugins_array
Definition: sql_lex.h:3782
bool new_top_level_query()
Create top-level query expression and query block.
Definition: sql_lex.cc:779
bool need_correct_ident()
Definition: sql_lex.cc:3694
LEX_ALTER alter_password
Definition: sql_lex.h:3771
bool m_broken
see mark_broken()
Definition: sql_lex.h:4035
const char * ssl_cipher
Definition: sql_lex.h:3763
bool table_or_sp_used()
Definition: sql_lex.cc:4210
Query_block * new_set_operation_query(Query_block *curr_query_block)
Create query block and attach it to the current query expression.
Definition: sql_lex.cc:703
void first_lists_tables_same()
Definition: sql_lex.cc:4084
Secondary_engine_execution_context * m_secondary_engine_context
Context object used by secondary storage engines to store query state during optimization and executi...
Definition: sql_lex.h:4399
bool was_replication_command_executed() const
Definition: sql_lex.h:4439
LEX_CSTRING prepared_stmt_name
Definition: sql_lex.h:4016
LEX_RESET_SLAVE reset_slave_info
Definition: sql_lex.h:3890
List< Name_resolution_context > context_stack
Definition: sql_lex.h:3879
bool autocommit
Definition: sql_lex.h:3989
Table_ref * insert_table
Table being inserted into (may be a view)
Definition: sql_lex.h:3786
void destroy()
Destroy contained objects, but not the LEX object itself.
Definition: sql_lex.h:4210
Query_result * result
Definition: sql_lex.h:3766
void destroy_values_map()
Definition: sql_lex.h:3836
void set_was_replication_command_executed()
Definition: sql_lex.h:4443
void set_current_query_block(Query_block *select)
Definition: sql_lex.h:3731
uint start_transaction_opt
Definition: sql_lex.h:3965
void new_static_query(Query_expression *sel_query_expression, Query_block *select)
Create query expression and query block in existing memory objects.
Definition: sql_lex.cc:811
bool deny_window_function(Query_block *qb) const
We have detected the presence of an alias of a window function with a window on query block qb.
Definition: sql_lex.h:4143
HA_CHECK_OPT check_opt
Definition: sql_lex.h:3883
bool drop_if_exists
Definition: sql_lex.h:3974
Table_ref * unlink_first_table(bool *link_to_local)
Definition: sql_lex.cc:4034
bool is_metadata_used() const
Check if the current statement uses meta-data (uses a table or a stored routine).
Definition: sql_lex.h:4131
bool is_lex_started
Definition: sql_lex.h:4184
bool is_explain() const
Definition: sql_lex.h:3738
char * to_log
Definition: sql_lex.h:3762
bool no_write_to_binlog
Definition: sql_lex.h:3990
bool drop_temporary
Definition: sql_lex.h:3988
void insert_values_map(Item_field *f1, Field *f2)
Definition: sql_lex.h:3831
Plugins_array plugins
Definition: sql_lex.h:3783
List< LEX_USER > * default_roles
Definition: sql_lex.h:3805
bool m_has_udf
True if statement references UDF functions.
Definition: sql_lex.h:4005
void mark_broken(bool broken=true)
Certain permanent transformations (like in2exists), if they fail, may leave the LEX in an inconsisten...
Definition: sql_lex.h:4085
bool is_ignore() const
Definition: sql_lex.h:4009
Alter_info * alter_info
Definition: sql_lex.h:4014
const char * stmt_definition_end
Definition: sql_lex.h:4174
void set_exec_completed()
Definition: sql_lex.h:4122
List< LEX_CSTRING > dynamic_privileges
Definition: sql_lex.h:3804
ulonglong m_statement_options
Statement context for Query_block::make_active_options.
Definition: sql_lex.h:4055
List< LEX_COLUMN > columns
Definition: sql_lex.h:3803
void cleanup_after_one_table_open()
Definition: sql_lex.cc:4153
Query_expression * unit
Outer-most query expression.
Definition: sql_lex.h:3713
bool verbose
Definition: sql_lex.h:3990
enum_view_create_mode create_view_mode
Definition: sql_lex.h:3952
bool has_values_map() const
Definition: sql_lex.h:3848
Opt_hints_global * opt_hints_global
Definition: sql_lex.h:3778
bool make_sql_cmd(Parse_tree_root *parse_tree)
Uses parse_tree to instantiate an Sql_cmd object and assigns it to the Lex.
Definition: sql_lex.cc:4964
List< LEX_USER > users_list
Definition: sql_lex.h:3802
LEX_MASTER_INFO mi
Definition: sql_lex.h:3886
List< Item_param > param_list
List of placeholders ('?') for parameters of a prepared statement.
Definition: sql_lex.h:3827
bool grant_if_exists
refers to optional IF EXISTS clause in REVOKE sql.
Definition: sql_lex.h:3980
dd::info_schema::Table_statistics m_IS_table_stats
IS schema queries read some dynamic table statistics from SE.
Definition: sql_lex.h:4384
enum enum_duplicates duplicates
Definition: sql_lex.h:3949
bool is_single_level_stmt()
check if the statement is a single-level join
Definition: sql_lex.h:4363
bool m_extended_show
Definition: sql_lex.h:3992
USER_RESOURCES mqh
Definition: sql_lex.h:3889
bool using_hypergraph_optimizer() const
Whether the currently-running query should be (attempted) executed in the hypergraph optimizer.
Definition: sql_lex.h:3748
bool only_view
Definition: sql_lex.h:4155
bool save_cmd_properties(THD *thd)
Definition: sql_lex.h:4305
sp_pcontext * sp_current_parsing_ctx
Current SP parsing context.
Definition: sql_lex.h:4050
bool will_contextualize
Used to inform the parser whether it should contextualize the parse tree.
Definition: sql_lex.h:4203
st_sp_chistics sp_chistics
Definition: sql_lex.h:4151
KEY_CREATE_INFO key_create_info
Definition: sql_lex.h:3885
bool is_replication_deprecated_syntax_used()
Definition: sql_lex.h:4427
enum enum_tx_isolation tx_isolation
Definition: sql_lex.h:3950
void set_sp_current_parsing_ctx(sp_pcontext *ctx)
Definition: sql_lex.h:4125
uint32 next_binlog_file_nr
Definition: sql_lex.h:4032
bool check_preparation_invalid(THD *thd)
Check whether preparation state for prepared statement is invalid.
Definition: sql_lex.cc:845
dd::info_schema::Tablespace_statistics m_IS_tablespace_stats
Definition: sql_lex.h:4385
sp_pcontext * get_sp_current_parsing_ctx()
Definition: sql_lex.h:4123
LEX_STRING binlog_stmt_arg
Argument of the BINLOG event statement.
Definition: sql_lex.h:3767
Query_block * new_query(Query_block *curr_query_block)
Create query expression object that contains one query block.
Definition: sql_lex.cc:644
THD * thd
Definition: sql_lex.h:3775
bool rewrite_required
Definition: sql_lex.h:4450
bool contains_plaintext_password
Definition: sql_lex.h:4030
LEX_STRING name
Definition: sql_lex.h:3760
uint8 create_view_algorithm
Definition: sql_lex.h:3967
ulong max_execution_time
Definition: sql_lex.h:4191
void restore_cmd_properties()
Definition: sql_lex.h:4297
bool grant_privilege
Set to true when GRANT ... GRANT OPTION ... TO ... is used (vs.
Definition: sql_lex.h:3964
bool m_exec_completed
Set to true when execution is completed, ie optimization has been done and execution is successful or...
Definition: sql_lex.h:4045
LEX_STRING ident
Definition: sql_lex.h:3769
ulonglong bulk_insert_row_cnt
Definition: sql_lex.h:3807
void set_has_udf()
Definition: sql_lex.h:4011
bool has_udf() const
Definition: sql_lex.h:4012
List< Item_func_set_user_var > set_var_list
Definition: sql_lex.h:3817
uint8 create_view_suid
Definition: sql_lex.h:4159
bool push_context(Name_resolution_context *context)
Definition: sql_lex.h:4337
void pop_context()
Definition: sql_lex.h:4341
bool m_was_replication_command_executed
Definition: sql_lex.h:4436
uint slave_thd_opt
Definition: sql_lex.h:3965
enum enum_yes_no_unknown tx_chain tx_release
Definition: sql_lex.h:3994
void clear_privileges()
Definition: sql_lex.cc:3489
LEX()
Definition: sql_lex.cc:3580
partition_info * part_info
Definition: sql_lex.h:3794
bool m_using_hypergraph_optimizer
Definition: sql_lex.h:3757
char * help_arg
Definition: sql_lex.h:3761
Server_options server_options
Definition: sql_lex.h:3888
bool copy_db_to(char const **p_db, size_t *p_db_length) const
This method should be called only during parsing.
Definition: sql_lex.cc:3724
enum_alter_user_attribute alter_user_attribute
Definition: sql_lex.h:3772
std::map< Item_field *, Field * >::iterator end_values_map()
Definition: sql_lex.h:3852
List< Item > purge_value_list
Definition: sql_lex.h:3810
Query_block * current_query_block() const
Definition: sql_lex.h:3722
std::map< Item_field *, Field * > * insert_update_values_map
Definition: sql_lex.h:3863
bool ignore
Definition: sql_lex.h:4006
Name_resolution_context * current_context()
Definition: sql_lex.h:4349
enum SSL_type ssl_type
Definition: sql_lex.h:3948
bool is_explain_analyze
Definition: sql_lex.h:3739
HA_CREATE_INFO * create_info
Definition: sql_lex.h:3884
void set_using_hypergraph_optimizer(bool use_hypergraph)
Definition: sql_lex.h:3752
void assert_ok_set_current_query_block()
Definition: sql_lex.cc:396
Query_block * new_empty_query_block()
Create an empty query block within this LEX object.
Definition: sql_lex.cc:587
bool in_update_value_clause
Set to true while resolving values in ON DUPLICATE KEY UPDATE clause.
Definition: sql_lex.h:4186
Query_block * all_query_blocks_list
List of all query blocks.
Definition: sql_lex.h:3716
void release_plugins()
Definition: sql_lex.cc:546
uint reparse_common_table_expr_at
If currently re-parsing a CTE's definition, this is the offset in bytes of that definition in the ori...
Definition: sql_lex.h:3935
Event_parse_data * event_parse_data
Definition: sql_lex.h:4153
bool safe_to_cache_query
Whether this query will return the same answer every time, given unchanged data.
Definition: sql_lex.h:4001
sp_name * spname
Definition: sql_lex.h:4027
bool prepared_stmt_code_is_varref
Definition: sql_lex.h:4023
void set_ignore(bool ignore_param)
Definition: sql_lex.h:4010
my_thread_id show_profile_query_id
QUERY ID for SHOW PROFILE.
Definition: sql_lex.h:3955
List< set_var_base > var_list
Definition: sql_lex.h:3816
bool reparse_derived_table_condition
If currently re-parsing a condition which is pushed down to a derived table, this will be set to true...
Definition: sql_lex.h:3940
LEX_STRING alter_user_comment_text
Definition: sql_lex.h:3773
bool is_ps_or_view_context_analysis()
Definition: sql_lex.h:4257
Query_block * query_block
First query block.
Definition: sql_lex.h:3715
ulonglong statement_options()
Gets the options that have been set for this statement.
Definition: sql_lex.h:4065
bool which_check_option_applicable()
Definition: sql_lex.h:4320
bool set_wild(LEX_STRING)
Definition: sql_lex.cc:4871
uint grant
Definition: sql_lex.h:3957
enum_keep_diagnostics keep_diagnostics
Definition: sql_lex.h:4031
LEX_SLAVE_CONNECTION slave_connection
Definition: sql_lex.h:3887
bool is_rewrite_required()
Definition: sql_lex.h:4455
Table_ref * insert_table_leaf
Leaf table being inserted into (always a base table)
Definition: sql_lex.h:3788
LEX_USER * definer
Definition: sql_lex.h:3800
void set_rewrite_required()
Definition: sql_lex.h:4453
List< Item > kill_value_list
Definition: sql_lex.h:3813
void restore_properties_for_insert()
Definition: sql_lex.h:4299
void clear_values_map()
Definition: sql_lex.h:3843
void set_secondary_engine_execution_context(Secondary_engine_execution_context *context)
Sets the secondary engine execution context for this statement.
Definition: sql_lex.cc:5110
bool is_broken() const
Definition: sql_lex.h:4076
bool sp_lex_in_use
Definition: sql_lex.h:4028
List< LEX_STRING > prepared_stmt_params
Definition: sql_lex.h:4025
Secondary_engine_execution_context * secondary_engine_execution_context() const
Gets the secondary engine execution context for this statement.
Definition: sql_lex.h:4405
st_parsing_options parsing_options
Definition: sql_lex.h:4013
int select_number
Number of query block (by EXPLAIN)
Definition: sql_lex.h:3966
void add_statement_options(ulonglong options)
Add options to values of m_statement_options.
Definition: sql_lex.h:4073
uint profile_options
Definition: sql_lex.h:3956
Query_expression * create_query_expr_and_block(THD *thd, Query_block *current_query_block, Item *where_clause, Item *having_clause, enum_parsing_context ctx)
Create query expression under current_query_block and a query block under the new query expression.
Definition: sql_lex.cc:597
void set_replication_deprecated_syntax_used()
Definition: sql_lex.h:4431
nesting_map m_deny_window_func
Windowing functions are not allowed in HAVING - in contrast to grouped aggregate functions,...
Definition: sql_lex.h:3914
LEX_GRANT_AS grant_as
Definition: sql_lex.h:3774
String * wild
Definition: sql_lex.h:3765
bool expr_allows_subquery
Definition: sql_lex.h:3929
void reset()
Reset query context to initial state.
Definition: sql_lex.cc:418
bool m_exec_started
Set to true when execution has started (after parsing, tables opened and query preparation is complet...
Definition: sql_lex.h:4040
void clear_execution()
Clear execution state for a statement after it has been prepared or executed, and before it is (re-)e...
Definition: sql_lex.cc:558
bool locate_var_assignment(const Name_string &name)
Locate an assignment to a user variable with a given name, within statement.
Definition: sql_lex.cc:4227
Sql_cmd * m_sql_cmd
Definition: sql_lex.h:3921
void reset_rewrite_required()
Definition: sql_lex.h:4454
LEX_STRING create_view_query_block
SELECT of CREATE VIEW statement.
Definition: sql_lex.h:3791
bool set_channel_name(LEX_CSTRING name={})
Set replication channel name.
Definition: sql_lex.cc:4983
bool accept(Select_lex_visitor *visitor)
Definition: sql_lex.cc:4867
void reset_exec_started()
Definition: sql_lex.h:4111
sp_head * sphead
Definition: sql_lex.h:4026
void reset_n_backup_query_tables_list(Query_tables_list *backup)
Definition: sql_lex.cc:4177
udf_func udf
Definition: sql_lex.h:3882
void set_trg_event_type_for_tables()
Set the initial purpose of this Table_ref object in the list of used tables.
Definition: sql_lex.cc:3899
void link_first_table_back(Table_ref *first, bool link_to_local)
Definition: sql_lex.cc:4120
const char * stmt_definition_begin
Intended to point to the next word after DEFINER-clause in the following statements:
Definition: sql_lex.h:4173
bool is_exec_completed() const
Check whether the statement has been executed (regardless of completion - successful or in error).
Definition: sql_lex.h:4121
enum enum_var_type option_type
Definition: sql_lex.h:3951
uint8 context_analysis_only
Definition: sql_lex.h:3973
bool can_use_merged()
check if command can use VIEW with MERGE algorithm (for top VIEWs)
Definition: sql_lex.cc:3618
bool can_not_use_merged()
Check if command can't use merged views in any part of command.
Definition: sql_lex.cc:3671
std::map< Item_field *, Field * >::iterator begin_values_map()
Definition: sql_lex.h:3849
bool m_subquery_to_derived_is_impossible
If true: during prepare, we did a subquery transformation (IN-to-EXISTS, SOME/ANY) that doesn't curre...
Definition: sql_lex.h:3919
void set_exec_started()
Definition: sql_lex.h:4110
Query_block * m_current_query_block
Definition: sql_lex.h:3719
Item_sum * in_sum_func
Definition: sql_lex.h:3881
virtual ~LEX()
Definition: sql_lex.cc:403
class Explain_format * explain_format
Definition: sql_lex.h:4188
void cleanup(bool full)
Definition: sql_lex.h:4101
nesting_map allow_sum_func
This field is used as a work field during resolving to validate the use of aggregate functions.
Definition: sql_lex.h:3903
const char * x509_subject
Definition: sql_lex.h:3763
friend bool lex_start(THD *thd)
Call lex_start() before every query that is to be prepared and executed.
Definition: sql_lex.cc:511
bool is_view_context_analysis()
Definition: sql_lex.h:4262
bool m_is_replication_deprecated_syntax_used
Definition: sql_lex.h:4424
ulong type
Definition: sql_lex.h:3891
Definition: sql_resolver.cc:6767
Definition: thr_lock.h:99
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
void * Alloc(size_t length)
Allocate memory.
Definition: my_alloc.h:145
Definition: mysql_lex_string.h:40
const char * str
Definition: mysql_lex_string.h:41
size_t length
Definition: mysql_lex_string.h:42
Definition: mysql_lex_string.h:35
Definition: materialize_path_parameters.h:42
Struct NESTED_JOIN is used to represent how tables are connected through outer join operations and se...
Definition: nested_join.h:78
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:121
Bison "location" class.
Definition: parse_location.h:43
State data storage for digest_start, digest_add_token.
Definition: sql_digest_stream.h:36
Definition: sql_lex.h:4686
Definition: sql_lex.h:3142
void reset()
Definition: sql_lex.cc:179
bool allows_select_into
Definition: sql_lex.h:3144
bool allows_variable
Definition: sql_lex.h:3143
st_parsing_options()
Definition: sql_lex.h:3146
Definition: sql_lex.h:2466
LEX_CSTRING comment
Definition: sql_lex.h:2467
enum enum_sp_data_access daccess
Definition: sql_lex.h:2470
bool detistic
Definition: sql_lex.h:2469
enum enum_sp_suid_behaviour suid
Definition: sql_lex.h:2468
Definition: sql_lex.h:2475
enum enum_trigger_event_type event
Definition: sql_lex.h:2477
LEX_CSTRING anchor_trigger_name
Trigger name referenced in the FOLLOWS/PRECEDES clause of the CREATE TRIGGER statement.
Definition: sql_lex.h:2488
enum enum_trigger_order_type ordering_clause
FOLLOWS or PRECEDES as specified in the CREATE TRIGGER statement.
Definition: sql_lex.h:2482
enum enum_trigger_action_time_type action_time
Definition: sql_lex.h:2476
Definition: sql_lex.h:2457
char * password
Definition: sql_lex.h:2459
char * plugin_auth
Definition: sql_lex.h:2460
char * plugin_dir
Definition: sql_lex.h:2461
void reset()
Cleans slave connection info.
Definition: sql_lex.cc:187
char * user
Definition: sql_lex.h:2458
Definition: sql_connect.h:41
thr_lock_type
Definition: thr_lock.h:51
@ TL_UNLOCK
Definition: thr_lock.h:53
@ TL_READ_DEFAULT
Definition: thr_lock.h:61
This file defines all base public constants related to triggers in MySQL.
enum_trigger_event_type
Constants to enumerate possible event types on which triggers can be fired.
Definition: trigger_def.h:42
enum_trigger_order_type
Possible trigger ordering clause values:
Definition: trigger_def.h:64
enum_trigger_action_time_type
Constants to enumerate possible timings when triggers can be fired.
Definition: trigger_def.h:52
unsigned int uint
Definition: uca9-dump.cc:75
Definition: lexer_yystype.h:33
Definition: parser_yystype.h:340
#define PSI_NOT_INSTRUMENTED
Definition: validate_password_imp.cc:42
SSL_type
Definition: violite.h:305
An adapter class to support iteration over an iterator of Item * (typically mem_root_deque<Item *>),...
auto VisibleFields(mem_root_deque< Item * > &fields)
Definition: visible_fields.h:112
int n
Definition: xcom_base.cc:509