MySQL 8.0.30
Source Code Documentation
parse_tree_nodes.cc File Reference
#include "sql/parse_tree_nodes.h"
#include <algorithm>
#include <cstring>
#include <limits>
#include <utility>
#include <vector>
#include "field_types.h"
#include "m_ctype.h"
#include "m_string.h"
#include "mem_root_deque.h"
#include "my_alloc.h"
#include "my_dbug.h"
#include "mysql/mysql_lex_string.h"
#include "mysql/udf_registration_types.h"
#include "mysql_com.h"
#include "scope_guard.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/create_field.h"
#include "sql/dd/info_schema/show.h"
#include "sql/dd/types/abstract_table.h"
#include "sql/dd/types/column.h"
#include "sql/derror.h"
#include "sql/field.h"
#include "sql/gis/srid.h"
#include "sql/intrusive_list_iterator.h"
#include "sql/item.h"
#include "sql/item_cmpfunc.h"
#include "sql/item_func.h"
#include "sql/item_timefunc.h"
#include "sql/key_spec.h"
#include "sql/mdl.h"
#include "sql/mysqld.h"
#include "sql/opt_explain_json.h"
#include "sql/opt_explain_traditional.h"
#include "sql/parse_location.h"
#include "sql/parse_tree_column_attrs.h"
#include "sql/parse_tree_hints.h"
#include "sql/parse_tree_partitions.h"
#include "sql/parse_tree_window.h"
#include "sql/parser_yystype.h"
#include "sql/query_options.h"
#include "sql/query_result.h"
#include "sql/sp.h"
#include "sql/sp_head.h"
#include "sql/sp_instr.h"
#include "sql/sp_pcontext.h"
#include "sql/sql_base.h"
#include "sql/sql_call.h"
#include "sql/sql_class.h"
#include "sql/sql_cmd.h"
#include "sql/sql_cmd_ddl_table.h"
#include "sql/sql_const.h"
#include "sql/sql_data_change.h"
#include "sql/sql_delete.h"
#include "sql/sql_do.h"
#include "sql/sql_error.h"
#include "sql/sql_insert.h"
#include "sql/sql_parse.h"
#include "sql/sql_select.h"
#include "sql/sql_show.h"
#include "sql/sql_show_processlist.h"
#include "sql/sql_show_status.h"
#include "sql/sql_update.h"
#include "sql/system_variables.h"
#include "sql/table_function.h"
#include "sql/thr_malloc.h"
#include "sql/trigger_def.h"
#include "sql/window.h"
#include "sql_string.h"
#include "template_utils.h"

Classes

class  PT_attribute< ATTRIBUTE, BASE >
 Generic attribute node that can be used with different base types and corresponding parse contexts. More...
 

Namespaces

namespace  anonymous_namespace{parse_tree_nodes.cc}
 

Typedefs

using Local_tables_iterator = IntrusiveListIterator< TABLE_LIST, &TABLE_LIST::next_local >
 
using Local_tables_list = IteratorContainer< Local_tables_iterator >
 A list interface over the TABLE_LIST::next_local pointer. More...
 

Functions

template<typename Context , typename Node >
bool anonymous_namespace{parse_tree_nodes.cc}::contextualize_safe (Context *pc, Node node)
 
template<typename Context >
bool anonymous_namespace{parse_tree_nodes.cc}::contextualize_safe (Context *pc, mem_root_deque< Item * > *list)
 
template<typename Context , typename Node , typename... Nodes>
bool anonymous_namespace{parse_tree_nodes.cc}::contextualize_safe (Context *pc, Node node, Nodes... nodes)
 Convenience function that calls Parse_tree_node::contextualize() on each of the nodes that are non-NULL, stopping when a call returns true. More...
 
bool anonymous_namespace{parse_tree_nodes.cc}::itemize_safe (Parse_context *pc, Item **item)
 Convenience function that calls Item::itemize() on the item if it's non-NULL. More...
 
static bool is_transition_variable_prefix (const Parse_context &pc, const LEX_CSTRING &opt_prefix, const char *prefix)
 Recognize the transition variable syntax: { OLD | NEW } "." ... More...
 
static bool is_old_transition_variable_prefix (const Parse_context &pc, const LEX_CSTRING &opt_prefix)
 
static bool is_new_transition_variable_prefix (const Parse_context &pc, const LEX_CSTRING &opt_prefix)
 
static bool is_any_transition_variable_prefix (const Parse_context &pc, const LEX_CSTRING &opt_prefix)
 Recognize any of transition variable syntax: { NEW | OLD } "." ... More...
 
static sp_variablefind_sp_variable (const Parse_context &pc, const LEX_CSTRING &name)
 Try to resolve a name as SP formal parameter or local variable. More...
 
static bool set_trigger_new_row (Parse_context *pc, LEX_CSTRING trigger_field_name, Item *expr_item, const POS &expr_pos)
 Helper action for a SET statement. More...
 
static bool add_system_variable_assignment (THD *thd, LEX_CSTRING prefix, LEX_CSTRING suffix, enum enum_var_type var_type, Item *val)
 Helper action for a SET statement. More...
 
static TABLE_LISTmulti_delete_table_match (TABLE_LIST *tbl, TABLE_LIST *tables)
 
static bool multi_delete_link_tables (Parse_context *pc, SQL_I_List< TABLE_LIST > *delete_tables)
 Link tables in auxiliary table list of multi-delete with corresponding elements in main table list, and set proper locks for them. More...
 
static bool setup_index (keytype key_type, const LEX_STRING name, PT_base_index_option *type, List< PT_key_part_specification > *columns, Index_options options, Table_ddl_parse_context *pc)
 
bool set_default_charset (HA_CREATE_INFO *create_info, const CHARSET_INFO *value)
 
bool set_default_collation (HA_CREATE_INFO *create_info, const CHARSET_INFO *collation)
 
static void setup_lex_show_cmd_type (THD *thd, Show_cmd_type show_cmd_type)
 
static bool init_alter_table_stmt (Table_ddl_parse_context *pc, Table_ident *table_name, Alter_info::enum_alter_table_algorithm algo, Alter_info::enum_alter_table_lock lock, Alter_info::enum_with_validation validation)
 A common initialization part of ALTER TABLE statement variants. More...
 
static bool check_unsupported_json_table_default (const Item *item)
 
PT_alter_tablespace_option_basemake_tablespace_engine_attribute (MEM_ROOT *mem_root, LEX_CSTRING attr)
 Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer. More...
 
PT_create_table_optionmake_table_engine_attribute (MEM_ROOT *mem_root, LEX_CSTRING attr)
 Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer. More...
 
PT_create_table_optionmake_table_secondary_engine_attribute (MEM_ROOT *mem_root, LEX_CSTRING attr)
 Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer. More...
 
PT_column_attr_basemake_column_engine_attribute (MEM_ROOT *mem_root, LEX_CSTRING attr)
 Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer. More...
 
PT_column_attr_basemake_column_secondary_engine_attribute (MEM_ROOT *mem_root, LEX_CSTRING attr)
 Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer. More...
 
PT_base_index_optionmake_index_engine_attribute (MEM_ROOT *mem_root, LEX_CSTRING attr)
 Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer. More...
 
PT_base_index_optionmake_index_secondary_engine_attribute (MEM_ROOT *mem_root, LEX_CSTRING attr)
 Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer. More...
 

Variables

static constexpr const size_t MAX_SYS_VAR_LENGTH {32}
 

Typedef Documentation

◆ Local_tables_iterator

◆ Local_tables_list

A list interface over the TABLE_LIST::next_local pointer.

Function Documentation

◆ add_system_variable_assignment()

static bool add_system_variable_assignment ( THD thd,
LEX_CSTRING  prefix,
LEX_CSTRING  suffix,
enum enum_var_type  var_type,
Item val 
)
static

Helper action for a SET statement.

Used to push a system variable into the assignment list. In stored routines detects "SET AUTOCOMMIT" and reject "SET GTID..." stuff.

Parameters
thdthe current thread
prefixleft hand side of a qualified name (if any) or nullptr string
suffixthe right hand side of a qualified name (if any) or a whole unqualified name
var_typethe scope of the variable
valthe value being assigned to the variable
Returns
true if error, false otherwise.

◆ check_unsupported_json_table_default()

static bool check_unsupported_json_table_default ( const Item item)
static

◆ find_sp_variable()

static sp_variable * find_sp_variable ( const Parse_context pc,
const LEX_CSTRING name 
)
static

Try to resolve a name as SP formal parameter or local variable.

Note
Doesn't output error messages on failure.
Parameters
pcParse context
nameName of probable SP variable
Returns
pointer to SP formal parameter/local variable object on success, otherwise nullptr

◆ init_alter_table_stmt()

static bool init_alter_table_stmt ( Table_ddl_parse_context pc,
Table_ident table_name,
Alter_info::enum_alter_table_algorithm  algo,
Alter_info::enum_alter_table_lock  lock,
Alter_info::enum_with_validation  validation 
)
static

A common initialization part of ALTER TABLE statement variants.

Parameters
pcThe parse context.
table_nameThe name of a table to alter.
algoThe ALGORITHM clause: inplace, copy etc.
lockThe LOCK clause: none, shared, exclusive etc.
validationThe WITH or WITHOUT VALIDATION clause.
Returns
false on success, true on error.

◆ is_any_transition_variable_prefix()

static bool is_any_transition_variable_prefix ( const Parse_context pc,
const LEX_CSTRING opt_prefix 
)
static

Recognize any of transition variable syntax: { NEW | OLD } "." ...

Parameters
pcParse context
opt_prefixOptional prefix or empty LEX_CSTRING
Returns
true if the transition variable syntax, otherwise false

◆ is_new_transition_variable_prefix()

static bool is_new_transition_variable_prefix ( const Parse_context pc,
const LEX_CSTRING opt_prefix 
)
static

◆ is_old_transition_variable_prefix()

static bool is_old_transition_variable_prefix ( const Parse_context pc,
const LEX_CSTRING opt_prefix 
)
static

◆ is_transition_variable_prefix()

static bool is_transition_variable_prefix ( const Parse_context pc,
const LEX_CSTRING opt_prefix,
const char *  prefix 
)
static

Recognize the transition variable syntax: { OLD | NEW } "." ...

Parameters
pcParse context
opt_prefixOptional prefix to examine or empty LEX_CSTRING
prefix"OLD" or "NEW" to compare with
Returns
true if the OLD transition variable syntax, otherwise false

◆ make_column_engine_attribute()

PT_column_attr_base * make_column_engine_attribute ( MEM_ROOT mem_root,
LEX_CSTRING  attr 
)

Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer.

Parameters
mem_rootMemory arena.
attrAttribute value from parser.
Returns
PT_create_table_option* to PT_attribute object.

◆ make_column_secondary_engine_attribute()

PT_column_attr_base * make_column_secondary_engine_attribute ( MEM_ROOT mem_root,
LEX_CSTRING  attr 
)

Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer.

Parameters
mem_rootMemory arena.
attrAttribute value from parser.
Returns
PT_column_attr_base* to PT_attribute object.

◆ make_index_engine_attribute()

PT_base_index_option * make_index_engine_attribute ( MEM_ROOT mem_root,
LEX_CSTRING  attr 
)

Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer.

Parameters
mem_rootMemory arena.
attrAttribute value from parser.
Returns
PT_base_index_option* to PT_attribute object.

◆ make_index_secondary_engine_attribute()

PT_base_index_option * make_index_secondary_engine_attribute ( MEM_ROOT mem_root,
LEX_CSTRING  attr 
)

Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer.

Parameters
mem_rootMemory arena.
attrAttribute value from parser.
Returns
PT_base_index_option* to PT_attribute object.

◆ make_table_engine_attribute()

PT_create_table_option * make_table_engine_attribute ( MEM_ROOT mem_root,
LEX_CSTRING  attr 
)

Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer.

Parameters
mem_rootMemory arena.
attrAttribute value from parser.
Returns
PT_alter_tablespace_option_base* to PT_attribute object.

◆ make_table_secondary_engine_attribute()

PT_create_table_option * make_table_secondary_engine_attribute ( MEM_ROOT mem_root,
LEX_CSTRING  attr 
)

Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer.

Parameters
mem_rootMemory arena.
attrAttribute value from parser.
Returns
PT_create_table_option* to PT_attribute object.

◆ make_tablespace_engine_attribute()

PT_alter_tablespace_option_base * make_tablespace_engine_attribute ( MEM_ROOT mem_root,
LEX_CSTRING  attr 
)

Factory function which instantiates PT_attribute with suitable parameters, allocates on the provided mem_root, and returns the appropriate base pointer.

Parameters
mem_rootMemory arena.
attrAttribute value from parser.
Returns
PT_alter_tablespace_option_base* to PT_attribute object.

◆ multi_delete_link_tables()

static bool multi_delete_link_tables ( Parse_context pc,
SQL_I_List< TABLE_LIST > *  delete_tables 
)
static

Link tables in auxiliary table list of multi-delete with corresponding elements in main table list, and set proper locks for them.

Parameters
pcParse context
delete_tablesList of tables to delete from
Returns
false if success, true if error

◆ multi_delete_table_match()

static TABLE_LIST * multi_delete_table_match ( TABLE_LIST tbl,
TABLE_LIST tables 
)
static

◆ set_trigger_new_row()

static bool set_trigger_new_row ( Parse_context pc,
LEX_CSTRING  trigger_field_name,
Item expr_item,
const POS expr_pos 
)
static

Helper action for a SET statement.

Used to SET a field of NEW row.

Parameters
pcthe parse context
trigger_field_namethe NEW-row field name
expr_itemthe value expression to be assigned
expr_posthe value expression query
Returns
error status (true if error, false otherwise).

◆ setup_index()

static bool setup_index ( keytype  key_type,
const LEX_STRING  name,
PT_base_index_option type,
List< PT_key_part_specification > *  columns,
Index_options  options,
Table_ddl_parse_context pc 
)
static

◆ setup_lex_show_cmd_type()

static void setup_lex_show_cmd_type ( THD thd,
Show_cmd_type  show_cmd_type 
)
static

Variable Documentation

◆ MAX_SYS_VAR_LENGTH

constexpr const size_t MAX_SYS_VAR_LENGTH {32}
staticconstexpr