MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Table_cache Class Reference

#include <table_cache.h>

Public Member Functions

bool init ()
void destroy ()
void lock ()
void unlock ()
void assert_owner ()
TABLEget_table (THD *thd, my_hash_value_type hash_value, const char *key, uint key_length, TABLE_SHARE **share)
void release_table (THD *thd, TABLE *table)
bool add_used_table (THD *thd, TABLE *table)
void remove_table (TABLE *table)
uint cached_tables () const
void free_all_unused_tables ()
void print_tables ()

Static Public Member Functions

static void init_psi_keys ()

Detailed Description

Cache for open TABLE objects.

The idea behind this cache is that most statements don't need to go to a central table definition cache to get a TABLE object and therefore don't need to lock LOCK_open mutex. Instead they only need to go to one Table_cache instance (the specific instance is determined by thread id) and only lock the mutex protecting this cache. DDL statements that need to remove all TABLE objects from all caches need to lock mutexes for all Table_cache instances, but they are rare.

This significantly increases scalability in some scenarios.

Definition at line 38 of file table_cache.h.

Member Function Documentation

bool Table_cache::add_used_table ( THD *  thd,
TABLE table 
)
inline

Add newly created TABLE object which is going to be used right away to the table cache.

Note
Caller should own lock on the table cache.
Sets TABLE::in_use member as side effect.
Return values
false- success.
true- failure.

Definition at line 346 of file table_cache.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void Table_cache::assert_owner ( )
inline

Assert that caller owns lock on the table cache.

Definition at line 119 of file table_cache.h.

Here is the caller graph for this function:

uint Table_cache::cached_tables ( ) const
inline

Get number of TABLE instances in the cache.

Definition at line 131 of file table_cache.h.

void Table_cache::destroy ( )

Destroy instance of table cache.

Definition at line 77 of file table_cache.cc.

void Table_cache::free_all_unused_tables ( )

Free all unused TABLE objects in the table cache.

Definition at line 151 of file table_cache.cc.

Here is the call graph for this function:

TABLE * Table_cache::get_table ( THD *  thd,
my_hash_value_type  hash_value,
const char *  key,
uint  key_length,
TABLE_SHARE **  share 
)
inline

Get an unused TABLE instance from the table cache.

Parameters
thdThread context.
hash_valueHash value for the key identifying table.
keyKey identifying table.
key_lengthLength of key for the table.
[out]shareNULL - if table cache doesn't contain any information about the table (i.e. doesn't have neither used nor unused TABLE objects for it). Pointer to TABLE_SHARE for the table otherwise.
Note
Caller should own lock on the table cache.
Sets TABLE::in_use member as side effect.
Return values
non-NULL- pointer to unused TABLE object, "share" out-parameter contains pointer to TABLE_SHARE for this table.
NULL- no unused TABLE object was found, "share" parameter contains pointer to TABLE_SHARE for this table if there are used TABLE objects in cache and NULL otherwise.

Definition at line 461 of file table_cache.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Table_cache::init ( void  )

Initialize instance of table cache.

Return values
false- success.
true- failure.

Definition at line 57 of file table_cache.cc.

void Table_cache::init_psi_keys ( )
static

Init P_S instrumentation key for mutex protecting Table_cache instance.

Definition at line 86 of file table_cache.cc.

Here is the caller graph for this function:

void Table_cache::lock ( void  )
inline

Acquire lock on table cache instance.

Definition at line 115 of file table_cache.h.

Here is the caller graph for this function:

void Table_cache::print_tables ( )

Print debug information for the contents of the table cache.

Definition at line 169 of file table_cache.cc.

void Table_cache::release_table ( THD *  thd,
TABLE table 
)
inline

Put used TABLE instance back to the table cache and mark it as unused.

Note
Caller should own lock on the table cache.
Sets TABLE::in_use member as side effect.

Definition at line 516 of file table_cache.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void Table_cache::remove_table ( TABLE table)
inline

Prepare used or unused TABLE instance for destruction by removing it from the table cache.

Note
Caller should own lock on the table cache.

Definition at line 404 of file table_cache.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void Table_cache::unlock ( void  )
inline

Release lock on table cache instance.

Definition at line 117 of file table_cache.h.

Here is the caller graph for this function:


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