MySQL  8.0.17
Source Code Documentation
LEX Struct Reference

#include <sql_lex.h>

Inheritance diagram for LEX:
Query_tables_list st_lex_local

Public Types

typedef Prealloced_array< plugin_ref, INITIAL_LEX_PLUGIN_LIST_SIZEPlugins_array
 
- Public Types inherited from Query_tables_list
enum  { START_SROUTINES_HASH_SIZE = 16 }
 
enum  enum_lock_tables_state { LTS_NOT_LOCKED = 0, LTS_LOCKED }
 Locking state of tables in this particular statement. More...
 
enum  enum_binlog_stmt_unsafe {
  BINLOG_STMT_UNSAFE_LIMIT = 0, BINLOG_STMT_UNSAFE_SYSTEM_TABLE, BINLOG_STMT_UNSAFE_AUTOINC_COLUMNS, BINLOG_STMT_UNSAFE_UDF,
  BINLOG_STMT_UNSAFE_SYSTEM_VARIABLE, BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION, BINLOG_STMT_UNSAFE_NONTRANS_AFTER_TRANS, BINLOG_STMT_UNSAFE_MULTIPLE_ENGINES_AND_SELF_LOGGING_ENGINE,
  BINLOG_STMT_UNSAFE_MIXED_STATEMENT, BINLOG_STMT_UNSAFE_INSERT_IGNORE_SELECT, BINLOG_STMT_UNSAFE_INSERT_SELECT_UPDATE, BINLOG_STMT_UNSAFE_WRITE_AUTOINC_SELECT,
  BINLOG_STMT_UNSAFE_REPLACE_SELECT, BINLOG_STMT_UNSAFE_CREATE_IGNORE_SELECT, BINLOG_STMT_UNSAFE_CREATE_REPLACE_SELECT, BINLOG_STMT_UNSAFE_CREATE_SELECT_AUTOINC,
  BINLOG_STMT_UNSAFE_UPDATE_IGNORE, BINLOG_STMT_UNSAFE_INSERT_TWO_KEYS, BINLOG_STMT_UNSAFE_AUTOINC_NOT_FIRST, BINLOG_STMT_UNSAFE_FULLTEXT_PLUGIN,
  BINLOG_STMT_UNSAFE_SKIP_LOCKED, BINLOG_STMT_UNSAFE_NOWAIT, BINLOG_STMT_UNSAFE_XA, BINLOG_STMT_UNSAFE_DEFAULT_EXPRESSION_IN_SUBSTATEMENT,
  BINLOG_STMT_UNSAFE_COUNT
}
 All types of unsafe statements. More...
 
enum  enum_stmt_accessed_table {
  STMT_READS_TRANS_TABLE = 0, STMT_READS_NON_TRANS_TABLE, STMT_READS_TEMP_TRANS_TABLE, STMT_READS_TEMP_NON_TRANS_TABLE,
  STMT_WRITES_TRANS_TABLE, STMT_WRITES_NON_TRANS_TABLE, STMT_WRITES_TEMP_TRANS_TABLE, STMT_WRITES_TEMP_NON_TRANS_TABLE,
  STMT_ACCESS_TABLE_COUNT
}
 

Public Member Functions

SELECT_LEXcurrent_select () const
 
void assert_ok_set_current_select ()
 
void set_current_select (SELECT_LEX *select)
 
bool is_explain () const
 
bool locate_var_assignment (const Name_string &name)
 Locate an assignment to a user variable with a given name, within statement. More...
 
void insert_values_map (Field *f1, Field *f2)
 
void clear_values_map ()
 
bool has_values_map () const
 
std::map< Field *, Field * >::iterator begin_values_map ()
 
std::map< Field *, Field * >::iterator end_values_map ()
 
bool is_ignore () const
 
void set_ignore (bool ignore_param)
 
ulonglong statement_options ()
 
void add_statement_options (ulonglong options)
 Add options to values of m_statement_options. More...
 
bool is_broken () const
 
void mark_broken (bool broken=true)
 Certain permanent transformations (like in2exists), if they fail, may leave the LEX in an inconsistent state. More...
 
bool is_exec_started () const
 
void set_exec_started ()
 
void reset_exec_started ()
 
sp_pcontextget_sp_current_parsing_ctx ()
 
void set_sp_current_parsing_ctx (sp_pcontext *ctx)
 
bool is_metadata_used () const
 Check if the current statement uses meta-data (uses a table or a stored routine). More...
 
 LEX ()
 
virtual ~LEX ()
 
void reset ()
 Reset query context to initial state. More...
 
SELECT_LEXnew_empty_query_block ()
 Create an empty query block within this LEX object. More...
 
SELECT_LEXnew_query (SELECT_LEX *curr_select)
 Create query expression object that contains one query block. More...
 
SELECT_LEXnew_union_query (SELECT_LEX *curr_select, bool distinct, bool check_syntax=true)
 Create query block and attach it to the current query expression. More...
 
bool new_top_level_query ()
 Create top-level query expression and query block. More...
 
void new_static_query (SELECT_LEX_UNIT *sel_unit, SELECT_LEX *select)
 Create query expression and query block in existing memory objects. More...
 
bool is_ps_or_view_context_analysis ()
 
bool is_view_context_analysis ()
 
void set_uncacheable (SELECT_LEX *curr_select, uint8 cause)
 Set the current query as uncacheable. More...
 
void set_trg_event_type_for_tables ()
 Set the initial purpose of this TABLE_LIST object in the list of used tables. More...
 
TABLE_LISTunlink_first_table (bool *link_to_local)
 
void link_first_table_back (TABLE_LIST *first, bool link_to_local)
 
void first_lists_tables_same ()
 
bool can_use_merged ()
 check if command can use VIEW with MERGE algorithm (for top VIEWs) More...
 
bool can_not_use_merged ()
 Check if command can't use merged views in any part of command. More...
 
bool need_correct_ident ()
 
bool which_check_option_applicable ()
 
void cleanup_after_one_table_open ()
 
bool push_context (Name_resolution_context *context)
 
void pop_context ()
 
bool copy_db_to (char const **p_db, size_t *p_db_length) const
 This method should be called only during parsing. More...
 
bool copy_db_to (char **p_db, size_t *p_db_length) const
 
Name_resolution_contextcurrent_context ()
 
void reset_n_backup_query_tables_list (Query_tables_list *backup)
 
void restore_backup_query_tables_list (Query_tables_list *backup)
 
bool table_or_sp_used ()
 
bool is_single_level_stmt ()
 check if the statement is a single-level join More...
 
bool accept (Select_lex_visitor *visitor)
 
bool set_wild (LEX_STRING)
 
void clear_privileges ()
 
bool make_sql_cmd (Parse_tree_root *parse_tree)
 Uses parse_tree to instantiate an Sql_cmd object and assigns it to the Lex. More...
 
Secondary_engine_execution_contextsecondary_engine_execution_context () const
 Gets the secondary engine execution context for this statement. More...
 
void set_secondary_engine_execution_context (Secondary_engine_execution_context *context)
 Sets the secondary engine execution context for this statement. More...
 
- Public Member Functions inherited from Query_tables_list
Query_tables_listoperator= (Query_tables_list &&)=default
 
bool is_query_tables_locked () const
 
 Query_tables_list ()
 
 ~Query_tables_list ()
 
void reset_query_tables_list (bool init)
 
void destroy_query_tables_list ()
 
void set_query_tables_list (Query_tables_list *state)
 
void add_to_query_tables (TABLE_LIST *table)
 
bool requires_prelocking ()
 
void mark_as_requiring_prelocking (TABLE_LIST **tables_own_last)
 
TABLE_LISTfirst_not_own_table ()
 
void chop_off_not_own_tables ()
 
bool is_stmt_unsafe () const
 Determine if this statement is marked as unsafe. More...
 
bool is_stmt_unsafe (enum_binlog_stmt_unsafe unsafe)
 
void set_stmt_unsafe (enum_binlog_stmt_unsafe unsafe_type)
 Flag the current (top-level) statement as unsafe. More...
 
void set_stmt_unsafe_flags (uint32 flags)
 Set the bits of binlog_stmt_flags determining the type of unsafeness of the current statement. More...
 
uint32 get_stmt_unsafe_flags () const
 Return a binary combination of all unsafe warnings for the statement. More...
 
bool is_stmt_row_injection () const
 Determine if this statement is a row injection. More...
 
void set_stmt_row_injection ()
 Flag the statement as a row injection. More...
 
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. More...
 
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. More...
 
bool is_mixed_stmt_unsafe (bool in_multi_stmt_transaction_mode, bool binlog_direct, bool trx_cache_is_not_empty, uint tx_isolation)
 
bool uses_stored_routines () const
 true if the parsed tree contains references to stored procedures or functions, false otherwise More...
 
void set_using_match ()
 
bool get_using_match ()
 

Public Attributes

SELECT_LEX_UNITunit
 Outer-most query expression. More...
 
SELECT_LEXselect_lex
 First query block. More...
 
SELECT_LEXall_selects_list
 List of all query blocks. More...
 
LEX_STRING name
 
char * help_arg
 
char * to_log
 
char * x509_subject
 
char * x509_issuer
 
char * ssl_cipher
 
Stringwild
 
Query_resultresult
 
LEX_STRING binlog_stmt_arg
 Argument of the BINLOG event statement. More...
 
LEX_STRING ident
 
LEX_USERgrant_user
 
LEX_ALTER alter_password
 
LEX_GRANT_AS grant_as
 
THDthd
 
Value_generatorgcol_info
 
Opt_hints_globalopt_hints_global
 
Plugins_array plugins
 
TABLE_LISTinsert_table
 Table being inserted into (may be a view) More...
 
TABLE_LISTinsert_table_leaf
 Leaf table being inserted into (always a base table) More...
 
LEX_STRING create_view_select
 SELECT of CREATE VIEW statement. More...
 
partition_infopart_info
 
LEX_USERdefiner
 
List< LEX_USERusers_list
 
List< LEX_COLUMNcolumns
 
List< LEX_CSTRINGdynamic_privileges
 
List< LEX_USER > * default_roles
 
ulonglong bulk_insert_row_cnt
 
List< Itempurge_value_list
 
List< Itemkill_value_list
 
List< set_var_basevar_list
 
List< Item_func_set_user_varset_var_list
 
List< Item_paramparam_list
 List of placeholders ('?') for parameters of a prepared statement. More...
 
List< Name_resolution_contextcontext_stack
 
Item_sumin_sum_func
 
udf_func udf
 
HA_CHECK_OPT check_opt
 
HA_CREATE_INFOcreate_info
 
KEY_CREATE_INFO key_create_info
 
LEX_MASTER_INFO mi
 
LEX_SLAVE_CONNECTION slave_connection
 
Server_options server_options
 
USER_RESOURCES mqh
 
LEX_RESET_SLAVE reset_slave_info
 
ulong type
 
nesting_map allow_sum_func
 This field is used as a work field during resolving to validate the use of aggregate functions. More...
 
nesting_map m_deny_window_func
 Windowing functions are not allowed in HAVING - in contrast to group aggregates - then we need to be stricter than allow_sum_func. More...
 
Sql_cmdm_sql_cmd
 
bool expr_allows_subselect
 
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 original statement which had the WITH clause. More...
 
enum SSL_type ssl_type
 
enum enum_duplicates duplicates
 
enum enum_tx_isolation tx_isolation
 
enum enum_var_type option_type
 
enum_view_create_mode create_view_mode
 
my_thread_id show_profile_query_id
 QUERY ID for SHOW PROFILE. More...
 
uint profile_options
 
uint grant
 
uint grant_tot_col
 
bool grant_privilege
 
uint slave_thd_opt
 
uint start_transaction_opt
 
int select_number
 Number of query block (by EXPLAIN) More...
 
uint8 create_view_algorithm
 
uint8 create_view_check
 
uint8 context_analysis_only
 
bool drop_if_exists
 
bool drop_temporary
 
bool autocommit
 
bool verbose
 
bool no_write_to_binlog
 
bool m_extended_show
 
enum enum_yes_no_unknown tx_chain tx_release
 
bool safe_to_cache_query
 Whether this query will return the same answer every time, given unchanged data. More...
 
bool subqueries
 
st_parsing_options parsing_options
 
Alter_infoalter_info
 
LEX_CSTRING prepared_stmt_name
 
LEX_STRING prepared_stmt_code
 
bool prepared_stmt_code_is_varref
 
List< LEX_STRINGprepared_stmt_params
 
sp_headsphead
 
sp_namespname
 
bool sp_lex_in_use
 
bool all_privileges
 
bool contains_plaintext_password
 
enum_keep_diagnostics keep_diagnostics
 
uint32 next_binlog_file_nr
 
st_sp_chistics sp_chistics
 
Event_parse_dataevent_parse_data
 
bool only_view
 
uint8 create_view_suid
 
const char * stmt_definition_begin
 Intended to point to the next word after DEFINER-clause in the following statements: More...
 
const char * stmt_definition_end
 
bool use_only_table_context
 During name resolution search only in the table list given by Name_resolution_context::first_name_resolution_table and Name_resolution_context::last_name_resolution_table (see Item_field::fix_fields()). More...
 
bool is_lex_started
 
bool in_update_value_clause
 Set to true while resolving values in ON DUPLICATE KEY UPDATE clause. More...
 
class Explain_formatexplain_format
 
ulong max_execution_time
 
bool binlog_need_explicit_defaults_ts
 
bool will_contextualize
 Used to inform the parser whether it should contextualize the parse tree. More...
 
dd::info_schema::Table_statistics m_IS_table_stats
 IS schema queries read some dynamic table statistics from SE. More...
 
dd::info_schema::Tablespace_statistics m_IS_tablespace_stats
 
- Public Attributes inherited from Query_tables_list
enum_sql_command sql_command
 SQL command for this statement. More...
 
TABLE_LISTquery_tables
 
TABLE_LIST ** query_tables_last
 
TABLE_LIST ** query_tables_own_last
 
std::unique_ptr< malloc_unordered_map< std::string, Sroutine_hash_entry * > > sroutines
 
SQL_I_List< Sroutine_hash_entrysroutines_list
 
Sroutine_hash_entry ** sroutines_list_own_last
 
uint sroutines_list_own_elements
 
enum_lock_tables_state lock_tables_state
 
uint table_count
 Number of tables which were open by open_tables() and to be locked by lock_tables(). More...
 

Private Attributes

SELECT_LEXm_current_select
 
std::map< Field *, Field * > * insert_update_values_map
 
bool ignore
 
bool m_broken
 see mark_broken() More...
 
bool m_exec_started
 Set to true when execution has started (after parsing, tables opened and query preparation is complete. More...
 
sp_pcontextsp_current_parsing_ctx
 Current SP parsing context. More...
 
ulonglong m_statement_options {0}
 Statement context for SELECT_LEX::make_active_options. More...
 
Secondary_engine_execution_contextm_secondary_engine_context {nullptr}
 Context object used by secondary storage engines to store query state during optimization and execution. More...
 

Friends

bool lex_start (THD *thd)
 Call lex_start() before every query that is to be prepared and executed. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Query_tables_list
static const char * stmt_accessed_table_string (enum_stmt_accessed_table accessed_table)
 
- Static Public Attributes inherited from Query_tables_list
static const int BINLOG_STMT_UNSAFE_ALL_FLAGS
 This has all flags from 0 (inclusive) to BINLOG_STMT_FLAG_COUNT (exclusive) set. More...
 
static const int binlog_stmt_unsafe_errcode [BINLOG_STMT_UNSAFE_COUNT]
 Maps elements of enum_binlog_stmt_unsafe to error codes. More...
 

Member Typedef Documentation

◆ Plugins_array

Constructor & Destructor Documentation

◆ LEX()

LEX::LEX ( )

◆ ~LEX()

LEX::~LEX ( )
virtual

Member Function Documentation

◆ accept()

bool LEX::accept ( Select_lex_visitor visitor)

◆ add_statement_options()

void LEX::add_statement_options ( ulonglong  options)
inline

Add options to values of m_statement_options.

options is an ORed bit set of options defined in query_options.h

Parameters
optionsAdd this set of options to the set already in m_statement_options

◆ assert_ok_set_current_select()

void LEX::assert_ok_set_current_select ( )

◆ begin_values_map()

std::map<Field *, Field *>::iterator LEX::begin_values_map ( )
inline

◆ can_not_use_merged()

bool LEX::can_not_use_merged ( )

Check if command can't use merged views in any part of command.

Temporary table algorithm will be used on all SELECT levels for queries listed here (see also LEX::can_use_merged()).

Returns
true if command cannot use merged view, false otherwise

◆ can_use_merged()

bool LEX::can_use_merged ( )

check if command can use VIEW with MERGE algorithm (for top VIEWs)

Only listed here commands can use merge algorithm in top level SELECT_LEX (for subqueries will be used merge algorithm if LEX::can_not_use_merged() is not true).

Returns
true if command can use merged VIEWs, false otherwise

◆ cleanup_after_one_table_open()

void LEX::cleanup_after_one_table_open ( )

◆ clear_privileges()

void LEX::clear_privileges ( )

◆ clear_values_map()

void LEX::clear_values_map ( )
inline

◆ copy_db_to() [1/2]

bool LEX::copy_db_to ( char const **  p_db,
size_t *  p_db_length 
) const

This method should be called only during parsing.

It is aware of compound statements (stored routine bodies) and will initialize the destination with the default database of the stored routine, rather than the default database of the connection it is parsed in. E.g. if one has no current database selected, or current database set to 'bar' and then issues:

CREATE PROCEDURE foo.p1() BEGIN SELECT * FROM t1 END//

t1 is meant to refer to foo.t1, not to bar.t1.

This method is needed to support this rule.

Returns
true in case of error (parsing should be aborted, false in case of success

◆ copy_db_to() [2/2]

bool LEX::copy_db_to ( char **  p_db,
size_t *  p_db_length 
) const
inline

◆ current_context()

Name_resolution_context* LEX::current_context ( )
inline

◆ current_select()

SELECT_LEX* LEX::current_select ( ) const
inline

◆ end_values_map()

std::map<Field *, Field *>::iterator LEX::end_values_map ( )
inline

◆ first_lists_tables_same()

void LEX::first_lists_tables_same ( )

◆ get_sp_current_parsing_ctx()

sp_pcontext* LEX::get_sp_current_parsing_ctx ( )
inline

◆ has_values_map()

bool LEX::has_values_map ( ) const
inline

◆ insert_values_map()

void LEX::insert_values_map ( Field f1,
Field f2 
)
inline

◆ is_broken()

bool LEX::is_broken ( ) const
inline

◆ is_exec_started()

bool LEX::is_exec_started ( ) const
inline

◆ is_explain()

bool LEX::is_explain ( ) const
inline
Returns
true if this is an EXPLAIN statement

◆ is_ignore()

bool LEX::is_ignore ( ) const
inline

◆ is_metadata_used()

bool LEX::is_metadata_used ( ) const
inline

Check if the current statement uses meta-data (uses a table or a stored routine).

◆ is_ps_or_view_context_analysis()

bool LEX::is_ps_or_view_context_analysis ( )
inline

◆ is_single_level_stmt()

bool LEX::is_single_level_stmt ( )
inline

check if the statement is a single-level join

Returns
result of the check
Return values
trueThe statement doesn't contain subqueries, unions and stored procedure calls.
falseThere are subqueries, UNIONs or stored procedure calls.

◆ is_view_context_analysis()

bool LEX::is_view_context_analysis ( )
inline

◆ link_first_table_back()

void LEX::link_first_table_back ( TABLE_LIST first,
bool  link_to_local 
)

◆ locate_var_assignment()

bool LEX::locate_var_assignment ( const Name_string name)

Locate an assignment to a user variable with a given name, within statement.

Parameters
nameName of variable to search for
Returns
true if variable is assigned to, false otherwise.

◆ make_sql_cmd()

bool LEX::make_sql_cmd ( Parse_tree_root parse_tree)

Uses parse_tree to instantiate an Sql_cmd object and assigns it to the Lex.

Parameters
parse_treeThe parse tree.
Returns
false on success, true on error.

◆ mark_broken()

void LEX::mark_broken ( bool  broken = true)
inline

Certain permanent transformations (like in2exists), if they fail, may leave the LEX in an inconsistent state.

They should call the following function, so that this LEX is not reused by another execution.

◆ need_correct_ident()

bool LEX::need_correct_ident ( )

◆ new_empty_query_block()

SELECT_LEX * LEX::new_empty_query_block ( )

Create an empty query block within this LEX object.

◆ new_query()

SELECT_LEX * LEX::new_query ( SELECT_LEX curr_select)

Create query expression object that contains one query block.

Create new select_lex_unit and select_lex objects for a query block, which can be either a top-level query or a subquery.

For the second and subsequent query block of a UNION query, use LEX::new_union_query() instead. Set the new select_lex as the current select_lex of the LEX object.

Parameters
curr_selectcurrent query specification
Returns
new query specification if successful, NULL if error

◆ new_static_query()

void LEX::new_static_query ( SELECT_LEX_UNIT sel_unit,
SELECT_LEX select 
)

Create query expression and query block in existing memory objects.

Initialize a LEX object, a query expression object (select_lex_unit) and a query block object (select_lex).

All objects are passed as pointers so they can be stack-allocated. The purpose of this structure is for short-lived procedures that need a LEX and a query block object.

Do not extend the struct with more query objects after creation.

The struct can be abandoned after use, no cleanup is needed.

Parameters
sel_unitPointer to the query expression object
selectPointer to the query block object

◆ new_top_level_query()

bool LEX::new_top_level_query ( )

Create top-level query expression and query block.

Given a LEX object, create a query expression object (select_lex_unit) and a query block object (select_lex).

Returns
false if successful, true if error

◆ new_union_query()

SELECT_LEX * LEX::new_union_query ( SELECT_LEX curr_select,
bool  distinct,
bool  check_syntax = true 
)

Create query block and attach it to the current query expression.

Create new select_lex object for all branches of a UNION except the left-most one.

Set the new select_lex as the current select_lex of the LEX object.

Parameters
curr_selectcurrent query specification
distinctTrue if part of UNION DISTINCT query
check_syntaxThis function is called from both new and legacy code. New code uses the actual parse tree for checking syntax before creating SELECT_LEX'es (good), while legacy code checks the SELECT_LEX structures later on to see what syntax they seem to be generated from (bad). When all parser rules have been converted, this parameter will always be false, and can be removed.
Returns
new query specification if successful, NULL if an error occurred.

◆ pop_context()

void LEX::pop_context ( )
inline

◆ push_context()

bool LEX::push_context ( Name_resolution_context context)
inline

◆ reset()

void LEX::reset ( void  )

Reset query context to initial state.

Reset a LEX object so that it is ready for a new query preparation and execution.

Pointers to query expression and query block objects are set to NULL. This is correct, as they point into a mem_root that has been recycled.

◆ reset_exec_started()

void LEX::reset_exec_started ( )
inline

◆ reset_n_backup_query_tables_list()

void LEX::reset_n_backup_query_tables_list ( Query_tables_list backup)

◆ restore_backup_query_tables_list()

void LEX::restore_backup_query_tables_list ( Query_tables_list backup)

◆ secondary_engine_execution_context()

Secondary_engine_execution_context* LEX::secondary_engine_execution_context ( ) const
inline

Gets the secondary engine execution context for this statement.

◆ set_current_select()

void LEX::set_current_select ( SELECT_LEX select)
inline

◆ set_exec_started()

void LEX::set_exec_started ( )
inline

◆ set_ignore()

void LEX::set_ignore ( bool  ignore_param)
inline

◆ set_secondary_engine_execution_context()

void LEX::set_secondary_engine_execution_context ( Secondary_engine_execution_context context)

Sets the secondary engine execution context for this statement.

The old context object is destroyed, if there is one. Can be set to nullptr to destroy the old context object and clear the pointer.

The supplied context object should be allocated on the execution MEM_ROOT, so that its memory doesn't have to be manually freed after query execution.

◆ set_sp_current_parsing_ctx()

void LEX::set_sp_current_parsing_ctx ( sp_pcontext ctx)
inline

◆ set_trg_event_type_for_tables()

void LEX::set_trg_event_type_for_tables ( )

Set the initial purpose of this TABLE_LIST object in the list of used tables.

We need to track this information on table-by-table basis, since when this table becomes an element of the pre-locked list, it's impossible to identify which SQL sub-statement it has been originally used in.

E.g.:

User request: SELECT * FROM t1 WHERE f1(); FUNCTION f1(): DELETE FROM t2; RETURN 1; BEFORE DELETE trigger on t2: INSERT INTO t3 VALUES (old.a);

For this user request, the pre-locked list will contain t1, t2, t3 table elements, each needed for different DML.

The trigger event map is updated to reflect INSERT, UPDATE, DELETE, REPLACE, LOAD DATA, CREATE TABLE .. SELECT, CREATE TABLE .. REPLACE SELECT statements, and additionally ON DUPLICATE KEY UPDATE clause.

◆ set_uncacheable()

void LEX::set_uncacheable ( SELECT_LEX curr_select,
uint8  cause 
)
inline

Set the current query as uncacheable.

Parameters
curr_selectCurrent select query block
causeWhy this query is uncacheable.

All query blocks representing subqueries, from the current one up to the outer-most one, but excluding the main query block, are also set as uncacheable.

◆ set_wild()

bool LEX::set_wild ( LEX_STRING  w)

◆ statement_options()

ulonglong LEX::statement_options ( )
inline
Returns
a bit set of options set for this statement

◆ table_or_sp_used()

bool LEX::table_or_sp_used ( )

◆ unlink_first_table()

TABLE_LIST * LEX::unlink_first_table ( bool link_to_local)

◆ which_check_option_applicable()

bool LEX::which_check_option_applicable ( )
inline

Friends And Related Function Documentation

◆ lex_start

bool lex_start ( THD thd)
friend

Call lex_start() before every query that is to be prepared and executed.

Because of this, it's critical not to do too many things here. (We already do too much)

The function creates a select_lex and a select_lex_unit object. These objects should rather be created by the parser bottom-up.

Member Data Documentation

◆ all_privileges

bool LEX::all_privileges

◆ all_selects_list

SELECT_LEX* LEX::all_selects_list

List of all query blocks.

◆ allow_sum_func

nesting_map LEX::allow_sum_func

This field is used as a work field during resolving to validate the use of aggregate functions.

For example in a query SELECT ... FROM ...WHERE MIN(i) == 1 GROUP BY ... HAVING MIN(i) > 2 MIN(i) in the WHERE clause is not allowed since only non-aggregated data is present, whereas MIN(i) in the HAVING clause is allowed because HAVING operates on the output of a grouping operation. Each query block is assigned a nesting level. This field is a bit field that contains the value one in the position of that nesting level if aggregate functions are allowed for that query block.

◆ alter_info

Alter_info* LEX::alter_info

◆ alter_password

LEX_ALTER LEX::alter_password

◆ autocommit

bool LEX::autocommit

◆ binlog_need_explicit_defaults_ts

bool LEX::binlog_need_explicit_defaults_ts

◆ binlog_stmt_arg

LEX_STRING LEX::binlog_stmt_arg

Argument of the BINLOG event statement.

◆ bulk_insert_row_cnt

ulonglong LEX::bulk_insert_row_cnt

◆ check_opt

HA_CHECK_OPT LEX::check_opt

◆ columns

List<LEX_COLUMN> LEX::columns

◆ contains_plaintext_password

bool LEX::contains_plaintext_password

◆ context_analysis_only

uint8 LEX::context_analysis_only

◆ context_stack

List<Name_resolution_context> LEX::context_stack

◆ create_info

HA_CREATE_INFO* LEX::create_info

◆ create_view_algorithm

uint8 LEX::create_view_algorithm

◆ create_view_check

uint8 LEX::create_view_check

◆ create_view_mode

enum_view_create_mode LEX::create_view_mode

◆ create_view_select

LEX_STRING LEX::create_view_select

SELECT of CREATE VIEW statement.

◆ create_view_suid

uint8 LEX::create_view_suid

◆ default_roles

List<LEX_USER>* LEX::default_roles

◆ definer

LEX_USER* LEX::definer

◆ drop_if_exists

bool LEX::drop_if_exists

◆ drop_temporary

bool LEX::drop_temporary

◆ duplicates

enum enum_duplicates LEX::duplicates

◆ dynamic_privileges

List<LEX_CSTRING> LEX::dynamic_privileges

◆ event_parse_data

Event_parse_data* LEX::event_parse_data

◆ explain_format

class Explain_format* LEX::explain_format

◆ expr_allows_subselect

bool LEX::expr_allows_subselect

◆ gcol_info

Value_generator* LEX::gcol_info

◆ grant

uint LEX::grant

◆ grant_as

LEX_GRANT_AS LEX::grant_as

◆ grant_privilege

bool LEX::grant_privilege

◆ grant_tot_col

uint LEX::grant_tot_col

◆ grant_user

LEX_USER* LEX::grant_user

◆ help_arg

char* LEX::help_arg

◆ ident

LEX_STRING LEX::ident

◆ ignore

bool LEX::ignore
private

◆ in_sum_func

Item_sum* LEX::in_sum_func

◆ in_update_value_clause

bool LEX::in_update_value_clause

Set to true while resolving values in ON DUPLICATE KEY UPDATE clause.

◆ insert_table

TABLE_LIST* LEX::insert_table

Table being inserted into (may be a view)

◆ insert_table_leaf

TABLE_LIST* LEX::insert_table_leaf

Leaf table being inserted into (always a base table)

◆ insert_update_values_map

std::map<Field *, Field *>* LEX::insert_update_values_map
private

◆ is_lex_started

bool LEX::is_lex_started

◆ keep_diagnostics

enum_keep_diagnostics LEX::keep_diagnostics

◆ key_create_info

KEY_CREATE_INFO LEX::key_create_info

◆ kill_value_list

List<Item> LEX::kill_value_list

◆ m_broken

bool LEX::m_broken
private

see mark_broken()

◆ m_current_select

SELECT_LEX* LEX::m_current_select
private

◆ m_deny_window_func

nesting_map LEX::m_deny_window_func

Windowing functions are not allowed in HAVING - in contrast to group aggregates - then we need to be stricter than allow_sum_func.

One bit per query block, as allow_sum_func.

◆ m_exec_started

bool LEX::m_exec_started
private

Set to true when execution has started (after parsing, tables opened and query preparation is complete.

Used to track arena state for SPs).

◆ m_extended_show

bool LEX::m_extended_show

◆ m_IS_table_stats

dd::info_schema::Table_statistics LEX::m_IS_table_stats

IS schema queries read some dynamic table statistics from SE.

These statistics are cached, to avoid opening of table more than once while preparing a single output record buffer.

◆ m_IS_tablespace_stats

dd::info_schema::Tablespace_statistics LEX::m_IS_tablespace_stats

◆ m_secondary_engine_context

Secondary_engine_execution_context* LEX::m_secondary_engine_context {nullptr}
private

Context object used by secondary storage engines to store query state during optimization and execution.

◆ m_sql_cmd

Sql_cmd* LEX::m_sql_cmd

◆ m_statement_options

ulonglong LEX::m_statement_options {0}
private

Statement context for SELECT_LEX::make_active_options.

◆ max_execution_time

ulong LEX::max_execution_time

◆ mi

LEX_MASTER_INFO LEX::mi

◆ mqh

USER_RESOURCES LEX::mqh

◆ name

LEX_STRING LEX::name

◆ next_binlog_file_nr

uint32 LEX::next_binlog_file_nr

◆ no_write_to_binlog

bool LEX::no_write_to_binlog

◆ only_view

bool LEX::only_view

◆ opt_hints_global

Opt_hints_global* LEX::opt_hints_global

◆ option_type

enum enum_var_type LEX::option_type

◆ param_list

List<Item_param> LEX::param_list

List of placeholders ('?') for parameters of a prepared statement.

Because we append to this list during parsing, it is naturally sorted by position of the '?' in the query string. The code which fills placeholders with user-supplied values, and the code which writes a query for statement-based logging, rely on this order. This list contains only real placeholders, not the clones which originate in a re-parsed CTE definition.

◆ parsing_options

st_parsing_options LEX::parsing_options

◆ part_info

partition_info* LEX::part_info

◆ plugins

Plugins_array LEX::plugins

◆ prepared_stmt_code

LEX_STRING LEX::prepared_stmt_code

◆ prepared_stmt_code_is_varref

bool LEX::prepared_stmt_code_is_varref

◆ prepared_stmt_name

LEX_CSTRING LEX::prepared_stmt_name

◆ prepared_stmt_params

List<LEX_STRING> LEX::prepared_stmt_params

◆ profile_options

uint LEX::profile_options

◆ purge_value_list

List<Item> LEX::purge_value_list

◆ reparse_common_table_expr_at

uint LEX::reparse_common_table_expr_at

If currently re-parsing a CTE's definition, this is the offset in bytes of that definition in the original statement which had the WITH clause.

Otherwise this is 0.

◆ reset_slave_info

LEX_RESET_SLAVE LEX::reset_slave_info

◆ result

Query_result* LEX::result

◆ safe_to_cache_query

bool LEX::safe_to_cache_query

Whether this query will return the same answer every time, given unchanged data.

Used to be for the query cache, but is now used to find out if an expression is usable for partitioning.

◆ select_lex

SELECT_LEX* LEX::select_lex

First query block.

◆ select_number

int LEX::select_number

Number of query block (by EXPLAIN)

◆ server_options

Server_options LEX::server_options

◆ set_var_list

List<Item_func_set_user_var> LEX::set_var_list

◆ show_profile_query_id

my_thread_id LEX::show_profile_query_id

QUERY ID for SHOW PROFILE.

◆ slave_connection

LEX_SLAVE_CONNECTION LEX::slave_connection

◆ slave_thd_opt

uint LEX::slave_thd_opt

◆ sp_chistics

st_sp_chistics LEX::sp_chistics

◆ sp_current_parsing_ctx

sp_pcontext* LEX::sp_current_parsing_ctx
private

Current SP parsing context.

See also
also sp_head::m_root_parsing_ctx.

◆ sp_lex_in_use

bool LEX::sp_lex_in_use

◆ sphead

sp_head* LEX::sphead

◆ spname

sp_name* LEX::spname

◆ ssl_cipher

char * LEX::ssl_cipher

◆ ssl_type

enum SSL_type LEX::ssl_type

◆ start_transaction_opt

uint LEX::start_transaction_opt

◆ stmt_definition_begin

const char* LEX::stmt_definition_begin

Intended to point to the next word after DEFINER-clause in the following statements:

  • CREATE TRIGGER (points to "TRIGGER");
  • CREATE PROCEDURE (points to "PROCEDURE");
  • CREATE FUNCTION (points to "FUNCTION" or "AGGREGATE");
  • CREATE EVENT (points to "EVENT")

This pointer is required to add possibly omitted DEFINER-clause to the DDL-statement before dumping it to the binlog.

◆ stmt_definition_end

const char* LEX::stmt_definition_end

◆ subqueries

bool LEX::subqueries

◆ thd

THD* LEX::thd

◆ to_log

char* LEX::to_log

◆ tx_isolation

enum enum_tx_isolation LEX::tx_isolation

◆ tx_release

enum enum_yes_no_unknown tx_chain LEX::tx_release

◆ type

ulong LEX::type

◆ udf

udf_func LEX::udf

◆ unit

SELECT_LEX_UNIT* LEX::unit

Outer-most query expression.

◆ use_only_table_context

bool LEX::use_only_table_context

During name resolution search only in the table list given by Name_resolution_context::first_name_resolution_table and Name_resolution_context::last_name_resolution_table (see Item_field::fix_fields()).

◆ users_list

List<LEX_USER> LEX::users_list

◆ var_list

List<set_var_base> LEX::var_list

◆ verbose

bool LEX::verbose

◆ wild

String* LEX::wild

◆ will_contextualize

bool LEX::will_contextualize

Used to inform the parser whether it should contextualize the parse tree.

When we get a pure parser this will not be needed.

◆ x509_issuer

char * LEX::x509_issuer

◆ x509_subject

char* LEX::x509_subject

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