MySQL 9.0.0
Source Code Documentation
p_s.cc File Reference

InnoDB performance_schema tables interface to MySQL. More...

#include "storage/innobase/handler/p_s.h"
#include <stdlib.h>
#include <sys/types.h>
#include <type_traits>
#include "lock0iter.h"
#include "lock0lock.h"
#include "sql_table.h"
#include "table.h"
#include "trx0i_s.h"
#include "trx0sys.h"
#include <algorithm>
#include <array>
#include <limits>
#include "my_io.h"

Classes

class  Max_of_n_smallest< N, Element >
 
class  Innodb_trx_scan_state
 State of a given scan. More...
 
class  Innodb_data_lock_iterator
 Inspect data locks for the innodb storage engine. More...
 
class  Innodb_data_lock_wait_iterator
 Inspect data lock waits for the innodb storage engine. More...
 

Enumerations

enum  scan_pass { INIT_SCANNING , SCANNING_RW_TRX_LIST , SCANNING_MYSQL_TRX_LIST , DONE_SCANNING }
 Pass of a given scan. More...
 

Functions

bool discard_trx (const trx_t *trx, bool read_write)
 Check if a transaction should be discarded. More...
 
template<typename Trx_list >
static constexpr bool is_read_write ()
 
template<typename Trx_list >
static const trx_tfetch_trx_in_trx_list (uint64_t filter_trx_immutable_id, Trx_list *trx_list)
 Find a transaction in a TRX LIST. More...
 
void alloc_identifier (PSI_server_data_lock_container *container, PSI_identifier kind, const std::string &id_str, const char **cached_id, size_t *cached_id_length)
 Allocate identifier in performance schema container. More...
 
void parse_table_path (PSI_server_data_lock_container *container, const char *table_path, const char **table_schema, size_t *table_schema_length, const char **table_name, size_t *table_name_length, const char **partition_name, size_t *partition_name_length, const char **subpartition_name, size_t *subpartition_name_length)
 Parse a table path string. More...
 
void print_table_lock_id (const lock_t *lock, char *lock_id, size_t lock_id_size)
 Print a table lock id. More...
 
void print_record_lock_id (const lock_t *lock, ulint heap_no, char *lock_id, size_t lock_id_size)
 Print a record lock id. More...
 
void print_lock_id (const lock_t *lock, ulint heap_no, char *lock_id, size_t lock_id_size)
 Print a lock id. More...
 
int scan_lock_id (const char *lock_id, uint64_t *trx_immutable_id, uint64_t *lock_immutable_id, ulint *heap_id)
 Scan a lock id string and extract information necessary to find a row by primary key. More...
 

Variables

static const char * g_engine = "INNODB"
 
static const size_t g_engine_length = 6
 

Detailed Description

InnoDB performance_schema tables interface to MySQL.

Enumeration Type Documentation

◆ scan_pass

enum scan_pass

Pass of a given scan.

Enumerator
INIT_SCANNING 
SCANNING_RW_TRX_LIST 

Scan the RW trx list.

See also
trx_sys_t::rw_trx_list
SCANNING_MYSQL_TRX_LIST 

Scan the MySQL trx list.

See also
trx_t::mysql_trx_list
DONE_SCANNING 

Function Documentation

◆ alloc_identifier()

void alloc_identifier ( PSI_server_data_lock_container container,
PSI_identifier  kind,
const std::string &  id_str,
const char **  cached_id,
size_t *  cached_id_length 
)

Allocate identifier in performance schema container.

Parameters
[in]containerThe container to fill
[in]kindThe identifier kind
[in]id_strThe identifier string
[out]cached_idThe cached identifier string
[out]cached_id_lengthThe cached identifier string length

◆ discard_trx()

bool discard_trx ( const trx_t trx,
bool  read_write 
)

Check if a transaction should be discarded.

Transactions present in any TRX LIST that have not started yet are discarded, when inspecting data locks. Transactions present in the MySQL TRX LIST, that are writing data and have an id, are also discarded.

Parameters
[in]trxTransaction to evaluate
[in]read_writeTrue if trx is in the RW TRX list
Returns
True if the trx should be discarded

◆ fetch_trx_in_trx_list()

template<typename Trx_list >
static const trx_t * fetch_trx_in_trx_list ( uint64_t  filter_trx_immutable_id,
Trx_list *  trx_list 
)
static

Find a transaction in a TRX LIST.

Parameters
[in]filter_trx_immutable_idThe transaction immutable id
[in]trx_listThe transaction list
Returns
The transaction when found, or NULL

◆ is_read_write()

template<typename Trx_list >
static constexpr bool is_read_write ( )
staticconstexpr

◆ parse_table_path()

void parse_table_path ( PSI_server_data_lock_container container,
const char *  table_path,
const char **  table_schema,
size_t *  table_schema_length,
const char **  table_name,
size_t *  table_name_length,
const char **  partition_name,
size_t *  partition_name_length,
const char **  subpartition_name,
size_t *  subpartition_name_length 
)

Parse a table path string.

Isolate the table schema, name, partition and sub partition from a table path string. Convert these strings and store them in the performance schema container.

Note
String returned are not zero terminated.
Parameters
[in]containerThe container to fill
[in]table_pathThe table path string
[out]table_schemaThe table schema
[out]table_schema_lengthThe table schema length
[out]table_nameThe table name
[out]table_name_lengthThe table name length
[out]partition_namePartition name
[out]partition_name_lengthPartition name length
[out]subpartition_nameSub partition name
[out]subpartition_name_lengthSub partition name length

◆ print_lock_id()

void print_lock_id ( const lock_t lock,
ulint  heap_no,
char *  lock_id,
size_t  lock_id_size 
)

Print a lock id.

Parameters
[in]lockThe lock to print
[in]heap_noLock heap number
[in,out]lock_idPrinting buffer
[in]lock_id_sizePrinting buffer length

◆ print_record_lock_id()

void print_record_lock_id ( const lock_t lock,
ulint  heap_no,
char *  lock_id,
size_t  lock_id_size 
)

Print a record lock id.

Parameters
[in]lockThe lock to print
[in]heap_noLock heap number
[in,out]lock_idPrinting buffer
[in]lock_id_sizePrinting buffer length

◆ print_table_lock_id()

void print_table_lock_id ( const lock_t lock,
char *  lock_id,
size_t  lock_id_size 
)

Print a table lock id.

Parameters
[in]lockThe lock to print
[in,out]lock_idPrinting buffer
[in]lock_id_sizePrinting buffer length

◆ scan_lock_id()

int scan_lock_id ( const char *  lock_id,
uint64_t *  trx_immutable_id,
uint64_t *  lock_immutable_id,
ulint heap_id 
)

Scan a lock id string and extract information necessary to find a row by primary key.

Parameters
[in]lock_idThe lock id string to parse
[out]trx_immutable_idThe immutable id of lock->trx
[out]lock_immutable_idThe immutable id of lock
[out]heap_idThe heap number found, for record locks
Returns
The type of lock found.
Return values
LOCK_TABLETable lock
LOCK_RECRecord lock
0Format error

Variable Documentation

◆ g_engine

const char* g_engine = "INNODB"
static

◆ g_engine_length

const size_t g_engine_length = 6
static