MySQL 8.0.31
Source Code Documentation
dd::cache::Storage_adapter Class Reference

Handling of access to persistent storage. More...

#include <storage_adapter.h>

Public Member Functions

template<typename T >
size_t core_size ()
 Get the number of core objects in a registry partition. More...
 
template<typename T >
Object_id core_get_id (const typename T::Name_key &key)
 Get a dictionary object id from core storage. More...
 
template<typename T >
void core_update (const T *)
 Update the dd object in the core registry. More...
 
void core_update (const dd::Tablespace *new_tsp)
 Overload of core_update for dd::Tablespace. More...
 
template<typename T >
void core_drop (THD *thd, const T *object)
 Drop a dictionary object from core storage. More...
 
template<typename T >
void core_store (THD *thd, T *object)
 Store a dictionary object to core storage. More...
 
template<typename T >
bool core_sync (THD *thd, const typename T::Name_key &key, const T *object)
 Sync a dictionary object from persistent to core storage. More...
 
void erase_all ()
 Remove and delete all elements and objects from core storage. More...
 
void dump ()
 Dump the contents of the core storage. More...
 
template<>
void core_get (const Table_stat::Name_key &, const Table_stat **)
 
template<>
void core_get (const Index_stat::Name_key &, const Index_stat **)
 
template<>
void core_drop (THD *, const Table_stat *)
 
template<>
void core_drop (THD *, const Index_stat *)
 
template<>
void core_store (THD *, Table_stat *)
 
template<>
void core_store (THD *, Index_stat *)
 

Static Public Member Functions

static Storage_adapterinstance ()
 
template<typename K , typename T >
static bool get (THD *thd, const K &key, enum_tx_isolation isolation, bool bypass_core_registry, const T **object)
 Get a dictionary object from persistent storage. More...
 
template<typename T >
static bool drop (THD *thd, const T *object)
 Drop a dictionary object from persistent storage. More...
 
template<typename T >
static bool store (THD *thd, T *object)
 Store a dictionary object to persistent storage. More...
 

Private Member Functions

template<typename T >
Object_id next_oid ()
 Generate a new object id for a registry partition. More...
 
template<typename K , typename T >
void core_get (const K &key, const T **object)
 Get a dictionary object from core storage. More...
 
 Storage_adapter ()
 
 ~Storage_adapter ()
 

Private Attributes

Object_registry m_core_registry
 
mysql_mutex_t m_lock
 

Static Private Attributes

static const Object_id FIRST_OID = 10001
 Use an id not starting at 1 to make it easy to recognize ids generated before objects are stored persistently. More...
 
static bool s_use_fake_storage = false
 

Friends

class dd_cache_unittest::CacheStorageTest
 

Detailed Description

Handling of access to persistent storage.

This class provides static template functions that manipulates an object on persistent storage based on the submitted key and object type. There is also an object registry instance to keep the core DD objects that are needed to handle cache misses for table meta data. The storage adapter owns the objects in the core registry. When adding objects to the registry using core_store(), the storage adapter will clone the object and take ownership of the clone. When retrieving objects from the registry using core_get(), a clone of the object will be returned, and this is therefore owned by the caller.

Constructor & Destructor Documentation

◆ Storage_adapter()

dd::cache::Storage_adapter::Storage_adapter ( )
inlineprivate

◆ ~Storage_adapter()

dd::cache::Storage_adapter::~Storage_adapter ( )
inlineprivate

Member Function Documentation

◆ core_drop() [1/3]

template<>
void dd::cache::Storage_adapter::core_drop ( THD ,
const Index_stat  
)

◆ core_drop() [2/3]

template<>
void dd::cache::Storage_adapter::core_drop ( THD ,
const Table_stat  
)

◆ core_drop() [3/3]

template<typename T >
void dd::cache::Storage_adapter::core_drop ( THD thd,
const T *  object 
)

Drop a dictionary object from core storage.

Template Parameters
TDictionary object type.
Parameters
thdThread context.
objectObject to be dropped.

◆ core_get() [1/3]

template<>
void dd::cache::Storage_adapter::core_get ( const Index_stat::Name_key ,
const Index_stat **   
)

◆ core_get() [2/3]

template<typename K , typename T >
template void dd::cache::Storage_adapter::core_get ( const K &  key,
const T **  object 
)
private

Get a dictionary object from core storage.

A clone of the registry object will be returned, owned by the caller.

Template Parameters
KKey type.
TDictionary object type.
Parameters
keyKey for which to get the object.
[out]objectObject retrieved, possibly nullptr if not present.

◆ core_get() [3/3]

template<>
void dd::cache::Storage_adapter::core_get ( const Table_stat::Name_key ,
const Table_stat **   
)

◆ core_get_id()

template<typename T >
template Object_id dd::cache::Storage_adapter::core_get_id< Tablespace > ( const typename T::Name_key &  key)

Get a dictionary object id from core storage.

Template Parameters
TDictionary object type.
Parameters
keyName key for which to get the object id.
Returns
Object id, INVALID_OBJECT_ID if the object is not present.

◆ core_size()

template<typename T >
template size_t dd::cache::Storage_adapter::core_size< Tablespace > ( )

Get the number of core objects in a registry partition.

Template Parameters
TDictionary object type.
Returns
Number of elements.

◆ core_store() [1/3]

template<>
void dd::cache::Storage_adapter::core_store ( THD ,
Index_stat  
)

◆ core_store() [2/3]

template<>
void dd::cache::Storage_adapter::core_store ( THD ,
Table_stat  
)

◆ core_store() [3/3]

template<typename T >
void dd::cache::Storage_adapter::core_store ( THD thd,
T *  object 
)

Store a dictionary object to core storage.

A clone of the submitted object will be added to the core storage. The caller is still the owner of the submitted objecct.

Template Parameters
TDictionary object type.
Parameters
thdThread context.
objectObject to be stored.

◆ core_sync()

template<typename T >
template bool dd::cache::Storage_adapter::core_sync ( THD thd,
const typename T::Name_key &  key,
const T *  object 
)

Sync a dictionary object from persistent to core storage.

Template Parameters
TDictionary object type.
Parameters
thdThread context.
keyKey for object to get from persistent storage.
objectObject to drop from the core registry.

◆ core_update() [1/2]

void dd::cache::Storage_adapter::core_update ( const dd::Tablespace new_tsp)

Overload of core_update for dd::Tablespace.

Currently the core registry can only be updated for the DD tablespace when encrypting it. A clone of the dd::Tablespace object passed in is stored in the registry.

Parameters
new_tspthe new dd::Tablespace object to keep in the core registry.

◆ core_update() [2/2]

template<typename T >
void dd::cache::Storage_adapter::core_update ( const T *  )
inline

Update the dd object in the core registry.

This is a noop unless this member function is overloaded for a given type. See below.

◆ drop()

template<typename T >
template bool dd::cache::Storage_adapter::drop ( THD thd,
const T *  object 
)
static

Drop a dictionary object from persistent storage.

Template Parameters
TDictionary object type.
Parameters
thdThread context.
objectObject to be dropped.
Return values
falseNo error.
trueError.

◆ dump()

void dd::cache::Storage_adapter::dump ( )

Dump the contents of the core storage.

◆ erase_all()

void dd::cache::Storage_adapter::erase_all ( )

Remove and delete all elements and objects from core storage.

◆ get()

template<typename K , typename T >
bool dd::cache::Storage_adapter::get ( THD thd,
const K &  key,
enum_tx_isolation  isolation,
bool  bypass_core_registry,
const T **  object 
)
static

Get a dictionary object from persistent storage.

Create an access key based on the submitted key, and find the record from the appropriate table. Restore the record into a new dictionary object.

Template Parameters
KKey type.
TDictionary object type.
Parameters
thdThread context.
keyKey for which to get the object.
isolationIsolation level.
bypass_core_registryIf set to true, get the object from the DD tables. Needed during DD bootstrap.
[out]objectObject retrieved, possibly NULL if not present.
Return values
falseNo error.
trueError.

◆ instance()

Storage_adapter * dd::cache::Storage_adapter::instance ( )
static

◆ next_oid()

template<typename T >
template Object_id dd::cache::Storage_adapter::next_oid< Tablespace > ( )
private

Generate a new object id for a registry partition.

Simulate an auto increment column. Used when the server is starting, while the scaffolding is being built.

Template Parameters
TObject registry partition.
Returns
Next object id to be used.

◆ store()

template<typename T >
template bool dd::cache::Storage_adapter::store ( THD thd,
T *  object 
)
static

Store a dictionary object to persistent storage.

Template Parameters
TDictionary object type.
Parameters
thdThread context.
objectObject to be stored.
Return values
falseNo error.
trueError.

Friends And Related Function Documentation

◆ dd_cache_unittest::CacheStorageTest

friend class dd_cache_unittest::CacheStorageTest
friend

Member Data Documentation

◆ FIRST_OID

const Object_id dd::cache::Storage_adapter::FIRST_OID = 10001
staticprivate

Use an id not starting at 1 to make it easy to recognize ids generated before objects are stored persistently.

◆ m_core_registry

Object_registry dd::cache::Storage_adapter::m_core_registry
private

◆ m_lock

mysql_mutex_t dd::cache::Storage_adapter::m_lock
private

◆ s_use_fake_storage

bool dd::cache::Storage_adapter::s_use_fake_storage = false
staticprivate

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