MySQL 9.1.0
Source Code Documentation
sql_base.cc File Reference
#include "sql/sql_base.h"
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <atomic>
#include <functional>
#include <memory>
#include <unordered_map>
#include <utility>
#include "ft_global.h"
#include "m_string.h"
#include "map_helpers.h"
#include "mf_wcomp.h"
#include "mutex_lock.h"
#include "my_alloc.h"
#include "my_bitmap.h"
#include "my_byteorder.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_dir.h"
#include "my_io.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "my_sqlcommand.h"
#include "my_sys.h"
#include "my_systime.h"
#include "my_table_map.h"
#include "my_thread_local.h"
#include "mysql/binlog/event/table_id.h"
#include "mysql/components/services/bits/mysql_cond_bits.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/components/services/bits/psi_cond_bits.h"
#include "mysql/components/services/bits/psi_mutex_bits.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/my_loglevel.h"
#include "mysql/plugin.h"
#include "mysql/psi/mysql_cond.h"
#include "mysql/psi/mysql_file.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_statement.h"
#include "mysql/psi/mysql_table.h"
#include "mysql/psi/mysql_thread.h"
#include "mysql/psi/psi_table.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql/strings/m_ctype.h"
#include "mysql/thread_type.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "nulls.h"
#include "scope_guard.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/binlog.h"
#include "sql/check_stack.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/dd/dd_schema.h"
#include "sql/dd/dd_table.h"
#include "sql/dd/dd_tablespace.h"
#include "sql/dd/string_type.h"
#include "sql/dd/types/abstract_table.h"
#include "sql/dd/types/column.h"
#include "sql/dd/types/column_statistics.h"
#include "sql/dd/types/foreign_key.h"
#include "sql/dd/types/function.h"
#include "sql/dd/types/procedure.h"
#include "sql/dd/types/schema.h"
#include "sql/dd/types/table.h"
#include "sql/dd/types/view.h"
#include "sql/dd_table_share.h"
#include "sql/debug_sync.h"
#include "sql/derror.h"
#include "sql/error_handler.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/histograms/histogram.h"
#include "sql/histograms/table_histograms.h"
#include "sql/item.h"
#include "sql/item_cmpfunc.h"
#include "sql/item_func.h"
#include "sql/item_subselect.h"
#include "sql/lock.h"
#include "sql/log.h"
#include "sql/log_event.h"
#include "sql/mysqld.h"
#include "sql/mysqld_thd_manager.h"
#include "sql/nested_join.h"
#include "sql/partition_info.h"
#include "sql/psi_memory_key.h"
#include "sql/query_options.h"
#include "sql/rpl_gtid.h"
#include "sql/rpl_handler.h"
#include "sql/rpl_replica_commit_order_manager.h"
#include "sql/rpl_rli.h"
#include "sql/session_tracker.h"
#include "sql/sp.h"
#include "sql/sp_cache.h"
#include "sql/sp_head.h"
#include "sql/sql_audit.h"
#include "sql/sql_backup_lock.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_data_change.h"
#include "sql/sql_db.h"
#include "sql/sql_error.h"
#include "sql/sql_executor.h"
#include "sql/sql_handler.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_parse.h"
#include "sql/sql_prepare.h"
#include "sql/sql_select.h"
#include "sql/sql_show.h"
#include "sql/sql_sort.h"
#include "sql/sql_table.h"
#include "sql/sql_update.h"
#include "sql/sql_view.h"
#include "sql/strfunc.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/table_cache.h"
#include "sql/thd_raii.h"
#include "sql/transaction.h"
#include "sql/transaction_info.h"
#include "sql/trigger_chain.h"
#include "sql/xa.h"
#include "sql_string.h"
#include "strmake.h"
#include "strxnmov.h"
#include "template_utils.h"
#include "thr_mutex.h"

Classes

class  Repair_mrg_table_error_handler
 This internal handler is used to trap ER_NO_SUCH_TABLE and ER_WRONG_MRG_TABLE errors during CHECK/REPAIR TABLE for MERGE tables. More...
 
class  Release_histogram_locks
 
class  MDL_deadlock_handler
 An error handler which converts, if possible, ER_LOCK_DEADLOCK error that can occur when we are trying to acquire a metadata lock to a request for back-off and re-start of open_tables() process. More...
 
class  Fix_row_type_error_handler
 Error handler class for suppressing HA_ERR_ROW_FORMAT_CHANGED errors from SE. More...
 
class  MDL_deadlock_discovery_repair_handler
 An error handler to mark transaction to rollback on DEADLOCK error during DISCOVER / REPAIR. More...
 
struct  anonymous_namespace{sql_base.cc}::schema_hash
 
struct  anonymous_namespace{sql_base.cc}::schema_key_equal
 
class  Tables_in_user_order_iterator
 This is an iterator which emits leaf Table_ref nodes in an order suitable for expansion of 'table_name. More...
 

Namespaces

namespace  anonymous_namespace{sql_base.cc}
 

Typedefs

using Table_definition_cache = malloc_unordered_map< std::string, std::unique_ptr< TABLE_SHARE, Table_share_deleter > >
 

Functions

static void init_tdc_psi_keys (void)
 Initialize performance schema instrumentation points used by the table cache. More...
 
static bool check_and_update_table_version (THD *thd, Table_ref *tables, TABLE_SHARE *table_share)
 Compare metadata versions of an element obtained from the table definition cache and its corresponding node in the parse tree. More...
 
static bool open_table_entry_fini (THD *thd, TABLE_SHARE *share, TABLE *entry)
 Finalize the process of TABLE creation by taking action if a HEAP table's content was emptied implicitly. More...
 
static bool auto_repair_table (THD *thd, Table_ref *table_list)
 Auxiliary routine which is used for performing automatic table repair. More...
 
static TABLEfind_temporary_table (THD *thd, const char *table_key, size_t table_key_length)
 Find a temporary table specified by a key in the THD::temporary_tables list. More...
 
static bool tdc_open_view (THD *thd, Table_ref *table_list, const char *cache_key, size_t cache_key_length)
 Open view by getting its definition from disk (and table cache in future). More...
 
static bool add_view_place_holder (THD *thd, Table_ref *table_list)
 Add a dummy LEX object for a view. More...
 
static size_t create_table_def_key (const char *db_name, const char *table_name, char *key)
 Create a table cache/table definition cache key for a table. More...
 
static size_t create_table_def_key_tmp (const THD *thd, const char *db_name, const char *table_name, char *key)
 Create a table cache/table definition cache key for a temporary table. More...
 
std::string create_table_def_key_secondary (const char *db_name, const char *table_name)
 Create a table cache/table definition cache key for a table in a secondary storage engine. More...
 
size_t get_table_def_key (const Table_ref *table_list, const char **key)
 Get table cache key for a table list element. More...
 
bool table_def_init (void)
 
void table_def_start_shutdown (void)
 Notify table definition cache that process of shutting down server has started so it has to keep number of TABLE and TABLE_SHARE objects minimal in order to reduce number of references to pluggable engines. More...
 
void table_def_free (void)
 
uint cached_table_definitions (void)
 
static TABLE_SHAREprocess_found_table_share (THD *thd, TABLE_SHARE *share, bool open_view)
 
static bool read_histograms (THD *thd, TABLE_SHARE *share, const dd::Schema *schema, const dd::Abstract_table *table_def)
 Read any existing histogram statistics from the data dictionary and store a copy of them in the TABLE_SHARE. More...
 
static void update_schema_options (const dd::Schema *sch_obj, TABLE_SHARE *share)
 Update TABLE_SHARE with options from dd::Schema object. More...
 
TABLE_SHAREget_table_share (THD *thd, const char *db, const char *table_name, const char *key, size_t key_length, bool open_view, bool open_secondary)
 Get the TABLE_SHARE for a table. More...
 
static TABLE_SHAREget_table_share_with_discover (THD *thd, Table_ref *table_list, const char *key, size_t key_length, bool open_secondary, int *error)
 Get a table share. More...
 
void release_table_share (TABLE_SHARE *share)
 Mark that we are not using table share anymore. More...
 
TABLE_SHAREget_cached_table_share (const char *db, const char *table_name)
 Get an existing table definition from the table definition cache. More...
 
OPEN_TABLE_LISTlist_open_tables (THD *thd, const char *db, const char *wild)
 
void intern_close_table (TABLE *table)
 
void free_io_cache (TABLE *table)
 
bool close_cached_tables (THD *thd, Table_ref *tables, bool wait_for_refresh, ulong timeout)
 
static void mark_temp_tables_as_free_for_reuse (THD *thd)
 Mark all temporary tables which were used by the current statement or substatement as free for reuse, but only if the query_id can be cleared. More...
 
void mark_tmp_table_for_reuse (TABLE *table)
 Reset a single temporary table. More...
 
static void mark_used_tables_as_free_for_reuse (THD *thd, TABLE *table)
 
static void close_open_tables (THD *thd)
 Auxiliary function to close all tables in the open_tables list. More...
 
static void close_all_tables_for_name (THD *thd, const char *key, size_t key_length, const char *db, const char *table_name, bool remove_from_locked_tables, TABLE *skip_table)
 Close all open instances of the table but keep the MDL lock. More...
 
void close_all_tables_for_name (THD *thd, TABLE_SHARE *share, bool remove_from_locked_tables, TABLE *skip_table)
 Close all open instances of the table but keep the MDL lock. More...
 
void close_all_tables_for_name (THD *thd, const char *db, const char *table_name, bool remove_from_locked_tables)
 Close all open instances of the table but keep the MDL lock. More...
 
static bool in_LTM (THD *thd)
 
static bool belongs_to_dd_table (const Table_ref *tl)
 Check if the given Table_ref belongs to a DD table. More...
 
void close_thread_tables (THD *thd)
 Close all tables used by the current substatement, or all tables used by this thread if we are on the outer-most level. More...
 
static void release_or_close_table (THD *thd, TABLE *table)
 Helper function which returns TABLE to Table Cache or closes if table is marked as needing re-open. More...
 
void close_thread_table (THD *thd, TABLE **table_ptr)
 
static uint tmpkeyval (TABLE *table)
 
bool close_temporary_tables (THD *thd)
 
Table_reffind_table_in_global_list (Table_ref *table, const char *db_name, const char *table_name)
 Find table in global list. More...
 
static Table_reffind_dup_table (const Table_ref *table, Table_ref *table_list, bool check_alias)
 Test that table is unique (It's only exists once in the table list) More...
 
Table_refunique_table (const Table_ref *table, Table_ref *table_list, bool check_alias)
 Test that the subject table of INSERT/UPDATE/DELETE/CREATE or (in case of MyISAMMRG) one of its children are not used later in the query. More...
 
void update_non_unique_table_error (Table_ref *update, const char *operation, Table_ref *duplicate)
 Issue correct error message in case we found 2 duplicate tables which prevent some update operation. More...
 
TABLEfind_temporary_table (THD *thd, const char *db, const char *table_name)
 Find temporary table specified by database and table names in the THD::temporary_tables list. More...
 
TABLEfind_temporary_table (THD *thd, const Table_ref *tl)
 Find a temporary table specified by Table_ref instance in the THD::temporary_tables list. More...
 
void drop_temporary_table (THD *thd, Table_ref *table_list)
 Drop a temporary table. More...
 
void close_temporary_table (THD *thd, TABLE *table, bool free_share, bool delete_table)
 
void close_temporary (THD *thd, TABLE *table, bool free_share, bool delete_table)
 
bool rename_temporary_table (THD *thd, TABLE *table, const char *db, const char *table_name)
 
bool wait_while_table_is_used (THD *thd, TABLE *table, enum ha_extra_function function)
 Force all other threads to stop using the table by upgrading metadata lock on it and remove unused TABLE instances from cache. More...
 
static bool check_if_table_exists (THD *thd, Table_ref *table, bool *exists)
 Check that table exists in data-dictionary or in some storage engine. More...
 
static bool open_table_get_mdl_lock (THD *thd, Open_table_context *ot_ctx, Table_ref *table_list, uint flags, MDL_ticket **mdl_ticket)
 Try to acquire an MDL lock for a table being opened. More...
 
static bool tdc_wait_for_old_version (THD *thd, const char *db, const char *table_name, ulong wait_timeout, uint deadlock_weight)
 Check if table's share is being removed from the table definition cache and, if yes, wait until the flush is complete. More...
 
bool open_table (THD *thd, Table_ref *table_list, Open_table_context *ot_ctx)
 Open a base table. More...
 
TABLEfind_locked_table (TABLE *list, const char *db, const char *table_name)
 Find table in the list of open tables. More...
 
TABLEfind_table_for_mdl_upgrade (THD *thd, const char *db, const char *table_name, bool no_error)
 Find instance of TABLE with upgradable or exclusive metadata lock from the list of open tables, emit error if no such table found. More...
 
void assign_new_table_id (TABLE_SHARE *share)
 
static bool check_and_update_routine_version (THD *thd, Sroutine_hash_entry *rt, sp_head *sp)
 Compares versions of a stored routine obtained from the sp cache and the version used at prepare. More...
 
static bool fix_row_type (THD *thd, Table_ref *table_list)
 Auxiliary routine for automatically updating row format for the table. More...
 
thr_lock_type read_lock_type_for_table (THD *thd, Query_tables_list *prelocking_ctx, Table_ref *table_list, bool routine_modifies_data)
 
static void process_table_fks (THD *thd, Query_tables_list *prelocking_ctx, TABLE_SHARE *share, bool is_insert, bool is_update, bool is_delete, Table_ref *belong_to_view, bool *need_prelocking)
 Process table's foreign keys (if any) by prelocking algorithm. More...
 
static bool open_and_process_routine (THD *thd, Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt, Prelocking_strategy *prelocking_strategy, bool has_prelocking_list, Open_table_context *ot_ctx, bool *need_prelocking, bool *routine_modifies_data)
 Handle element of prelocking set other than table. More...
 
static bool open_and_process_table (THD *thd, LEX *lex, Table_ref *const tables, uint *counter, Prelocking_strategy *prelocking_strategy, bool has_prelocking_list, Open_table_context *ot_ctx)
 Handle table list element by obtaining metadata lock, opening table or view and, if prelocking strategy prescribes so, extending the prelocking set with tables and routines used by it. More...
 
int run_before_dml_hook (THD *thd)
 Run the server hook called "before_dml". More...
 
static bool is_temporary_table_being_opened (const Table_ref *table)
 Check whether a table being opened is a temporary table. More...
 
bool get_and_lock_tablespace_names (THD *thd, Table_ref *tables_start, Table_ref *tables_end, ulong lock_wait_timeout, uint flags)
 Acquire IX metadata locks on tablespace names used by LOCK TABLES or by a DDL statement. More...
 
bool lock_table_names (THD *thd, Table_ref *tables_start, Table_ref *tables_end, ulong lock_wait_timeout, uint flags, Prealloced_array< MDL_request *, 1 > *schema_reqs)
 Acquire "strong" (SRO, SNW, SNRW) metadata locks on tables used by LOCK TABLES or by a DDL statement. More...
 
static bool open_tables_check_upgradable_mdl (THD *thd, Table_ref *tables_start, Table_ref *tables_end)
 Check for upgradable (SNW, SNRW) metadata locks on tables to be opened for a DDL statement. More...
 
static bool acquire_backup_lock_in_lock_tables_mode (THD *thd, Table_ref *tables_start, Table_ref *tables_end)
 Iterate along a list of tables and acquire BACKUP LOCK in shared mode in case a strong MDL request (DDL/LOCK TABLES-type) was specified for a table. More...
 
static bool set_non_locking_read_for_IS_view (THD *thd, Table_ref *tl)
 Check if this is a DD table used under a I_S view then request InnoDB to do non-locking reads on the table. More...
 
bool is_acl_table_in_non_LTM (const Table_ref *tl, enum enum_locked_tables_mode ltm)
 Check if given Table_ref is a acl table and is being read and not in LOCK TABLE mode. More...
 
static bool set_non_locking_read_for_ACL_table (THD *thd, Table_ref *tl, const bool &issue_warning)
 Check if this is a ACL table is requested for read and then request InnoDB to do non-locking reads on the table. More...
 
bool open_tables (THD *thd, Table_ref **start, uint *counter, uint flags, Prelocking_strategy *prelocking_strategy)
 Open all tables in list. More...
 
static bool check_lock_and_start_stmt (THD *thd, Query_tables_list *prelocking_ctx, Table_ref *table_list)
 Check that lock is ok for tables; Call start stmt if ok. More...
 
TABLEopen_n_lock_single_table (THD *thd, Table_ref *table_l, thr_lock_type lock_type, uint flags, Prelocking_strategy *prelocking_strategy)
 Open and lock one table. More...
 
TABLEopen_ltable (THD *thd, Table_ref *table_list, thr_lock_type lock_type, uint lock_flags)
 
bool open_and_lock_tables (THD *thd, Table_ref *tables, uint flags, Prelocking_strategy *prelocking_strategy)
 Open all tables in list, locks them and optionally process derived tables. More...
 
static bool open_secondary_engine_tables (THD *thd, uint flags)
 Check if a secondary engine can be used to execute the current statement, and if so, replace the opened tables with their secondary counterparts. More...
 
bool open_tables_for_query (THD *thd, Table_ref *tables, uint flags)
 Open all tables for a query or statement, in list started by "tables". More...
 
static void mark_real_tables_as_free_for_reuse (Table_ref *table_list)
 
bool lock_tables (THD *thd, Table_ref *tables, uint count, uint flags)
 Lock all tables in a list. More...
 
bool lock_dictionary_tables (THD *thd, Table_ref *tables, uint count, uint flags)
 Simplified version of lock_tables() call to be used for locking data-dictionary tables when reading or storing data-dictionary objects. More...
 
void close_tables_for_reopen (THD *thd, Table_ref **tables, const MDL_savepoint &start_of_statement_svp)
 Prepare statement for reopening of tables and recalculation of set of prelocked tables. More...
 
TABLEopen_table_uncached (THD *thd, const char *path, const char *db, const char *table_name, bool add_to_temporary_tables_list, bool open_in_engine, const dd::Table &table_def)
 Open a single table without table caching and don't add it to THD::open_tables. More...
 
bool rm_temporary_table (THD *thd, handlerton *base, const char *path, const dd::Table *table_def)
 Delete a temporary table. More...
 
bool open_temporary_table (THD *thd, Table_ref *tl)
 Find a temporary table specified by Table_ref instance in the cache and prepare its TABLE instance for use. More...
 
bool open_temporary_tables (THD *thd, Table_ref *tl_list)
 Pre-open temporary tables corresponding to table list elements. More...
 
static bool find_field_in_view (THD *thd, Table_ref *tr, const char *field_name, const char *alias, Item_ident **ref_field)
 Find a field by name in a view that uses merge algorithm. More...
 
static bool find_field_in_natural_join (THD *thd, Table_ref *tr, const char *name, const char *alias, Find_field_result *result, Field **base_field, Item_ident **ref_field)
 Find field by name in a NATURAL/USING join table reference. More...
 
Fieldfind_field_in_table (TABLE *table, const char *field_name, bool allow_rowid, uint *field_index)
 Find field by name in a base table. More...
 
bool find_field_in_table_ref (THD *thd, Table_ref *tr, const char *field_name, size_t length, const char *alias, const char *db_name, const char *table_name, Access_bitmask want_privilege, bool allow_rowid, Find_field_result *result, Field **base_field, Item_ident **ref_field)
 Given a table reference and the name of a field, attempt to find the field in the referenced table. More...
 
Fieldfind_field_in_table_sef (TABLE *table, const char *field_name)
 Find field in table, no side effects, only purpose is to check for field in table object and get reference to the field if found. More...
 
bool find_field_in_tables (THD *thd, Item_ident *item, Table_ref *first_table, Table_ref *last_table, int report_error, Access_bitmask want_privilege, Find_field_result *result, Field **base_field, Item_ident **ref_field)
 Find field in list of tables inside one query block. More...
 
bool find_item_in_list (THD *thd, Item *find, mem_root_deque< Item * > *items, Item ***found, uint *counter, enum_resolution_type *resolution)
 Find Item in list of items (find_field_in_tables analog) More...
 
static bool test_if_string_in_list (const char *find, List< String > *str_list)
 
static bool set_new_item_local_context (THD *thd, Item_ident *item, Table_ref *table_ref)
 
static bool mark_common_columns (THD *thd, Table_ref *table_ref_1, Table_ref *table_ref_2, List< String > *using_fields, uint *found_using_fields)
 
static bool store_natural_using_join_columns (THD *thd, Table_ref *natural_using_join, Table_ref *table_ref_1, Table_ref *table_ref_2, List< String > *using_fields, uint found_using_fields)
 
static bool store_top_level_join_columns (THD *thd, Table_ref *table_ref, Table_ref *left_neighbor, Table_ref *right_neighbor)
 
bool setup_natural_join_row_types (THD *thd, mem_root_deque< Table_ref * > *from_clause, Name_resolution_context *context)
 
bool resolve_var_assignments (THD *thd, LEX *lex)
 Resolve variable assignments from LEX object. More...
 
bool setup_fields (THD *thd, Access_bitmask want_privilege, bool allow_sum_func, bool split_sum_funcs, bool column_update, const mem_root_deque< Item * > *typed_items, mem_root_deque< Item * > *fields, Ref_item_array ref_item_array)
 Resolve a list of expressions and setup appropriate data. More...
 
bool insert_fields (THD *thd, Query_block *query_block, const char *db_name, const char *table_name, mem_root_deque< Item * > *fields, mem_root_deque< Item * >::iterator *it, bool any_privileges)
 
bool fill_record (THD *thd, TABLE *table, const mem_root_deque< Item * > &fields, const mem_root_deque< Item * > &values, MY_BITMAP *bitmap, MY_BITMAP *insert_into_fields_bitmap, bool raise_autoinc_has_expl_non_null_val)
 Fill fields with given items. More...
 
static bool check_record (THD *thd, const mem_root_deque< Item * > &fields)
 Check the NOT NULL constraint on all the fields of the current record. More...
 
bool check_record (THD *thd, Field **ptr)
 Check the NOT NULL constraint on all the fields of the current record. More...
 
static bool check_inserting_record (THD *thd, Field **ptr)
 Check the NOT NULL constraint on all the fields explicitly set in INSERT INTO statement or implicitly set in BEFORE trigger. More...
 
bool invoke_table_check_constraints (THD *thd, const TABLE *table)
 Invoke check constraints defined on the table. More...
 
static bool command_can_invoke_insert_triggers (enum enum_trigger_event_type event, enum_sql_command sql_command)
 Check if SQL-statement is INSERT/INSERT SELECT/REPLACE/REPLACE SELECT and trigger event is ON INSERT. More...
 
bool call_before_insert_triggers (THD *thd, TABLE *table, enum enum_trigger_event_type event, MY_BITMAP *insert_into_fields_bitmap)
 Execute BEFORE INSERT trigger. More...
 
bool fill_record_n_invoke_before_triggers (THD *thd, COPY_INFO *optype_info, const mem_root_deque< Item * > &fields, const mem_root_deque< Item * > &values, TABLE *table, enum enum_trigger_event_type event, int num_fields, bool raise_autoinc_has_expl_non_null_val, bool *is_row_changed)
 Fill fields in list with values from the list of items and invoke before triggers. More...
 
bool fill_record (THD *thd, TABLE *table, Field **ptr, const mem_root_deque< Item * > &values, MY_BITMAP *bitmap, MY_BITMAP *insert_into_fields_bitmap, bool raise_autoinc_has_expl_non_null_val)
 Fill field buffer with values from Field list. More...
 
bool fill_record_n_invoke_before_triggers (THD *thd, Field **ptr, const mem_root_deque< Item * > &values, TABLE *table, enum enum_trigger_event_type event, int num_fields)
 Fill fields in array with values from the list of items and invoke before triggers. More...
 
bool mysql_rm_tmp_tables (void)
 Drop all temporary tables which have been left from previous server run. More...
 
void tdc_flush_unused_tables ()
 
void tdc_remove_table (THD *thd, enum_tdc_remove_table_type remove_type, const char *db, const char *table_name, bool has_lock)
 Remove all or some (depending on parameter) instances of TABLE and TABLE_SHARE from the table definition cache. More...
 
int setup_ftfuncs (const THD *thd, Query_block *query_block)
 
bool init_ftfuncs (THD *thd, Query_block *query_block)
 
bool open_trans_system_tables_for_read (THD *thd, Table_ref *table_list)
 Open and lock transactional system tables for read. More...
 
void close_trans_system_tables (THD *thd)
 Close transactional system tables, opened with open_trans_system_tables_for_read(). More...
 
void close_mysql_tables (THD *thd)
 A helper function to close a mysql. More...
 
TABLEopen_log_table (THD *thd, Table_ref *one_table, Open_tables_backup *backup)
 Open a log table. More...
 
void close_log_table (THD *thd, Open_tables_backup *backup)
 Close a log table. More...
 

Variables

static constexpr const size_t MAX_DBKEY_LENGTH {NAME_LEN * 2 + 1 + 1 + 4 + 4}
 The maximum length of a key in the table definition cache. More...
 
static constexpr long STACK_MIN_SIZE_FOR_OPEN {1024 * 80}
 
mysql_mutex_t LOCK_open
 LOCK_open protects the following variables/objects: More...
 
mysql_cond_t COND_open
 COND_open synchronizes concurrent opening of the same share: More...
 
static PSI_mutex_key key_LOCK_open
 
static PSI_cond_key key_COND_open
 
static PSI_mutex_info all_tdc_mutexes []
 
static PSI_cond_info all_tdc_conds []
 
Table_definition_cachetable_def_cache
 
static TABLE_SHAREoldest_unused_share
 
static TABLE_SHARE end_of_unused_share
 
static bool table_def_shutdown_in_progress = false
 
static mysql::binlog::event::Table_id last_table_id
 

Variable Documentation

◆ MAX_DBKEY_LENGTH

constexpr const size_t MAX_DBKEY_LENGTH {NAME_LEN * 2 + 1 + 1 + 4 + 4}
staticconstexpr

The maximum length of a key in the table definition cache.

The key consists of the schema name, a '\0' character, the table name and a '\0' character. Hence NAME_LEN * 2 + 1 + 1.

Additionally, the key can be suffixed with either 4 + 4 extra bytes for slave tmp tables, or with a single extra byte for tables in a secondary storage engine. Add 4 + 4 to account for either of these suffixes.

◆ STACK_MIN_SIZE_FOR_OPEN

constexpr long STACK_MIN_SIZE_FOR_OPEN {1024 * 80}
staticconstexpr