MySQL 8.4.0
Source Code Documentation
dd::cache::Dictionary_client Class Reference

#include <dictionary_client.h>

Classes

class  Auto_releaser
 Class to help releasing and deleting objects. More...
 

Public Member Functions

 Dictionary_client (THD *thd)
 
 ~Dictionary_client ()
 
template<typename T >
bool acquire (Object_id id, const T **object)
 Retrieve an object by its object id. More...
 
template<typename T >
bool acquire_for_modification (Object_id id, T **object)
 Retrieve an object by its object id. More...
 
template<typename T >
bool acquire_uncached (Object_id id, T **object)
 Retrieve an object by its object id without caching it. More...
 
template<typename T >
bool acquire_uncached (Object_id id, std::unique_ptr< T > *object_ptr)
 Retrieve an object by its object id without caching it. More...
 
template<typename T >
bool acquire_uncached_uncommitted (Object_id id, T **object)
 Retrieve a possibly uncommitted object by its object id without caching it. More...
 
template<typename T >
bool acquire_uncached_uncommitted (Object_id id, std::unique_ptr< T > *object_ptr)
 Retrieve a possibly uncommitted object by its object id without caching it. More...
 
template<typename T >
bool acquire (const String_type &object_name, const T **object)
 Retrieve an object by its name. More...
 
template<typename T >
bool acquire_for_modification (const String_type &object_name, T **object)
 Retrieve an object by its name. More...
 
template<typename T >
bool acquire (const String_type &schema_name, const String_type &object_name, const T **object)
 Retrieve an object by its schema- and object name. More...
 
template<typename T >
bool acquire_for_modification (const String_type &schema_name, const String_type &object_name, T **object)
 Retrieve an object by its schema- and object name. More...
 
template<typename T >
bool acquire (const String_type &schema_name, const String_type &object_name, const typename T::Cache_partition **object)
 Retrieve an object by its schema- and object name. More...
 
template<typename T >
bool acquire_for_modification (const String_type &schema_name, const String_type &object_name, typename T::Cache_partition **object)
 Retrieve an object by its schema- and object name. More...
 
bool acquire_uncached_table_by_se_private_id (const String_type &engine, Object_id se_private_id, Table **table, bool skip_spi_cache=false)
 Retrieve a table object by its se private id. More...
 
bool acquire_uncached_table_by_partition_se_private_id (const String_type &engine, Object_id se_partition_id, Table **table)
 Retrieve a table object by its partition se private id. More...
 
bool get_table_name_by_se_private_id (const String_type &engine, Object_id se_private_id, String_type *schema_name, String_type *table_name)
 Retrieve schema and table name by the se private id of the table. More...
 
bool get_table_name_by_partition_se_private_id (const String_type &engine, Object_id se_partition_id, String_type *schema_name, String_type *table_name)
 Retrieve schema and table name by the se private id of the partition. More...
 
bool get_table_name_by_trigger_name (const Schema &schema, const String_type &trigger_name, String_type *table_name)
 Retrieve a table name of a given trigger name and schema. More...
 
bool check_foreign_key_exists (const Schema &schema, const String_type &foreign_key_name, bool *exists)
 Check if schema contains foreign key with specified name. More...
 
bool check_constraint_exists (const Schema &schema, const String_type &check_cons_name, bool *exists)
 Check if schema contains check constraint with specified name. More...
 
template<typename T >
bool fetch_schema_component_names (const Schema *schema, std::vector< String_type > *names) const
 Fetch the names of the components in the schema. More...
 
bool fetch_schema_table_names_by_engine (const Schema *schema, const String_type &engine, std::vector< String_type > *names) const
 Fetch the names of the tables in the schema belonging to specific storage engine. More...
 
bool fetch_schema_table_names_not_hidden_by_se (const Schema *schema, std::vector< String_type > *names) const
 Fetch the names of the server tables in the schema. More...
 
template<typename T >
bool fetch_global_component_ids (std::vector< Object_id > *ids) const
 Fetch all global component ids of the given type. More...
 
template<typename T >
bool fetch_global_component_names (std::vector< String_type > *names) const
 Fetch all global component names of the given type. More...
 
template<typename Object_type >
bool foreach (const Object_key *object_key, std::function< bool(std::unique_ptr< Object_type > &)> const &processor) const
 Execute the submitted lambda function for each entity of the given type selected by the submitted key. More...
 
template<typename T >
bool fetch_schema_components (const Schema *schema, Const_ptr_vec< T > *coll)
 Fetch all components in the schema. More...
 
template<typename T >
bool fetch_global_components (Const_ptr_vec< T > *coll)
 Fetch all global components of the given type. More...
 
template<typename T >
bool is_user_definer (const LEX_USER &user, bool *is_definer) const
 Check if a user is referenced as definer by some object of the given type. More...
 
template<typename T >
bool fetch_referencing_views_object_id (const char *schema, const char *tbl_or_sf_name, std::vector< Object_id > *view_ids) const
 Fetch Object ids of all the views referencing base table/ view/ stored function name specified in "schema". More...
 
bool fetch_fk_children_uncached (const String_type &parent_schema, const String_type &parent_name, const String_type &parent_engine, bool uncommitted, std::vector< String_type > *children_schemas, std::vector< String_type > *children_names)
 Fetch the names of tables (children) which have foreign keys defined to the given table (parent). More...
 
bool invalidate (const String_type &schema_name, const String_type &table_name)
 Invalidate a cache entry. More...
 
template<typename T >
void invalidate (const T *object)
 Invalidate a cache entry. More...
 
template<typename T >
bool drop (const T *object)
 Remove and delete an object from the cache and the dd tables. More...
 
template<typename T >
bool store (T *object)
 Store a new dictionary object. More...
 
template<typename T >
bool update (T *new_object)
 Update a persisted dictionary object, but keep the shared cache unchanged. More...
 
void rollback_modified_objects ()
 Remove the uncommitted objects from the client. More...
 
void commit_modified_objects ()
 Remove the uncommitted objects from the client and put them into the shared cache, thereby making them visible to other clients. More...
 
bool remove_table_dynamic_statistics (const String_type &schema_name, const String_type &table_name)
 Remove table statistics entries from mysql.table_stats and mysql.index_stats. More...
 
template<typename T >
void dump () const
 Debug dump of a partition of the client and its registry to stderr. More...
 
template<>
bool fetch_schema_component_names (const Schema *schema, std::vector< String_type > *names) const
 
template<>
bool fetch_schema_component_names (const Schema *schema, std::vector< String_type > *names) const
 
template<>
bool fetch_schema_component_names (const Schema *schema, std::vector< String_type > *names) const
 
template<>
bool store (Table_stat *object)
 
template<>
bool store (Index_stat *object)
 

Private Types

template<typename T >
using Const_ptr_vec = std::vector< const T * >
 

Private Member Functions

template<typename K , typename T >
bool acquire (const K &key, const T **object, bool *local_committed, bool *local_uncommitted)
 Get a dictionary object. More...
 
template<typename K , typename T >
void acquire_uncommitted (const K &key, T **object, bool *dropped)
 Get an uncommitted dictionary object that can be modified safely. More...
 
template<typename T >
size_t release (Object_registry *registry)
 Mark all objects of a certain type as not being used by this client. More...
 
size_t release (Object_registry *registry)
 Release all objects in the submitted object registry. More...
 
template<typename T >
void auto_delete (T *object)
 Register an uncached object to be auto deleted. More...
 
template<typename T >
void no_auto_delete (T *object)
 Remove an object from the auto delete vector. More...
 
template<typename T >
void register_uncommitted_object (T *object)
 Transfer object ownership from caller to Dictionary_client, and register the object as uncommitted. More...
 
template<typename T >
void register_dropped_object (T *object)
 Transfer object ownership from caller to Dictionary_client, and register the object as dropped. More...
 
template<typename T >
void remove_uncommitted_objects (bool commit_to_shared_cache)
 Remove the uncommitted objects from the client and (depending on the parameter) put them into the shared cache, thereby making them visible to other clients. More...
 
template<typename Object_type >
bool fetch (Const_ptr_vec< Object_type > *coll, const Object_key *object_key)
 Fetch objects from DD tables that match the supplied key. More...
 
template<typename T >
bool acquire_uncached_impl (Object_id id, T **object)
 Auxiliary function to retrieve an object by its object id without caching it.It is responsibility of the caller to delete the retrieved object. More...
 
template<typename T >
bool acquire_uncached_uncommitted_impl (Object_id id, T **object)
 Auxiliary function to retrieve a possibly uncommitted object by its object id without caching it. More...
 

Private Attributes

std::vector< Entity_object * > m_uncached_objects
 
Object_registry m_registry_committed
 
Object_registry m_registry_uncommitted
 
Object_registry m_registry_dropped
 
THDm_thd
 
Auto_releaser m_default_releaser
 
Auto_releaserm_current_releaser
 
SPI_lru_cache_owner_ptr m_no_table_spids
 Se-private ids known not to exist in either TABLES or PARTITIONS or both. More...
 

Member Typedef Documentation

◆ Const_ptr_vec

template<typename T >
using dd::cache::Dictionary_client::Const_ptr_vec = std::vector<const T *>
private

Constructor & Destructor Documentation

◆ Dictionary_client()

dd::cache::Dictionary_client::Dictionary_client ( THD thd)
explicit

◆ ~Dictionary_client()

dd::cache::Dictionary_client::~Dictionary_client ( )

Member Function Documentation

◆ acquire() [1/5]

template<typename K , typename T >
bool dd::cache::Dictionary_client::acquire ( const K &  key,
const T **  object,
bool *  local_committed,
bool *  local_uncommitted 
)
private

Get a dictionary object.

The operation retrieves a dictionary object by one of its keys from the cache and returns it through the object parameter. If the object is already present in the client's local object registry, it is fetched from there. Otherwise, it is fetched from the shared cache (possibly involving a cache miss), and eventually added to the local object registry.

If no object is found for the given key, NULL is returned. The shared cache owns the returned object, i.e., the caller must not delete it. After using the object(s), the user must release it using one of the release mechanisms described earlier.

The reference counter for the object is incremented if the object is retrieved from the shared cache. If the object was present in the local registry, the reference counter stays the same. A cache miss is handled transparently by the shared cache.

Note
This function must be called with type T being the same as T::Cache_partition. Dynamic casting to the actual subtype must be done at an outer level.
Template Parameters
KKey type.
TDictionary object type.
Parameters
keyKey to use for looking up the object.
[out]objectObject pointer, if an object exists, otherwise NULL.
[out]local_committedWhether the object was read from the local committed object registry.
[out]local_uncommittedWhether the object was read from the local uncommitted registry.
Return values
falseNo error.
trueError (from handling a cache miss).

◆ acquire() [2/5]

template<typename T >
bool dd::cache::Dictionary_client::acquire ( const String_type object_name,
const T **  object 
)

Retrieve an object by its name.

Template Parameters
TDictionary object type.
Parameters
object_nameName of the object.
[out]objectDictionary object, if present; otherwise NULL.
Return values
falseNo error.
trueError (from handling a cache miss).

◆ acquire() [3/5]

template<typename T >
bool dd::cache::Dictionary_client::acquire ( const String_type schema_name,
const String_type object_name,
const T **  object 
)

Retrieve an object by its schema- and object name.

Note
We will acquire an IX-lock on the schema name unless we already have one. This is needed for proper synchronization with schema DDL in cases where the table does not exist, and where the indirect synchronization based on table names therefore will not apply.
Template Parameters
TDictionary object type.
Parameters
schema_nameName of the schema containing the object.
object_nameName of the object.
[out]objectDictionary object, if present; otherwise NULL.
Return values
falseNo error.
trueError (from handling a cache miss, or from failing to get an MDL lock).

◆ acquire() [4/5]

template<typename T >
bool dd::cache::Dictionary_client::acquire ( const String_type schema_name,
const String_type object_name,
const typename T::Cache_partition **  object 
)

Retrieve an object by its schema- and object name.

Note
We will acquire an IX-lock on the schema name unless we already have one. This is needed for proper synchronization with schema DDL in cases where the table does not exist, and where the indirect synchronization based on table names therefore will not apply.
This is a variant of the method above asking for an object of type T, and hence using T's functions for updating name keys etc. This function, however, returns the instance pointed to as type T::Cache_partition to ease handling of various subtypes of the same base type.
Template Parameters
TDictionary object type.
Parameters
schema_nameName of the schema containing the object.
object_nameName of the object.
[out]objectDictionary object, if present; otherwise NULL.
Return values
falseNo error.
trueError (from handling a cache miss, or from failing to get an MDL lock).

◆ acquire() [5/5]

template<typename T >
bool dd::cache::Dictionary_client::acquire ( Object_id  id,
const T **  object 
)

Retrieve an object by its object id.

Template Parameters
TDictionary object type.
Parameters
idObject id to retrieve.
[out]objectDictionary object, if present; otherwise NULL.
Return values
falseNo error.
trueError (from handling a cache miss).

◆ acquire_for_modification() [1/4]

template<typename T >
bool dd::cache::Dictionary_client::acquire_for_modification ( const String_type object_name,
T **  object 
)

Retrieve an object by its name.

This function returns a cloned object that can be modified.

Template Parameters
TDictionary object type.
Parameters
object_nameName of the object.
[out]objectDictionary object, if present; otherwise NULL.
Return values
falseNo error.
trueError (from handling a cache miss).

◆ acquire_for_modification() [2/4]

template<typename T >
bool dd::cache::Dictionary_client::acquire_for_modification ( const String_type schema_name,
const String_type object_name,
T **  object 
)

Retrieve an object by its schema- and object name.

This function returns a cloned object that can be modified.

Note
We will acquire an IX-lock on the schema name unless we already have one. This is needed for proper synchronization with schema DDL in cases where the table does not exist, and where the indirect synchronization based on table names therefore will not apply.
Template Parameters
TDictionary object type.
Parameters
schema_nameName of the schema containing the object.
object_nameName of the object.
[out]objectDictionary object, if present; otherwise NULL.
Return values
falseNo error.
trueError (from handling a cache miss, or from failing to get an MDL lock).

◆ acquire_for_modification() [3/4]

template<typename T >
bool dd::cache::Dictionary_client::acquire_for_modification ( const String_type schema_name,
const String_type object_name,
typename T::Cache_partition **  object 
)

Retrieve an object by its schema- and object name.

This function returns a cloned object that can be modified.

Note
We will acquire an IX-lock on the schema name unless we already have one. This is needed for proper synchronization with schema DDL in cases where the table does not exist, and where the indirect synchronization based on table names therefore will not apply.
This is a variant of the method above asking for an object of type T, and hence using T's functions for updating name keys etc. This function, however, returns the instance pointed to as type T::Cache_partition to ease handling of various subtypes of the same base type.
Template Parameters
TDictionary object type.
Parameters
schema_nameName of the schema containing the object.
object_nameName of the object.
[out]objectDictionary object, if present; otherwise NULL.
Return values
falseNo error.
trueError (from handling a cache miss, or from failing to get an MDL lock).

◆ acquire_for_modification() [4/4]

template<typename T >
bool dd::cache::Dictionary_client::acquire_for_modification ( Object_id  id,
T **  object 
)

Retrieve an object by its object id.

This function returns a cloned object that can be modified.

Template Parameters
TDictionary object type.
Parameters
idObject id to retrieve.
[out]objectDictionary object, if present; otherwise NULL.
Return values
falseNo error.
trueError (from handling a cache miss).

◆ acquire_uncached() [1/2]

template<typename T >
bool dd::cache::Dictionary_client::acquire_uncached ( Object_id  id,
std::unique_ptr< T > *  object_ptr 
)

Retrieve an object by its object id without caching it.

The object is not cached and owned by the caller through unique_ptr it provides. The object may not be used as a parameter to the other dictionary client methods since it is not known by the object registry.

Template Parameters
TDictionary object type.
Parameters
idObject id to retrieve.
[out]object_ptrSmart pointer with dictionary object, if present or with nullptr otherwise.
Return values
falseNo error.
trueError (from reading the dictionary tables).

◆ acquire_uncached() [2/2]

template<typename T >
bool dd::cache::Dictionary_client::acquire_uncached ( Object_id  id,
T **  object 
)

Retrieve an object by its object id without caching it.

The object is not cached but owned by the dictionary client, who makes sure it is deleted. The object must not be released, and may not be used as a parameter to the other dictionary client methods since it is not known by the object registry.

Template Parameters
TDictionary object type.
Parameters
idObject id to retrieve.
[out]objectDictionary object, if present; otherwise NULL.
Return values
falseNo error.
trueError (from reading the dictionary tables).

◆ acquire_uncached_impl()

template<typename T >
bool dd::cache::Dictionary_client::acquire_uncached_impl ( Object_id  id,
T **  object 
)
private

Auxiliary function to retrieve an object by its object id without caching it.It is responsibility of the caller to delete the retrieved object.

◆ acquire_uncached_table_by_partition_se_private_id()

bool dd::cache::Dictionary_client::acquire_uncached_table_by_partition_se_private_id ( const String_type engine,
Object_id  se_partition_id,
Table **  table 
)

Retrieve a table object by its partition se private id.

Parameters
engineName of the engine storing the table.
se_partition_idSE private id of the partition.
[out]tableTable object, if present; otherwise NULL.
Return values
falseNo error or if object was not found.
trueError (from handling a cache miss).

◆ acquire_uncached_table_by_se_private_id()

bool dd::cache::Dictionary_client::acquire_uncached_table_by_se_private_id ( const String_type engine,
Object_id  se_private_id,
Table **  table,
bool  skip_spi_cache = false 
)

Retrieve a table object by its se private id.

Parameters
engineName of the engine storing the table.
se_private_idSE private id of the table.
[out]tableTable object, if present; otherwise NULL.
skip_spi_cacheOptionally skip looking into the missing SE private ID cache. Defaults to false.
Note
The object must be acquired uncached since we cannot acquire a metadata lock in advance since we do not know the table name. Thus, the returned table object is owned by the caller, who must make sure it is deleted.
Return values
falseNo error or if object was not found.
trueError (e.g. from reading DD tables, or if an object of a wrong type was found).

◆ acquire_uncached_uncommitted() [1/2]

template<typename T >
bool dd::cache::Dictionary_client::acquire_uncached_uncommitted ( Object_id  id,
std::unique_ptr< T > *  object_ptr 
)

Retrieve a possibly uncommitted object by its object id without caching it.

The object is not cached and owned by the caller through unique_ptr it provides. The object may not be used as a parameter to the other dictionary client methods since it is not known by the object registry.

When the object is read from the persistent tables, the transaction isolation level is READ UNCOMMITTED. This is necessary to be able to read uncommitted data from an earlier stage of the same session.

Template Parameters
TDictionary object type.
Parameters
idObject id to retrieve.
[out]object_ptrSmart pointer with dictionary object, if present or with nullptr otherwise.
Return values
falseNo error.
trueError (from reading the dictionary tables).

◆ acquire_uncached_uncommitted() [2/2]

template<typename T >
bool dd::cache::Dictionary_client::acquire_uncached_uncommitted ( Object_id  id,
T **  object 
)

Retrieve a possibly uncommitted object by its object id without caching it.

The object is not cached but owned by the dictionary client, who makes sure it is deleted. The object must not be released, and may not be used as a parameter to the other dictionary client methods since it is not known by the object registry.

When the object is read from the persistent tables, the transaction isolation level is READ UNCOMMITTED. This is necessary to be able to read uncommitted data from an earlier stage of the same session.

Template Parameters
TDictionary object type.
Parameters
idObject id to retrieve.
[out]objectDictionary object, if present; otherwise nullptr.
Return values
falseNo error.
trueError (from reading the dictionary tables).

◆ acquire_uncached_uncommitted_impl()

template<typename T >
bool dd::cache::Dictionary_client::acquire_uncached_uncommitted_impl ( Object_id  id,
T **  object 
)
private

Auxiliary function to retrieve a possibly uncommitted object by its object id without caching it.

It is responsibility of the caller to delete the retrieved object.

◆ acquire_uncommitted()

template<typename K , typename T >
void dd::cache::Dictionary_client::acquire_uncommitted ( const K &  key,
T **  object,
bool *  dropped 
)
private

Get an uncommitted dictionary object that can be modified safely.

The difference between this method and acquire(), is that this method only looks in the local registry of uncommitted objects. That is, object created by acquire_for_modification() or registered with register_uncommitted_object(). It will not access the shared cache. Objects that have been dropped are returned as nullptr, but with the value of the parameter 'dropped' set to 'true'.

Template Parameters
KKey type.
TDictionary object type.
Parameters
keyKey to use for looking up the object.
[out]objectObject pointer, if an object exists, otherwise NULL.
[out]droppedObject exists, but has been dropped and has not yet committed. In this case, 'object' is set to nullptr.

◆ auto_delete()

template<typename T >
void dd::cache::Dictionary_client::auto_delete ( T *  object)
inlineprivate

Register an uncached object to be auto deleted.

Template Parameters
TDictionary object type.
Parameters
objectDictionary object to auto delete.

◆ check_constraint_exists()

bool dd::cache::Dictionary_client::check_constraint_exists ( const Schema schema,
const String_type check_cons_name,
bool *  exists 
)

Check if schema contains check constraint with specified name.

Parameters
schemaSchema containing the check constraint.
check_cons_nameName of the check constraint.
[out]existsSet to true if check constraint with the name provided exists in the schema, false otherwise.
Return values
falseNo error.
trueError.

◆ check_foreign_key_exists()

bool dd::cache::Dictionary_client::check_foreign_key_exists ( const Schema schema,
const String_type foreign_key_name,
bool *  exists 
)

Check if schema contains foreign key with specified name.

Parameters
schemaSchema containing the foreign key.
foreign_key_nameName of the foreign key.
[out]existsSet to true if foreign key with the name provided exists in the schema, false otherwise.
Return values
falseNo error.
trueError.

◆ commit_modified_objects()

void dd::cache::Dictionary_client::commit_modified_objects ( )

Remove the uncommitted objects from the client and put them into the shared cache, thereby making them visible to other clients.

Should be called after commit to disk but before metadata locks are released.

◆ drop()

template<typename T >
bool dd::cache::Dictionary_client::drop ( const T *  object)

Remove and delete an object from the cache and the dd tables.

This function will remove the object from the local registry as well as the shared cache. This means that all keys associated with the object will be removed from the maps, and the cache element wrapper will be deleted. Afterwards, the object pointed to will also be deleted, and finally, the corresponding entry in the appropriate dd table is deleted. The object may not be accessed after calling this function.

See also
invalidate()
Note
The object parameter is const since the contents of the object is not really changed, the object is just deleted. The method makes sure there is an exclusive meta data lock on the object name.
The argument to this function may come from acquire(), and may be an instance that is present in the uncommitted registry, or in the committed registry. These use cases are handled by the implementation of the function. The ownership of the 'object' is not changed, instead, a clone is created and added to the dropped registry.
Template Parameters
TDictionary object type.
Parameters
objectObject to be dropped.
Return values
falseThe operation was successful.
trueThere was an error.

◆ dump()

template<typename T >
void dd::cache::Dictionary_client::dump

Debug dump of a partition of the client and its registry to stderr.

Template Parameters
TDictionary object type.

◆ fetch()

template<typename Object_type >
bool dd::cache::Dictionary_client::fetch ( Const_ptr_vec< Object_type > *  coll,
const Object_key object_key 
)
private

Fetch objects from DD tables that match the supplied key.

Template Parameters
Object_typeType of object to fetch.
Parameters
collVector to fill with objects.
object_keyThe search key. If key is not supplied, then we do full index scan.
Returns
false Success.
true Failure (error is reported).

◆ fetch_fk_children_uncached()

bool dd::cache::Dictionary_client::fetch_fk_children_uncached ( const String_type parent_schema,
const String_type parent_name,
const String_type parent_engine,
bool  uncommitted,
std::vector< String_type > *  children_schemas,
std::vector< String_type > *  children_names 
)

Fetch the names of tables (children) which have foreign keys defined to the given table (parent).

Parameters
parent_schemaSchema name of parent table.
parent_nameTable name of parent table.
parent_engineStorage engine of parent table.
uncommittedUse READ_UNCOMMITTED isolation.
[out]children_schemasSchema names of child tables.
[out]children_namesTable names of child tables.
Returns
true Failure (error is reported).
false Success.
Note
Child tables are identified by matching pairs of names.
This is a temporary workaround until WL#6049. This function will not* take any locks protecting against DDL changes. So the returned names could become invalid at any time - e.g. due to DROP DATABASE, DROP TABLE or DROP FOREIGN KEY.

◆ fetch_global_component_ids()

template<typename T >
bool dd::cache::Dictionary_client::fetch_global_component_ids ( std::vector< Object_id > *  ids) const

Fetch all global component ids of the given type.

Template Parameters
TType of components to get.
Parameters
[out]idsAn std::vector containing all component ids.
Returns
true Failure (error is reported).
false Success.

◆ fetch_global_component_names()

template<typename T >
bool dd::cache::Dictionary_client::fetch_global_component_names ( std::vector< String_type > *  names) const

Fetch all global component names of the given type.

Template Parameters
TType of components to get.
Parameters
[out]namesAn std::vector containing all component names.
Returns
true Failure (error is reported).
false Success.

◆ fetch_global_components()

template<typename T >
bool dd::cache::Dictionary_client::fetch_global_components ( Const_ptr_vec< T > *  coll)

Fetch all global components of the given type.

Template Parameters
TType of components to get.
Parameters
[out]collAn std::vector containing all components.
Returns
true Failure (error is reported).
false Success.

◆ fetch_referencing_views_object_id()

template<typename T >
bool dd::cache::Dictionary_client::fetch_referencing_views_object_id ( const char *  schema,
const char *  tbl_or_sf_name,
std::vector< Object_id > *  view_ids 
) const

Fetch Object ids of all the views referencing base table/ view/ stored function name specified in "schema".

"name". The views are retrieved using READ_UNCOMMITTED reads as the views could be changed by the same statement (e.g. multi-table/-view RENAME TABLE).

Template Parameters
TType of the object (View_table/View_routine) to retrieve view names for.
Parameters
schemaSchema name.
tbl_or_sf_nameBase table/ View/ Stored function name.
[out]view_idsVector to store Object ids of all the views referencing schema.name.
Returns
true Failure (error is reported).
false Success.

◆ fetch_schema_component_names() [1/4]

template<typename T >
bool dd::cache::Dictionary_client::fetch_schema_component_names ( const Schema schema,
std::vector< String_type > *  names 
) const

Fetch the names of the components in the schema.

Hidden components are ignored. E.g., Object with dd::Table::hidden() == true will be ignored.

Template Parameters
TType of object to retrieve names for.
Parameters
schemaSchema for which to get component names.
[out]namesAn std::vector containing all object names.
Returns
true Failure (error is reported).
false Success.

◆ fetch_schema_component_names() [2/4]

template<>
bool dd::cache::Dictionary_client::fetch_schema_component_names ( const Schema schema,
std::vector< String_type > *  names 
) const

◆ fetch_schema_component_names() [3/4]

template<>
bool dd::cache::Dictionary_client::fetch_schema_component_names ( const Schema schema,
std::vector< String_type > *  names 
) const

◆ fetch_schema_component_names() [4/4]

template<>
bool dd::cache::Dictionary_client::fetch_schema_component_names ( const Schema schema,
std::vector< String_type > *  names 
) const

◆ fetch_schema_components()

template<typename T >
bool dd::cache::Dictionary_client::fetch_schema_components ( const Schema schema,
Const_ptr_vec< T > *  coll 
)

Fetch all components in the schema.

Template Parameters
TType of components to get.
Parameters
schemaSchema for which to get components.
[out]collAn std::vector containing all components.
Returns
true Failure (error is reported).
false Success.

◆ fetch_schema_table_names_by_engine()

bool dd::cache::Dictionary_client::fetch_schema_table_names_by_engine ( const Schema schema,
const String_type engine,
std::vector< String_type > *  names 
) const

Fetch the names of the tables in the schema belonging to specific storage engine.

E.g., Object with dd::Table::hidden() == true will be ignored.

Parameters
schemaSchema for which to get component names.
engineEngine name of tables to match.
[out]namesAn std::vector containing all object names.
Returns
true Failure (error is reported).
false Success.

◆ fetch_schema_table_names_not_hidden_by_se()

bool dd::cache::Dictionary_client::fetch_schema_table_names_not_hidden_by_se ( const Schema schema,
std::vector< String_type > *  names 
) const

Fetch the names of the server tables in the schema.

Ignore tables hidden by SE.

Parameters
schemaSchema for which to get component names.
[out]namesAn std::vector containing all object names.
Returns
true Failure (error is reported).
false Success.

◆ foreach()

template<typename Object_type >
bool dd::cache::Dictionary_client::foreach ( const Object_key object_key,
std::function< bool(std::unique_ptr< Object_type > &)> const &  processor 
) const

Execute the submitted lambda function for each entity of the given type selected by the submitted key.

If the lambda returns true, iteration stops and the function returns.

Template Parameters
Object_typeEntity type to examine.
Parameters
object_keyKey to use for selecting entities.
processorLambda to execute for each entity.
Returns
true Failure (error is reported unless the lambda returned true).
false Success.

◆ get_table_name_by_partition_se_private_id()

bool dd::cache::Dictionary_client::get_table_name_by_partition_se_private_id ( const String_type engine,
Object_id  se_partition_id,
String_type schema_name,
String_type table_name 
)

Retrieve schema and table name by the se private id of the partition.

Parameters
engineName of the engine storing the table.
se_partition_idSE private id of the table partition.
[out]schema_nameName of the schema containing the table.
[out]table_nameName of the table.
Return values
falseNo error or if object was not found. The OUT params will be set to empty string when object is not found.
trueError.

◆ get_table_name_by_se_private_id()

bool dd::cache::Dictionary_client::get_table_name_by_se_private_id ( const String_type engine,
Object_id  se_private_id,
String_type schema_name,
String_type table_name 
)

Retrieve schema and table name by the se private id of the table.

Parameters
engineName of the engine storing the table.
se_private_idSE private id of the table.
[out]schema_nameName of the schema containing the table.
[out]table_nameName of the table.
Return values
falseNo error OR if object was not found. The OUT params will be set to empty string when object is not found.
trueError.

◆ get_table_name_by_trigger_name()

bool dd::cache::Dictionary_client::get_table_name_by_trigger_name ( const Schema schema,
const String_type trigger_name,
String_type table_name 
)

Retrieve a table name of a given trigger name and schema.

Parameters
schemaSchema containing the trigger.
trigger_nameName of the trigger.
[out]table_nameName of the table for which trigger belongs to. Empty string if there is no such trigger.
Return values
falseNo error.
trueError.

◆ invalidate() [1/2]

bool dd::cache::Dictionary_client::invalidate ( const String_type schema_name,
const String_type table_name 
)

Invalidate a cache entry.

This function will acquire a table object based on the schema qualified table name, and call 'invalidate(table_object)'.

Note
This function only applies to tables yet.
Parameters
schema_nameName of the schema containing the table.
table_nameName of the table.
Return values
falseNo error.
trueError (from handling a cache miss, or from failing to get an MDL lock).

◆ invalidate() [2/2]

template<typename T >
void dd::cache::Dictionary_client::invalidate ( const T *  object)

Invalidate a cache entry.

This function will remove and delete an object from the shared cache, based on the id of the object. If the object id is present in the local object registry and the auto releaser, it will be removed from there as well.

Note
There is no particular consideration of already dropped or modified objects in this method.
Template Parameters
TDictionary object type.
Parameters
objectObject to be invalidated.

◆ is_user_definer()

template<typename T >
bool dd::cache::Dictionary_client::is_user_definer ( const LEX_USER user,
bool *  is_definer 
) const

Check if a user is referenced as definer by some object of the given type.

Template Parameters
TType of dictionary objects to check.
Parameters
userUser name, including @ and host.
[out]is_definerTrue if the user is referenced as definer by some object.
Returns
true Failure (error is reported, is_definer is undefined).
false Success.

◆ no_auto_delete()

template<typename T >
void dd::cache::Dictionary_client::no_auto_delete ( T *  object)
inlineprivate

Remove an object from the auto delete vector.

Template Parameters
TDictionary object type.
Parameters
objectDictionary object to keep.

◆ register_dropped_object()

template<typename T >
void dd::cache::Dictionary_client::register_dropped_object ( T *  object)
private

Transfer object ownership from caller to Dictionary_client, and register the object as dropped.

This method is used internally by the Dictionary_client for keeping track of dropped objects. This is needed before transaction commit if an attempt is made to acquire the dropped object, to avoid consulting the shared cache, which might contaminate the cache due to a cache miss (handled with isolation level READ_COMMITTED). Instead of consulting the shared cache, this Dictionary_client will recognize that the object is dropped, and return a nullptr.

This method takes a non-const argument as it only makes sense to register objects not acquired from the shared cache.

Template Parameters
TDictionary object type.
Parameters
objectObject to transfer ownership.

◆ register_uncommitted_object()

template<typename T >
void dd::cache::Dictionary_client::register_uncommitted_object ( T *  object)
private

Transfer object ownership from caller to Dictionary_client, and register the object as uncommitted.

This is intended for objects created by the caller that should be managed by Dictionary_client. Transferring an object in this way will make it accessible by calling acquire().

This method takes a non-const argument as it only makes sense to register objects not acquired from the shared cache.

Template Parameters
TDictionary object type.
Parameters
objectObject to transfer ownership.

◆ release() [1/2]

template<typename T >
size_t dd::cache::Dictionary_client::release ( Object_registry registry)
private

Mark all objects of a certain type as not being used by this client.

This function is called with the client's own object registry, or with the registry of an auto releaser (which will contain a subset of the objects in the client's object registry).

The function will release all objects of a given type in the registry submitted.The objects must be present and in use. If the objects become unused, they are added to the free list in the shared cache, which is then rectified to enforce its capacity constraints. The objects are also removed from the client's object registry.

Template Parameters
TDictionary object type.
Parameters
registryObject registry tp release from.
Returns
Number of objects released.

◆ release() [2/2]

size_t dd::cache::Dictionary_client::release ( Object_registry registry)
private

Release all objects in the submitted object registry.

This function will release all objects from the client's registry, or from the registry of an auto releaser.

Parameters
registryObject registry tp release from.
Returns
Number of objects released.

◆ remove_table_dynamic_statistics()

bool dd::cache::Dictionary_client::remove_table_dynamic_statistics ( const String_type schema_name,
const String_type table_name 
)

Remove table statistics entries from mysql.table_stats and mysql.index_stats.

Parameters
schema_nameSchema name of the table
table_nameTable name of which stats should be cleaned.
Returns
true - on failure
false - on success

◆ remove_uncommitted_objects()

template<typename T >
void dd::cache::Dictionary_client::remove_uncommitted_objects ( bool  commit_to_shared_cache)
private

Remove the uncommitted objects from the client and (depending on the parameter) put them into the shared cache, thereby making them visible to other clients.

Should be called after commit to disk but before metadata locks are released.

Can also be called after rollback in order to explicitly throw the modified objects away before making any actions to compensate for a partially completed statement. Note that uncommitted objects are automatically removed once the topmost stack-allocated auto releaser goes out of scope, so calling this function in case of abort is only needed to make acquire return the old object again later in the same statement.

Parameters
commit_to_shared_cacheIf true, uncommitted objects will be put into the shared cache.
Template Parameters
TDictionary object type.

◆ rollback_modified_objects()

void dd::cache::Dictionary_client::rollback_modified_objects ( )

Remove the uncommitted objects from the client.

Can also be used to explicitly throw the modified objects away before making any actions to compensate for a partially completed statement. Note that uncommitted objects are automatically removed once the topmost stack-allocated auto releaser goes out of scope, so calling this function in case of abort is only needed to make acquire return the old object again later in the same statement.

◆ store() [1/3]

template<>
bool dd::cache::Dictionary_client::store ( Index_stat object)

◆ store() [2/3]

template<typename T >
bool dd::cache::Dictionary_client::store ( T *  object)

Store a new dictionary object.

This function will write the object to the dd tables. The object is added neither to the dictionary client's object registry nor the shared cache.

Note
A precondition is that the object has not been acquired from the shared cache. For storing an object which is already in the cache, please use update().
After calling store(), the submitted dictionary object can not be used for further calls to store(). It might be used as an argument to update(), but this is not recommended since calling update() will imply transferring object ownership to the dictionary client. Instead, please call 'acquire_for_modification()' to get a new object instance to use for modification and further updates.
Template Parameters
TDictionary object type.
Parameters
objectObject to be stored.
Return values
falseThe operation was successful.
trueThere was an error.

◆ store() [3/3]

template<>
bool dd::cache::Dictionary_client::store ( Table_stat object)

◆ update()

template<typename T >
bool dd::cache::Dictionary_client::update ( T *  new_object)

Update a persisted dictionary object, but keep the shared cache unchanged.

This function will store a dictionary object to the DD tables after verifying that an object with the same id already exists. The old object, which may be present in the shared dictionary cache, is not modified. To make the changes visible in the shared cache, please call remove_uncommitted_objects().

Note
A precondition is that the object has been acquired from the shared cache indirectly by acquire_for_modification(). For storing an object which is not already in the cache, please use store().
The new_object pointer submitted to this function, is owned by the auto delete vector. When registering the new object as an uncommitted object, the object must be removed from the auto delete vector.
Template Parameters
TDictionary object type.
Parameters
new_objectNew object, not present in the cache, to be stored persistently.
Return values
falseThe operation was successful.
trueThere was an error.

Member Data Documentation

◆ m_current_releaser

Auto_releaser* dd::cache::Dictionary_client::m_current_releaser
private

◆ m_default_releaser

Auto_releaser dd::cache::Dictionary_client::m_default_releaser
private

◆ m_no_table_spids

SPI_lru_cache_owner_ptr dd::cache::Dictionary_client::m_no_table_spids
private

Se-private ids known not to exist in either TABLES or PARTITIONS or both.

◆ m_registry_committed

Object_registry dd::cache::Dictionary_client::m_registry_committed
private

◆ m_registry_dropped

Object_registry dd::cache::Dictionary_client::m_registry_dropped
private

◆ m_registry_uncommitted

Object_registry dd::cache::Dictionary_client::m_registry_uncommitted
private

◆ m_thd

THD* dd::cache::Dictionary_client::m_thd
private

◆ m_uncached_objects

std::vector<Entity_object *> dd::cache::Dictionary_client::m_uncached_objects
private

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