MySQL 9.1.0
Source Code Documentation
trx0i_s.h File Reference

INFORMATION SCHEMA innodb_trx, innodb_locks and innodb_lock_waits tables cache structures and public functions. More...

#include <optional>
#include "dict0types.h"
#include "lock0types.h"
#include "trx0types.h"
#include "univ.i"

Go to the source code of this file.

Classes

struct  i_s_locks_row_t
 This structure represents INFORMATION_SCHEMA.innodb_locks row. More...
 
struct  i_s_trx_row_t
 This structure represents INFORMATION_SCHEMA.innodb_trx row. More...
 

Macros

#define TRX_I_S_STRING_COPY(data, field, constraint, tcache)
 Safely copy strings in to the INNODB_TRX table's string based columns. More...
 

Enumerations

enum  i_s_table { I_S_INNODB_TRX }
 Auxiliary enum used by functions that need to select one of the INFORMATION_SCHEMA tables. More...
 

Functions

void trx_i_s_cache_init (trx_i_s_cache_t *cache)
 Initialize INFORMATION SCHEMA trx related cache. More...
 
void trx_i_s_cache_free (trx_i_s_cache_t *cache)
 Free the INFORMATION SCHEMA trx related cache. More...
 
void trx_i_s_cache_start_read (trx_i_s_cache_t *cache)
 Issue a shared/read lock on the tables cache. More...
 
void trx_i_s_cache_end_read (trx_i_s_cache_t *cache)
 Release a shared/read lock on the tables cache. More...
 
void trx_i_s_cache_start_write (trx_i_s_cache_t *cache)
 Issue an exclusive/write lock on the tables cache. More...
 
void trx_i_s_cache_end_write (trx_i_s_cache_t *cache)
 Release an exclusive/write lock on the tables cache. More...
 
ulint trx_i_s_cache_get_rows_used (trx_i_s_cache_t *cache, enum i_s_table table)
 Retrieves the number of used rows in the cache for a given INFORMATION SCHEMA table. More...
 
void * trx_i_s_cache_get_nth_row (trx_i_s_cache_t *cache, enum i_s_table table, ulint n)
 Retrieves the nth row in the cache for a given INFORMATION SCHEMA table. More...
 
int trx_i_s_possibly_fetch_data_into_cache (trx_i_s_cache_t *cache)
 Update the transactions cache if it has not been read for some time. More...
 
bool trx_i_s_cache_is_truncated (trx_i_s_cache_t *cache)
 Returns true if the data in the cache is truncated due to the memory limit posed by TRX_I_S_MEM_LIMIT. More...
 
char * trx_i_s_create_lock_id (const i_s_locks_row_t &row, char *lock_id, size_t lock_id_size)
 Crafts a lock id string from a i_s_locks_row_t object. More...
 
void p_s_fill_lock_data (const char **lock_data, const lock_t *lock, ulint heap_no, PSI_server_data_lock_container *container)
 Fill performance schema lock data. More...
 
void fill_locks_row (i_s_locks_row_t *row, const lock_t *lock, ulint heap_no)
 Fills i_s_locks_row_t object with data about the lock. More...
 
int trx_i_s_parse_lock_id (const char *lock_id, i_s_locks_row_t *row)
 Parses lock id into row. More...
 

Variables

constexpr uint32_t TRX_I_S_MEM_LIMIT = 16777216
 The maximum amount of memory that can be consumed by innodb_trx, innodb_locks and innodb_lock_waits information schema tables. More...
 
constexpr uint32_t TRX_I_S_LOCK_DATA_MAX_LEN = 8192
 The maximum length of a string that can be stored in i_s_locks_row_t::lock_data. More...
 
constexpr uint32_t TRX_I_S_TRX_QUERY_MAX_LEN = 1024
 The maximum length of a string that can be stored in i_s_trx_row_t::trx_query. More...
 
constexpr uint32_t TRX_I_S_TRX_OP_STATE_MAX_LEN = 64
 The maximum length of a string that can be stored in i_s_trx_row_t::trx_operation_state. More...
 
constexpr uint32_t TRX_I_S_TRX_FK_ERROR_MAX_LEN = 256
 The maximum length of a string that can be stored in i_s_trx_row_t::trx_foreign_key_error. More...
 
constexpr uint32_t TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN = 16
 The maximum length of a string that can be stored in i_s_trx_row_t::trx_isolation_level. More...
 
trx_i_s_cache_ttrx_i_s_cache
 This is the intermediate buffer where data needed to fill the INFORMATION SCHEMA tables is fetched and later retrieved by the C++ code in handler/i_s.cc. More...
 
constexpr uint32_t TRX_I_S_LOCK_ID_MAX_LEN = 20 * 6 + 5
 The maximum length of a resulting lock_id_size in trx_i_s_create_lock_id(), not including the terminating NUL. More...
 

Detailed Description

INFORMATION SCHEMA innodb_trx, innodb_locks and innodb_lock_waits tables cache structures and public functions.

Created July 17, 2007 Vasil Dimov

Macro Definition Documentation

◆ TRX_I_S_STRING_COPY

#define TRX_I_S_STRING_COPY (   data,
  field,
  constraint,
  tcache 
)
Value:
do { \
if (strlen(data) > constraint) { \
char buff[constraint + 1]; \
strncpy(buff, data, constraint); \
buff[constraint] = '\0'; \
\
field = static_cast<const char *>( \
ha_storage_put_memlim((tcache)->storage, buff, constraint + 1, \
} else { \
field = static_cast<const char *>(ha_storage_put_str_memlim( \
(tcache)->storage, data, MAX_ALLOWED_FOR_STORAGE(tcache))); \
} \
} while (0)
static const char * ha_storage_put_str_memlim(ha_storage_t *storage, const char *str, ulint memlim)
Copies string into the storage and returns a pointer to the copy obeying a memory limit.
Definition: ha0storage.h:105
#define MAX_ALLOWED_FOR_STORAGE(cache)
Memory limit passed to ha_storage_put_memlim().
Definition: trx0i_s.cc:96

Safely copy strings in to the INNODB_TRX table's string based columns.

Enumeration Type Documentation

◆ i_s_table

enum i_s_table

Auxiliary enum used by functions that need to select one of the INFORMATION_SCHEMA tables.

Enumerator
I_S_INNODB_TRX 

INFORMATION_SCHEMA.innodb_trx.

Function Documentation

◆ fill_locks_row()

void fill_locks_row ( i_s_locks_row_t row,
const lock_t lock,
ulint  heap_no 
)

Fills i_s_locks_row_t object with data about the lock.

Parameters
[out]rowResult object that's filled
[in]lockLock to get data from
[in]heap_noLock's record number or ULINT_UNDEFINED if the lock is a table lock

◆ p_s_fill_lock_data()

void p_s_fill_lock_data ( const char **  lock_data,
const lock_t lock,
ulint  heap_no,
PSI_server_data_lock_container container 
)

Fill performance schema lock data.

Create a string that represents the LOCK_DATA column, for a given lock record.

Parameters
[out]lock_dataLock data string
[in]lockLock to inspect
[in]heap_noLock heap number
[in]containerData container to fill

◆ trx_i_s_cache_end_read()

void trx_i_s_cache_end_read ( trx_i_s_cache_t cache)

Release a shared/read lock on the tables cache.

in: cache

Parameters
cachein: cache

◆ trx_i_s_cache_end_write()

void trx_i_s_cache_end_write ( trx_i_s_cache_t cache)

Release an exclusive/write lock on the tables cache.

in: cache

Parameters
cachein: cache

◆ trx_i_s_cache_free()

void trx_i_s_cache_free ( trx_i_s_cache_t cache)

Free the INFORMATION SCHEMA trx related cache.

in/out: cache to free

Parameters
cachein, own: cache to free

◆ trx_i_s_cache_get_nth_row()

void * trx_i_s_cache_get_nth_row ( trx_i_s_cache_t cache,
enum i_s_table  table,
ulint  n 
)

Retrieves the nth row in the cache for a given INFORMATION SCHEMA table.

Returns
row in: row number

Retrieves the nth row in the cache for a given INFORMATION SCHEMA table.

Returns
row
Parameters
cachein: cache
tablein: which table
nin: row number

◆ trx_i_s_cache_get_rows_used()

ulint trx_i_s_cache_get_rows_used ( trx_i_s_cache_t cache,
enum i_s_table  table 
)

Retrieves the number of used rows in the cache for a given INFORMATION SCHEMA table.

Returns
number of rows in: which table
number of rows
Parameters
cachein: cache
tablein: which table

◆ trx_i_s_cache_init()

void trx_i_s_cache_init ( trx_i_s_cache_t cache)

Initialize INFORMATION SCHEMA trx related cache.

out: cache to init

Parameters
cacheout: cache to init

◆ trx_i_s_cache_is_truncated()

bool trx_i_s_cache_is_truncated ( trx_i_s_cache_t cache)

Returns true if the data in the cache is truncated due to the memory limit posed by TRX_I_S_MEM_LIMIT.

Parameters
[in]cacheThe cache
Returns
true if truncated

◆ trx_i_s_cache_start_read()

void trx_i_s_cache_start_read ( trx_i_s_cache_t cache)

Issue a shared/read lock on the tables cache.

in: cache

Parameters
cachein: cache

◆ trx_i_s_cache_start_write()

void trx_i_s_cache_start_write ( trx_i_s_cache_t cache)

Issue an exclusive/write lock on the tables cache.

in: cache

Parameters
cachein: cache

◆ trx_i_s_create_lock_id()

char * trx_i_s_create_lock_id ( const i_s_locks_row_t row,
char *  lock_id,
size_t  lock_id_size 
)

Crafts a lock id string from a i_s_locks_row_t object.

Returns its second argument. This function aborts if there is not enough space in lock_id. Be sure to provide at least TRX_I_S_LOCK_ID_MAX_LEN + 1 if you want to be 100% sure that it will not abort.

Parameters
[in]rowThe description of the lock sufficient to populate a row
[out]lock_idThe buffer to store the resulting lock_id
[in]lock_id_sizeThe size of the lock_id buffer
Returns
resulting lock id

◆ trx_i_s_parse_lock_id()

int trx_i_s_parse_lock_id ( const char *  lock_id,
i_s_locks_row_t row 
)

Parses lock id into row.

Parameters
[in]lock_idLock id generated with trx_i_s_create_lock_id
[out]rowRow to be filled in with data
Returns
LOCK_REC, LOCK_TABLE or 0 if failed to parse

◆ trx_i_s_possibly_fetch_data_into_cache()

int trx_i_s_possibly_fetch_data_into_cache ( trx_i_s_cache_t cache)

Update the transactions cache if it has not been read for some time.

Returns
0 - fetched, 1 - not in/out: cache

Called from handler/i_s.cc.

Returns
0 - fetched, 1 - not
Parameters
cachein/out: cache

Variable Documentation

◆ trx_i_s_cache

trx_i_s_cache_t* trx_i_s_cache
extern

This is the intermediate buffer where data needed to fill the INFORMATION SCHEMA tables is fetched and later retrieved by the C++ code in handler/i_s.cc.

◆ TRX_I_S_LOCK_DATA_MAX_LEN

constexpr uint32_t TRX_I_S_LOCK_DATA_MAX_LEN = 8192
constexpr

The maximum length of a string that can be stored in i_s_locks_row_t::lock_data.

◆ TRX_I_S_LOCK_ID_MAX_LEN

constexpr uint32_t TRX_I_S_LOCK_ID_MAX_LEN = 20 * 6 + 5
constexpr

The maximum length of a resulting lock_id_size in trx_i_s_create_lock_id(), not including the terminating NUL.

"%lu:%lu:%lu:%lu:%lu:%lu" -> 20*6+5 chars

◆ TRX_I_S_MEM_LIMIT

constexpr uint32_t TRX_I_S_MEM_LIMIT = 16777216
constexpr

The maximum amount of memory that can be consumed by innodb_trx, innodb_locks and innodb_lock_waits information schema tables.

◆ TRX_I_S_TRX_FK_ERROR_MAX_LEN

constexpr uint32_t TRX_I_S_TRX_FK_ERROR_MAX_LEN = 256
constexpr

The maximum length of a string that can be stored in i_s_trx_row_t::trx_foreign_key_error.

◆ TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN

constexpr uint32_t TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN = 16
constexpr

The maximum length of a string that can be stored in i_s_trx_row_t::trx_isolation_level.

◆ TRX_I_S_TRX_OP_STATE_MAX_LEN

constexpr uint32_t TRX_I_S_TRX_OP_STATE_MAX_LEN = 64
constexpr

The maximum length of a string that can be stored in i_s_trx_row_t::trx_operation_state.

◆ TRX_I_S_TRX_QUERY_MAX_LEN

constexpr uint32_t TRX_I_S_TRX_QUERY_MAX_LEN = 1024
constexpr

The maximum length of a string that can be stored in i_s_trx_row_t::trx_query.