My Project
|
Classes | |
class | MDL_deadlock_handler |
class | MDL_deadlock_discovery_repair_handler |
Defines | |
#define | WRONG_GRANT (Field*) -1 |
Functions | |
uint | get_table_def_key (const TABLE_LIST *table_list, const char **key) |
uchar * | table_def_key (const uchar *record, size_t *length, my_bool not_used __attribute__((unused))) |
bool | table_def_init (void) |
void | table_def_start_shutdown (void) |
void | table_def_free (void) |
uint | cached_table_definitions (void) |
TABLE_SHARE * | get_table_share (THD *thd, TABLE_LIST *table_list, const char *key, uint key_length, uint db_flags, int *error, my_hash_value_type hash_value) |
void | release_table_share (TABLE_SHARE *share) |
TABLE_SHARE * | get_cached_table_share (const char *db, const char *table_name) |
OPEN_TABLE_LIST * | list_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_LIST *tables, bool wait_for_refresh, ulong timeout) |
bool | close_cached_connection_tables (THD *thd, LEX_STRING *connection) |
void | mark_tmp_table_for_reuse (TABLE *table) |
void | close_all_tables_for_name (THD *thd, TABLE_SHARE *share, bool remove_from_locked_tables, TABLE *skip_table) |
void | close_thread_tables (THD *thd) |
void | close_thread_table (THD *thd, TABLE **table_ptr) |
bool | close_temporary_tables (THD *thd) |
TABLE_LIST * | find_table_in_list (TABLE_LIST *table, TABLE_LIST *TABLE_LIST::*link, const char *db_name, const char *table_name) |
TABLE_LIST * | unique_table (THD *thd, TABLE_LIST *table, TABLE_LIST *table_list, bool check_alias) |
void | update_non_unique_table_error (TABLE_LIST *update, const char *operation, TABLE_LIST *duplicate) |
TABLE * | find_temporary_table (THD *thd, const char *db, const char *table_name) |
TABLE * | find_temporary_table (THD *thd, const TABLE_LIST *tl) |
TABLE * | find_temporary_table (THD *thd, const char *table_key, uint table_key_length) |
int | drop_temporary_table (THD *thd, TABLE_LIST *table_list, bool *is_trans) |
void | close_temporary_table (THD *thd, TABLE *table, bool free_share, bool delete_table) |
void | close_temporary (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) |
void | drop_open_table (THD *thd, TABLE *table, const char *db_name, const char *table_name) |
bool | check_if_table_exists (THD *thd, TABLE_LIST *table, bool *exists) |
bool | open_table (THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) |
TABLE * | find_locked_table (TABLE *list, const char *db, const char *table_name) |
TABLE * | find_table_for_mdl_upgrade (THD *thd, const char *db, const char *table_name, bool no_error) |
void | assign_new_table_id (TABLE_SHARE *share) |
bool | tdc_open_view (THD *thd, TABLE_LIST *table_list, const char *alias, const char *cache_key, uint cache_key_length, uint flags) |
thr_lock_type | read_lock_type_for_table (THD *thd, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, bool routine_modifies_data) |
uchar * | schema_set_get_key (const uchar *record, size_t *length, my_bool not_used __attribute__((unused))) |
bool | lock_table_names (THD *thd, TABLE_LIST *tables_start, TABLE_LIST *tables_end, ulong lock_wait_timeout, uint flags) |
bool | open_tables (THD *thd, TABLE_LIST **start, uint *counter, uint flags, Prelocking_strategy *prelocking_strategy) |
TABLE * | open_n_lock_single_table (THD *thd, TABLE_LIST *table_l, thr_lock_type lock_type, uint flags, Prelocking_strategy *prelocking_strategy) |
Open and lock one table. | |
TABLE * | open_ltable (THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type, uint lock_flags) |
bool | open_and_lock_tables (THD *thd, TABLE_LIST *tables, bool derived, uint flags, Prelocking_strategy *prelocking_strategy) |
bool | open_normal_and_derived_tables (THD *thd, TABLE_LIST *tables, uint flags) |
bool | lock_tables (THD *thd, TABLE_LIST *tables, uint count, uint flags) |
void | close_tables_for_reopen (THD *thd, TABLE_LIST **tables, const MDL_savepoint &start_of_statement_svp) |
TABLE * | open_table_uncached (THD *thd, const char *path, const char *db, const char *table_name, bool add_to_temporary_tables_list, bool open_in_engine) |
bool | rm_temporary_table (handlerton *base, const char *path) |
bool | open_temporary_table (THD *thd, TABLE_LIST *tl) |
bool | open_temporary_tables (THD *thd, TABLE_LIST *tl_list) |
Field * | find_field_in_table (THD *thd, TABLE *table, const char *name, uint length, bool allow_rowid, uint *cached_field_index_ptr) |
Field * | find_field_in_table_ref (THD *thd, TABLE_LIST *table_list, const char *name, uint length, const char *item_name, const char *db_name, const char *table_name, Item **ref, bool check_privileges, bool allow_rowid, uint *cached_field_index_ptr, bool register_tree_change, TABLE_LIST **actual_table) |
Field * | find_field_in_table_sef (TABLE *table, const char *name) |
Field * | find_field_in_tables (THD *thd, Item_ident *item, TABLE_LIST *first_table, TABLE_LIST *last_table, Item **ref, find_item_error_report_type report_error, bool check_privileges, bool register_tree_change) |
Item ** | find_item_in_list (Item *find, List< Item > &items, uint *counter, find_item_error_report_type report_error, enum_resolution_type *resolution) |
int | setup_wild (THD *thd, TABLE_LIST *tables, List< Item > &fields, List< Item > *sum_func_list, uint wild_num) |
bool | setup_fields (THD *thd, Ref_ptr_array ref_pointer_array, List< Item > &fields, enum_mark_columns mark_used_columns, List< Item > *sum_func_list, bool allow_sum_func) |
TABLE_LIST ** | make_leaves_list (TABLE_LIST **list, TABLE_LIST *tables) |
bool | setup_tables (THD *thd, Name_resolution_context *context, List< TABLE_LIST > *from_clause, TABLE_LIST *tables, TABLE_LIST **leaves, bool select_insert) |
bool | setup_tables_and_check_access (THD *thd, Name_resolution_context *context, List< TABLE_LIST > *from_clause, TABLE_LIST *tables, TABLE_LIST **leaves, bool select_insert, ulong want_access_first, ulong want_access) |
bool | insert_fields (THD *thd, Name_resolution_context *context, const char *db_name, const char *table_name, List_iterator< Item > *it, bool any_privileges) |
int | setup_conds (THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, Item **conds) |
bool | fill_record (THD *thd, List< Item > &fields, List< Item > &values, bool ignore_errors, MY_BITMAP *bitmap) |
bool | fill_record_n_invoke_before_triggers (THD *thd, List< Item > &fields, List< Item > &values, bool ignore_errors, Table_triggers_list *triggers, enum trg_event_type event) |
bool | fill_record (THD *thd, Field **ptr, List< Item > &values, bool ignore_errors, MY_BITMAP *bitmap) |
bool | fill_record_n_invoke_before_triggers (THD *thd, Field **ptr, List< Item > &values, bool ignore_errors, Table_triggers_list *triggers, enum trg_event_type event) |
my_bool | mysql_rm_tmp_tables (void) |
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) |
int | setup_ftfuncs (SELECT_LEX *select_lex) |
int | init_ftfuncs (THD *thd, SELECT_LEX *select_lex, bool no_order) |
bool | is_equal (const LEX_STRING *a, const LEX_STRING *b) |
bool | open_system_tables_for_read (THD *thd, TABLE_LIST *table_list, Open_tables_backup *backup) |
void | close_system_tables (THD *thd, Open_tables_backup *backup) |
void | close_mysql_tables (THD *thd) |
TABLE * | open_system_table_for_update (THD *thd, TABLE_LIST *one_table) |
TABLE * | open_log_table (THD *thd, TABLE_LIST *one_table, Open_tables_backup *backup) |
void | close_log_table (THD *thd, Open_tables_backup *backup) |
virtual bool | MDL_deadlock_handler::handle_condition (THD *thd, uint sql_errno, const char *sqlstate, Sql_condition::enum_warning_level level, const char *msg, Sql_condition **cond_hdl) |
Open_table_context::Open_table_context (THD *thd, uint flags) | |
bool | Open_table_context::request_backoff_action (enum_open_table_action action_arg, TABLE_LIST *table) |
bool | Open_table_context::recover_from_failed_open () |
virtual bool | DML_prelocking_strategy::handle_routine (THD *thd, Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt, sp_head *sp, bool *need_prelocking) |
virtual bool | DML_prelocking_strategy::handle_table (THD *thd, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, bool *need_prelocking) |
virtual bool | DML_prelocking_strategy::handle_view (THD *thd, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, bool *need_prelocking) |
virtual bool | Alter_table_prelocking_strategy::handle_routine (THD *thd, Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt, sp_head *sp, bool *need_prelocking) |
virtual bool | Alter_table_prelocking_strategy::handle_table (THD *thd, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, bool *need_prelocking) |
virtual bool | Alter_table_prelocking_strategy::handle_view (THD *thd, Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, bool *need_prelocking) |
Variables | |
mysql_mutex_t | LOCK_open |
HASH | table_def_cache |
Field * | not_found_field = (Field*) 0x1 |
Field * | view_ref_found = (Field*) 0x2 |
Item ** | not_found_item = (Item**) 0x1 |
bool check_if_table_exists | ( | THD * | thd, |
TABLE_LIST * | table, | ||
bool * | exists | ||
) |
Check that table exists in table definition cache, on disk or in some storage engine.
thd | Thread context | |
table | Table list element | |
[out] | exists | Out parameter which is set to TRUE if table exists and to FALSE otherwise. |
TRUE | Some error occurred |
FALSE | No error. 'exists' out parameter set accordingly. |
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.
Works both under LOCK TABLES and in the normal mode. Removes all closed instances of the table from the table cache.
thd | thread handle | |
[in] | share | table share, but is just a handy way to access the table cache key |
[in] | remove_from_locked_tables | TRUE if the table is being dropped or renamed. In that case the documented behaviour is to implicitly remove the table from LOCK TABLES list. |
[in] | skip_table | TABLE instance that should be kept open. |
bool close_cached_connection_tables | ( | THD * | thd, |
LEX_STRING * | connection | ||
) |
Close all tables which match specified connection string or if specified string is NULL, then any table with a connection string.
void close_log_table | ( | THD * | thd, |
Open_tables_backup * | backup | ||
) |
Close a log table. The last table opened by open_log_table() is closed, then the thread context is restored.
thd | The current thread |
backup | [in] the context to restore. |
void close_mysql_tables | ( | THD * | thd | ) |
A helper function to close a mysql.* table opened in an auxiliary THD during bootstrap or in the main connection, when we know that there are no locks held by the connection due to a preceding implicit commit.
This function assumes that there is no statement transaction started for the operation itself, since mysql.* tables are not transactional and when they are used the binlog is off (DDL binlogging is always statement-based.
We need this function since we'd like to not just close the system table, but also release the metadata lock on it.
Note, that in LOCK TABLES mode this function does not release the metadata lock. But in this mode the table can be opened only if it is locked explicitly with LOCK TABLES.
void close_tables_for_reopen | ( | THD * | thd, |
TABLE_LIST ** | tables, | ||
const MDL_savepoint & | start_of_statement_svp | ||
) |
Prepare statement for reopening of tables and recalculation of set of prelocked tables.
[in] | thd | Thread context. |
[in,out] | tables | List of tables which we were trying to open and lock. |
[in] | start_of_statement_svp | MDL savepoint which represents the set of metadata locks which the current transaction managed to acquire before execution of the current statement and to which we should revert before trying to reopen tables. NULL if no metadata locks were held and thus all metadata locks should be released. |
void drop_open_table | ( | THD * | thd, |
TABLE * | table, | ||
const char * | db_name, | ||
const char * | table_name | ||
) |
Close a and drop a just created table in CREATE TABLE ... SELECT.
thd | Thread handle |
table | TABLE object for the table to be dropped |
db_name | Name of database for this table |
table_name | Name of this table |
This routine assumes that the table to be closed is open only by the calling thread, so we needn't wait until other threads close the table. It also assumes that the table is first in thd->open_ables and a data lock on it, if any, has been released. To sum up, it's tuned to work with CREATE TABLE ... SELECT and CREATE TABLE .. SELECT only. Note, that currently CREATE TABLE ... SELECT is not supported under LOCK TABLES. This function, still, can be called in prelocked mode, e.g. if we do CREATE TABLE .. SELECT f1();
int drop_temporary_table | ( | THD * | thd, |
TABLE_LIST * | table_list, | ||
bool * | is_trans | ||
) |
Drop a temporary table.
Try to locate the table in the list of thd->temporary_tables. If the table is found:
This function is used to drop user temporary tables, as well as internal tables created in CREATE TEMPORARY TABLE ... SELECT or ALTER TABLE. Even though part of the work done by this function is redundant when the table is internal, as long as we link both internal and user temporary tables into the same thd->temporary_tables list, it's impossible to tell here whether we're dealing with an internal or a user temporary table.
In is_trans out-parameter, we return the type of the table: either transactional (e.g. innodb) as TRUE or non-transactional (e.g. myisam) as FALSE.
This function assumes that table to be dropped was pre-opened using table list provided.
0 | the table was found and dropped successfully. |
1 | the table was not found in the list of temporary tables of this thread |
-1 | the table is in use by a outer query |
bool fill_record | ( | THD * | thd, |
Field ** | ptr, | ||
List< Item > & | values, | ||
bool | ignore_errors, | ||
MY_BITMAP * | bitmap | ||
) |
Fill field buffer with values from Field list.
thd | thread handler |
ptr | pointer on pointer to record |
values | list of fields |
ignore_errors | True if we should ignore errors |
bitmap | Bitmap over fields to fill |
false | OK |
true | Error occured |
TABLE* find_locked_table | ( | TABLE * | list, |
const char * | db, | ||
const char * | table_name | ||
) |
TABLE* find_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.
thd | Thread context |
db | Database name. |
table_name | Name of table. |
no_error | Don't emit error if no suitable TABLE instance were found. |
TABLE* find_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.
TABLE* find_temporary_table | ( | THD * | thd, |
const TABLE_LIST * | tl | ||
) |
Find a temporary table specified by TABLE_LIST instance in the THD::temporary_tables list.
TABLE* find_temporary_table | ( | THD * | thd, |
const char * | table_key, | ||
uint | table_key_length | ||
) |
Find a temporary table specified by a key in the THD::temporary_tables list.
uint get_table_def_key | ( | const TABLE_LIST * | table_list, |
const char ** | key | ||
) |
Get table cache key for a table list element.
table_list[in] | Table list element. |
key[out] | On return points to table cache key for the table. |
bool DML_prelocking_strategy::handle_routine | ( | THD * | thd, |
Query_tables_list * | prelocking_ctx, | ||
Sroutine_hash_entry * | rt, | ||
sp_head * | sp, | ||
bool * | need_prelocking | ||
) | [virtual] |
Defines how prelocking algorithm for DML statements should handle routines:
[in] | thd | Thread context. |
[in] | prelocking_ctx | Prelocking context of the statement. |
[in] | rt | Prelocking set element describing routine. |
[in] | sp | Routine body. |
[out] | need_prelocking | Set to TRUE if method detects that prelocking required, not changed otherwise. |
FALSE | Success. |
TRUE | Failure (OOM). |
Implements Prelocking_strategy.
bool Alter_table_prelocking_strategy::handle_routine | ( | THD * | thd, |
Query_tables_list * | prelocking_ctx, | ||
Sroutine_hash_entry * | rt, | ||
sp_head * | sp, | ||
bool * | need_prelocking | ||
) | [virtual] |
Defines how prelocking algorithm for ALTER TABLE statement should handle routines - do nothing as this statement is not supposed to call routines.
We still can end up in this method when someone tries to define a foreign key referencing a view, and not just a simple view, but one that uses stored routines.
Implements Prelocking_strategy.
bool DML_prelocking_strategy::handle_table | ( | THD * | thd, |
Query_tables_list * | prelocking_ctx, | ||
TABLE_LIST * | table_list, | ||
bool * | need_prelocking | ||
) | [virtual] |
Defines how prelocking algorithm for DML statements should handle table list elements:
We do not need to acquire metadata locks on trigger names in DML statements, since all DDL statements that change trigger metadata always lock their subject tables.
[in] | thd | Thread context. |
[in] | prelocking_ctx | Prelocking context of the statement. |
[in] | table_list | Table list element for table. |
[in] | sp | Routine body. |
[out] | need_prelocking | Set to TRUE if method detects that prelocking required, not changed otherwise. |
FALSE | Success. |
TRUE | Failure (OOM). |
Implements Prelocking_strategy.
bool Alter_table_prelocking_strategy::handle_table | ( | THD * | thd, |
Query_tables_list * | prelocking_ctx, | ||
TABLE_LIST * | table_list, | ||
bool * | need_prelocking | ||
) | [virtual] |
Defines how prelocking algorithm for ALTER TABLE statement should handle table list elements.
Unlike in DML, we do not process triggers here.
[in] | thd | Thread context. |
[in] | prelocking_ctx | Prelocking context of the statement. |
[in] | table_list | Table list element for table. |
[in] | sp | Routine body. |
[out] | need_prelocking | Set to TRUE if method detects that prelocking required, not changed otherwise. |
FALSE | Success. |
TRUE | Failure (OOM). |
Implements Prelocking_strategy.
bool DML_prelocking_strategy::handle_view | ( | THD * | thd, |
Query_tables_list * | prelocking_ctx, | ||
TABLE_LIST * | table_list, | ||
bool * | need_prelocking | ||
) | [virtual] |
Defines how prelocking algorithm for DML statements should handle view - all view routines should be added to the prelocking set.
[in] | thd | Thread context. |
[in] | prelocking_ctx | Prelocking context of the statement. |
[in] | table_list | Table list element for view. |
[in] | sp | Routine body. |
[out] | need_prelocking | Set to TRUE if method detects that prelocking required, not changed otherwise. |
FALSE | Success. |
TRUE | Failure (OOM). |
Implements Prelocking_strategy.
bool Alter_table_prelocking_strategy::handle_view | ( | THD * | thd, |
Query_tables_list * | prelocking_ctx, | ||
TABLE_LIST * | table_list, | ||
bool * | need_prelocking | ||
) | [virtual] |
Defines how prelocking algorithm for ALTER TABLE statement should handle view - do nothing. We don't need to add view routines to the prelocking set in this case as view is not going to be materialized.
Implements Prelocking_strategy.
bool lock_table_names | ( | THD * | thd, |
TABLE_LIST * | tables_start, | ||
TABLE_LIST * | tables_end, | ||
ulong | lock_wait_timeout, | ||
uint | flags | ||
) |
Acquire upgradable (SNW, SNRW) metadata locks on tables used by LOCK TABLES or by a DDL statement. Acquire lock "S" on table being created in CREATE TABLE statement.
thd | Thread context. |
tables_start | Start of list of tables on which upgradable locks should be acquired. |
tables_end | End of list of tables. |
lock_wait_timeout | Seconds to wait before timeout. |
flags | Bitmap of flags to modify how the tables will be open, see open_table() description for details. |
FALSE | Success. |
TRUE | Failure (e.g. connection was killed) |
bool lock_tables | ( | THD * | thd, |
TABLE_LIST * | tables, | ||
uint | count, | ||
uint | flags | ||
) |
Lock all tables in a list.
thd | Thread handler |
tables | Tables to lock |
count | Number of opened tables |
flags | Options (see mysql_lock_tables() for details) |
You can't call lock_tables() while holding thr_lock locks, as this would break the dead-lock-free handling thr_lock gives us. You must always get all needed locks at once.
If the query for which we are calling this function is marked as requiring prelocking, this function will change locked_tables_mode to LTM_PRELOCKED.
FALSE | Success. |
TRUE | A lock wait timeout, deadlock or out of memory. |
void mark_tmp_table_for_reuse | ( | TABLE * | table | ) |
Reset a single temporary table. Effectively this "closes" one temporary table, in a session.
table | Temporary table. |
bool open_and_lock_tables | ( | THD * | thd, |
TABLE_LIST * | tables, | ||
bool | derived, | ||
uint | flags, | ||
Prelocking_strategy * | prelocking_strategy | ||
) |
Open all tables in list, locks them and optionally process derived tables.
thd | Thread context. |
tables | List of tables for open and locking. |
derived | If to handle derived tables. |
flags | Bitmap of options to be used to open and lock tables (see open_tables() and mysql_lock_tables() for details). |
prelocking_strategy | Strategy which specifies how prelocking algorithm should work for this statement. |
FALSE | OK. |
TRUE | Error |
TABLE* open_log_table | ( | THD * | thd, |
TABLE_LIST * | one_table, | ||
Open_tables_backup * | backup | ||
) |
Open a log table. Opening such tables is performed internally in the server implementation, and is a 'nested' open, since some tables might be already opened by the current thread. The thread context before this call is saved, and is restored when calling close_log_table().
thd | The current thread |
one_table | Log table to open |
backup | [out] Temporary storage used to save the thread context |
TABLE* open_n_lock_single_table | ( | THD * | thd, |
TABLE_LIST * | table_l, | ||
thr_lock_type | lock_type, | ||
uint | flags, | ||
Prelocking_strategy * | prelocking_strategy | ||
) |
Open and lock one table.
[in] | thd | thread handle |
[in] | table_l | table to open is first table in this list |
[in] | lock_type | lock to use for table |
[in] | flags | options to be used while opening and locking table (see open_table(), mysql_lock_tables()) |
[in] | prelocking_strategy | Strategy which specifies how prelocking algorithm should work for this statement. |
!= | NULL OK, opened table returned |
NULL | Error |
This function is meant as a replacement for open_ltable() when MERGE tables can be opened. open_ltable() cannot open MERGE tables.
There may be more differences between open_n_lock_single_table() and open_ltable(). One known difference is that open_ltable() does neither call thd->decide_logging_format() nor handle some other logging and locking issues because it does not call lock_tables().
bool open_normal_and_derived_tables | ( | THD * | thd, |
TABLE_LIST * | tables, | ||
uint | flags | ||
) |
Open all tables in list and process derived tables
thd | thread handler |
tables | list of tables for open |
flags | bitmap of flags to modify how the tables will be open: MYSQL_LOCK_IGNORE_FLUSH - open table even if someone has done a flush on it. |
false | - ok |
true | - error |
bool open_table | ( | THD * | thd, |
TABLE_LIST * | table_list, | ||
Open_table_context * | ot_ctx | ||
) |
Open a base table.
thd | Thread context. |
table_list | Open first table in list. |
ot_ctx | Context with flags which modify how open works and which is used to recover from a failed open_table() attempt. Some examples of flags: MYSQL_OPEN_IGNORE_FLUSH - Open table even if someone has done a flush. No version number checking is done. MYSQL_OPEN_HAS_MDL_LOCK - instead of acquiring metadata locks rely on that caller already has appropriate ones. |
Uses a cache of open tables to find a TABLE instance not in use.
If TABLE_LIST::open_strategy is set to OPEN_IF_EXISTS, the table is opened only if it exists. If the open strategy is OPEN_STUB, the underlying table is never opened. In both cases, metadata locks are always taken according to the lock strategy.
The function used to open temporary tables, but now it opens base tables only.
TRUE | Open failed. "action" parameter may contain type of action needed to remedy problem before retrying again. |
FALSE | Success. Members of TABLE_LIST structure are filled properly (e.g. TABLE_LIST::table is set for real tables and TABLE_LIST::view is set for views). |
Open_table_context::Open_table_context | ( | THD * | thd, |
uint | flags | ||
) |
TABLE* open_table_uncached | ( | THD * | thd, |
const char * | path, | ||
const char * | db, | ||
const char * | table_name, | ||
bool | add_to_temporary_tables_list, | ||
bool | open_in_engine | ||
) |
Open a single table without table caching and don't add it to THD::open_tables. Depending on the 'add_to_temporary_tables_list' value, the opened TABLE instance will be addded to THD::temporary_tables list.
thd | Thread context. |
path | Path (without .frm) |
db | Database name. |
table_name | Table name. |
add_to_temporary_tables_list | Specifies if the opened TABLE instance should be linked into THD::temporary_tables list. |
open_in_engine | Indicates that we need to open table in storage engine in addition to constructing TABLE object for it. |
NULL | on error. |
bool open_tables | ( | THD * | thd, |
TABLE_LIST ** | start, | ||
uint * | counter, | ||
uint | flags, | ||
Prelocking_strategy * | prelocking_strategy | ||
) |
Open all tables in list
[in] | thd | Thread context. |
[in,out] | start | List of tables to be open (it can be adjusted for statement that uses tables only implicitly, e.g. for "SELECT f1()"). |
[out] | counter | Number of tables which were open. |
[in] | flags | Bitmap of flags to modify how the tables will be open, see open_table() description for details. |
[in] | prelocking_strategy | Strategy which specifies how prelocking algorithm should work for this statement. |
If query for which we are opening tables is already marked as requiring prelocking it won't do such precaching and will simply reuse table list which is already built.
FALSE | Success. |
TRUE | Error, reported. |
bool open_temporary_table | ( | THD * | thd, |
TABLE_LIST * | tl | ||
) |
Find a temporary table specified by TABLE_LIST instance in the cache and prepare its TABLE instance for use.
This function tries to resolve this table in the list of temporary tables of this thread. Temporary tables are thread-local and "shadow" base tables with the same name.
FALSE | On success. If a temporary table exists for the given key, tl->table is set. |
TRUE | On error. my_error() has been called. |
bool open_temporary_tables | ( | THD * | thd, |
TABLE_LIST * | tl_list | ||
) |
Pre-open temporary tables corresponding to table list elements.
FALSE | On success. If a temporary tables exists for the given element, tl->table is set. |
TRUE | On error. my_error() has been called. |
Recover from failed attempt of open table by performing requested action.
FALSE | - Success. One should try to open tables once again. |
TRUE | - Error |
void release_table_share | ( | TABLE_SHARE * | share | ) |
Mark that we are not using table share anymore.
share | Table share |
If the share has no open tables and (we have done a refresh or if we have already too many open table shares) then delete the definition.
bool Open_table_context::request_backoff_action | ( | enum_open_table_action | action_arg, |
TABLE_LIST * | table | ||
) |
Check if we can back-off and set back off action if we can. Otherwise report and return error.
TRUE | if back-off is impossible. |
FALSE | if we can back off. Back off action has been set. |
bool rm_temporary_table | ( | handlerton * | base, |
const char * | path | ||
) |
Delete a temporary table.
base | Handlerton for table to be deleted. |
path | Path to the table to be deleted (i.e. path to its .frm without an extension). |
false | - success. |
true | - failure. |
bool setup_tables_and_check_access | ( | THD * | thd, |
Name_resolution_context * | context, | ||
List< TABLE_LIST > * | from_clause, | ||
TABLE_LIST * | tables, | ||
TABLE_LIST ** | leaves, | ||
bool | select_insert, | ||
ulong | want_access_first, | ||
ulong | want_access | ||
) |
Prepare tables and check access for the view tables.
thd | Thread context. |
context | Name resolution contest to setup table list there. |
from_clause | Top-level list of table references in the FROM clause. |
tables | Table list (select_lex->table_list). |
leaves[in/out] | List of join table leaves list (select_lex->leaf_tables). |
select_insert | It is SELECT ... INSERT command/ |
want_access_first | What access is requested of the first leaf. |
want_access | What access is requested on the rest of leaves. |
FALSE | - Success. |
TRUE | - Error. |
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.
bool tdc_open_view | ( | THD * | thd, |
TABLE_LIST * | table_list, | ||
const char * | alias, | ||
const char * | cache_key, | ||
uint | cache_key_length, | ||
uint | flags | ||
) |
Open view by getting its definition from disk (and table cache in future).
thd | Thread handle |
table_list | TABLE_LIST with db, table_name & belong_to_view |
alias | Alias name |
cache_key | Key for table definition cache |
cache_key_length | Length of cache_key |
flags | Flags which modify how we open the view |
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.
thd | Thread context |
remove_type | Type of removal: TDC_RT_REMOVE_ALL - remove all TABLE instances and TABLE_SHARE instance. There should be no used TABLE objects and caller should have exclusive metadata lock on the table. TDC_RT_REMOVE_NOT_OWN - remove all TABLE instances except those that belong to this thread. There should be no TABLE objects used by other threads and caller should have exclusive metadata lock on the table. TDC_RT_REMOVE_UNUSED - remove all unused TABLE instances (if there are no used instances will also remove TABLE_SHARE). TDC_RT_REMOVE_NOT_OWN_KEEP_SHARE - remove all TABLE instances except those that belong to this thread, but don't mark TABLE_SHARE as old. There should be no TABLE objects used by other threads and caller should have exclusive metadata lock on the table. |
db | Name of database |
table_name | Name of table |
has_lock | If TRUE, LOCK_open is already acquired |
TABLE_LIST* unique_table | ( | THD * | thd, |
TABLE_LIST * | table, | ||
TABLE_LIST * | 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.
For MyISAMMRG tables, it is assumed that all the underlying tables of table
(if any) are listed right after it and that their parent_l
field points at the main table.
non-NULL | The table list element for the table that represents the duplicate. |
NULL | No duplicates found. |
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.
thd | Thread handler |
table | Table to remove from cache |
function | HA_EXTRA_PREPARE_FOR_DROP if table is to be deleted HA_EXTRA_FORCE_REOPEN if table is not be used HA_EXTRA_PREPARE_FOR_RENAME if table is to be renamed |
FALSE | Success. |
TRUE | Failure (e.g. because thread was killed). |
mysql_mutex_t LOCK_open |
LOCK_open protects the following variables/objects:
1) The table_def_cache This is the hash table mapping table name to a table share object. The hash table can only be manipulated while holding LOCK_open. 2) last_table_id Generation of a new unique table_map_id for a table share is done through incrementing last_table_id, a global variable used for this purpose. 3) LOCK_open protects the initialisation of the table share object and all its members and also protects reading the .frm file from where the table share is initialised. 4) In particular the share->ref_count is updated each time a new table object is created that refers to a table share. This update is protected by LOCK_open. 5) oldest_unused_share, end_of_unused_share and share->next and share->prev are variables to handle the lists of table share objects, these can only be read and manipulated while holding the LOCK_open mutex. 6) table_def_shutdown_in_progress can be updated only while holding LOCK_open and ALL table cache mutexes. 7) refresh_version This variable can only be updated while holding LOCK_open AND all table cache mutexes. 8) share->version This variable is initialised while holding LOCK_open. It can only be updated while holding LOCK_open AND all table cache mutexes. So if a table share is found through a reference its version won't change if any of those mutexes are held. 9) share->m_flush_tickets