MySQL 9.1.0
Source Code Documentation
pfs_statement_provider.h File Reference

Performance schema instrumentation (declarations). More...

#include <sys/types.h>
#include "my_psi_config.h"
#include "my_inttypes.h"
#include "my_macros.h"
#include "mysql/psi/psi_statement.h"
#include "sql/sql_digest.h"

Go to the source code of this file.

Macros

#define PSI_STATEMENT_CALL(M)   pfs_##M##_vc
 
#define PSI_DIGEST_CALL(M)   pfs_##M##_vc
 
#define PSI_PS_CALL(M)   pfs_##M##_vc
 

Functions

void pfs_register_statement_vc (const char *category, PSI_statement_info *info, int count)
 
PSI_statement_lockerpfs_get_thread_statement_locker_vc (PSI_statement_locker_state *state, PSI_statement_key key, const void *charset, PSI_sp_share *sp_share)
 This is the entry point to the performance schema statement instrumentation. More...
 
PSI_statement_lockerpfs_refine_statement_vc (PSI_statement_locker *locker, PSI_statement_key key)
 
void pfs_start_statement_vc (PSI_statement_locker *locker, const char *db, uint db_len, const char *src_file, uint src_line)
 
void pfs_set_statement_text_vc (PSI_statement_locker *locker, const char *text, uint text_len)
 
void pfs_set_statement_query_id_vc (PSI_statement_locker *locker, ulonglong count)
 
void pfs_set_statement_lock_time_vc (PSI_statement_locker *locker, ulonglong count)
 
void pfs_set_statement_rows_sent_vc (PSI_statement_locker *locker, ulonglong count)
 
void pfs_set_statement_rows_examined_vc (PSI_statement_locker *locker, ulonglong count)
 
void pfs_inc_statement_created_tmp_disk_tables_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_inc_statement_created_tmp_tables_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_inc_statement_select_full_join_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_inc_statement_select_full_range_join_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_inc_statement_select_range_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_inc_statement_select_range_check_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_inc_statement_select_scan_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_inc_statement_sort_merge_passes_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_inc_statement_sort_range_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_inc_statement_sort_rows_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_inc_statement_sort_scan_vc (PSI_statement_locker *locker, ulong count)
 
void pfs_set_statement_no_index_used_vc (PSI_statement_locker *locker)
 
void pfs_set_statement_no_good_index_used_vc (PSI_statement_locker *locker)
 
void pfs_notify_statement_query_attributes_vc (PSI_statement_locker *locker, bool with_query_attributes)
 
void pfs_statement_abort_telemetry_vc (PSI_statement_locker *locker)
 
void pfs_set_statement_secondary_engine_vc (PSI_statement_locker *locker, bool secondary)
 
void pfs_end_statement_vc (PSI_statement_locker *locker, void *stmt_da)
 
PSI_prepared_stmtpfs_create_prepared_stmt_vc (void *identity, uint stmt_id, PSI_statement_locker *locker, const char *stmt_name, size_t stmt_name_length, const char *sql_text, size_t sql_text_length)
 
void pfs_destroy_prepared_stmt_vc (PSI_prepared_stmt *prepared_stmt)
 
void pfs_reprepare_prepared_stmt_vc (PSI_prepared_stmt *prepared_stmt)
 
void pfs_execute_prepared_stmt_vc (PSI_statement_locker *locker, PSI_prepared_stmt *ps)
 
void pfs_set_prepared_stmt_text_vc (PSI_prepared_stmt *prepared_stmt, const char *text, uint text_len)
 
void pfs_set_prepared_stmt_secondary_engine_vc (PSI_prepared_stmt *prepared_stmt, bool secondary)
 
PSI_digest_lockerpfs_digest_start_vc (PSI_statement_locker *locker)
 
void pfs_digest_end_vc (PSI_digest_locker *locker, const sql_digest_storage *digest)
 

Detailed Description

Performance schema instrumentation (declarations).

Macro Definition Documentation

◆ PSI_DIGEST_CALL

#define PSI_DIGEST_CALL (   M)    pfs_##M##_vc

◆ PSI_PS_CALL

#define PSI_PS_CALL (   M)    pfs_##M##_vc

◆ PSI_STATEMENT_CALL

#define PSI_STATEMENT_CALL (   M)    pfs_##M##_vc

Function Documentation

◆ pfs_create_prepared_stmt_vc()

PSI_prepared_stmt * pfs_create_prepared_stmt_vc ( void *  identity,
uint  stmt_id,
PSI_statement_locker locker,
const char *  stmt_name,
size_t  stmt_name_length,
const char *  sql_text,
size_t  sql_text_length 
)

◆ pfs_destroy_prepared_stmt_vc()

void pfs_destroy_prepared_stmt_vc ( PSI_prepared_stmt prepared_stmt)

◆ pfs_digest_end_vc()

void pfs_digest_end_vc ( PSI_digest_locker locker,
const sql_digest_storage digest 
)

◆ pfs_digest_start_vc()

PSI_digest_locker * pfs_digest_start_vc ( PSI_statement_locker locker)

◆ pfs_end_statement_vc()

void pfs_end_statement_vc ( PSI_statement_locker locker,
void *  stmt_da 
)

◆ pfs_execute_prepared_stmt_vc()

void pfs_execute_prepared_stmt_vc ( PSI_statement_locker locker,
PSI_prepared_stmt ps 
)

◆ pfs_get_thread_statement_locker_vc()

PSI_statement_locker * pfs_get_thread_statement_locker_vc ( PSI_statement_locker_state state,
PSI_statement_key  key,
const void *  charset,
PSI_sp_share sp_share 
)

This is the entry point to the performance schema statement instrumentation.

This instrumentation is used to:

  • provide data to the performance schema tables, according to the performance schema configuration,
  • provide data to the telemetry traces component, if present, according to the telemetry component configuration.

These two data paths are executed in parallel, based on data collected once, and possibly used twice for different purposes.

State data storage for get_thread_statement_locker_v5_t.
Definition: psi_statement_bits.h:166

is used to collect data.

How each field in PSI_statement_locker_state is used is described here, not in PSI_statement_locker_state, because usage is specific to the implementation.

Other instrumentations of the PSI interface, (namely, LOCK_ORDER), may choose to use fields differently, or not at all.

Fields in PSI_statement_locker_state are used as follows.

PSI_statement_locker_state::m_class

Statement instrument class. Always populated. Not null.

PSI_statement_locker_state::m_cs_number

Always populated. Character set number, for query text.

PSI_statement_locker_state::m_thread

Thread instrumentation. Always populated. May be null.

PSI_statement_locker_state::m_parent_sp_share

Parent stored program instrumentation. Always populated. May be null.

PSI_statement_locker_state::m_pfs_flags

Flags controlling how collected data is used to feed performance schema tables. Always populated.

Bits have the following semantic:

  • STATE_FLAG_BASE indicates that basic statement statistics are to be collected.
  • STATE_FLAG_THREAD indicates that per thread statistics are to be populated. When not set, global statistics are populated instead.
  • STATE_FLAG_EVENT indicates that detail event data is to be collected.
  • STATE_FLAG_TIMED indicates that timing data is collected.
  • STATE_FLAG_CPU indicates that cpu data is collected.
  • STATE_FLAG_DIGEST indicates that digest data is collected.

In addition, the following filters are implemented:

  • STATE_FLAG_BASE depends on PFS_statement_class::m_enabled. That is, column SETUP_INSTRUMENTS.ENABLED is honored.
  • STATE_FLAG_THREAD depends on PFS_thread::m_enabled. That is, column THREADS.ENABLED is honored.
  • STATE_FLAG_TIMED depends on PFS_statement_class::m_timed. That is, column SETUP_INSTRUMENTS.TIMED is honored.

PSI_statement_locker_state::m_telemetry_scope

These flags are set by the telemetry traces component, to indicate if/how to collect data for telemetry. Never populated, when not compiling with telemetry. Always populated, when compiling with telemetry.

Possible values are:

  • 0, to indicate statement traces are not collected.
  • TRACE_STATEMENTS, to indicate statement traces are required.

These values are exposed in the mysql_server_telemetry_traces_v1 service, and part of the public mysql_server_telemetry_traces interface.

Subsequent calls to telemetry trace apis can narrow down flags, but can never add more flags.

PSI_statement_locker_state::m_tel_flags

These flags are a translation, in performance schema implementation terms, of interface PSI_statement_locker_state::m_telemetry_scope. Never populated, when not compiling with telemetry traces. Always populated, when compiling with telemetry traces.

Bits have the following semantic:

  • STATE_FLAG_BASE indicates that statement statistics are collected.
  • STATE_FLAG_THREAD indicates that the thread instrumentation object PFS_thread exists and is not NULL.
  • STATE_FLAG_TIMED indicates that timing data is collected.
  • STATE_FLAG_CPU indicates that cpu data is collected.
  • STATE_FLAG_DIGEST indicates that digest data is collected.
  • STATE_FLAG_EVENT indicates that per event data (query text, error message) is collected.

In practice, these flags are not set individually. See STATE_FLAG_STATEMENT_TELEMETRY.

PSI_statement_locker_state::m_collect_flags

Flags controlling data collection. These flags are the union of m_pfs_flags and m_telemetry_scope Always populated.

A value 0 indicates nothing is collected.

PSI_statement_locker_state::m_telemetry_locker

Opaque pointer to a telemetry span inside the telemetry component. Never populated, when not compiling with telemetry. Always populated, when compiling with telemetry. May be NULL.

PSI_statement_locker_state::m_telemetry

Pointer to the telemetry traces component code.

Typed as a void* pointer in public headers, to avoid exposing implementation details. The effective type is guaranteed to be

Definition: server_telemetry_traces_bits.h:137

which is the component entry point loaded by INSTALL COMPONENT <telemetry.so>

Never populated, when not compiling with telemetry traces. Conditionally populated, when compiling with telemetry traces. Not NULL if populated.

This member is initialized only when m_telemetry_locker != nullptr. It points to the telemetry traces component that created the m_telemetry_locker.

When m_telemetry_locker == nullptr, this member is not set.

PSI_statement_locker_state::m_telemetry_session

Pointer to a telemetry session, inside the telemetry component.

Never populated, when not compiling with telemetry traces. Conditionally populated, when compiling with telemetry traces. Not NULL if populated.

This member is initialized only when m_telemetry_locker != nullptr. It points to the telemetry session associated with the m_telemetry_locker.

When m_telemetry_locker == nullptr, this member is not set.

PSI_statement_locker_state::m_controlled_local_size_start PSI_statement_locker_state::m_controlled_stmt_size_start PSI_statement_locker_state::m_total_local_size_start PSI_statement_locker_state::m_total_stmt_size_start

Temporary storage used by the instrumentation to compute the amount of memory used by a sub statement.

Conditionally populated, several conditions apply:

  • m_thread != nullptr, the thread instrumentation must exist
  • m_collect_flags != 0, data is collected
  • m_parent_sp_share != nullptr, the statement is a sub statement.

Used to compute MAX_CONTROLLED_MEMORY and MAX_TOTAL_MEMORY.

PSI_statement_locker_state::m_timer_start

Statement timing information. Conditionally populated, if m_collect_flags != 0. May be 0.

Value set only when bit STATE_FLAG_TIMED is set in m_collect_flags.

Note that m_collect_flags & STATE_FLAG_TIMED can be true, while m_pfs_flags & STATE_FLAG_TIMED can be false, so check the proper flag before using this field.

PSI_statement_locker_state::m_cpu_time_start

CPU timing information. Conditionally populated, if m_collect_flags != 0. May be 0.

Value set only when bit STATE_FLAG_CPU is set in m_collect_flags.

Note that m_collect_flags & STATE_FLAG_CPU can be true, while m_pfs_flags & STATE_FLAG_CPU can be false, so check the proper flag before using this field.

PSI_statement_locker_state::m_no_index_used PSI_statement_locker_state::m_no_good_index_used PSI_statement_locker_state::m_lock_time PSI_statement_locker_state::m_rows_sent PSI_statement_locker_state::m_rows_examined PSI_statement_locker_state::m_created_tmp_disk_tables PSI_statement_locker_state::m_created_tmp_tables PSI_statement_locker_state::m_select_full_join PSI_statement_locker_state::m_select_full_range_join PSI_statement_locker_state::m_select_range PSI_statement_locker_state::m_select_range_check PSI_statement_locker_state::m_select_scan PSI_statement_locker_state::m_sort_merge_passes PSI_statement_locker_state::m_sort_range PSI_statement_locker_state::m_sort_rows PSI_statement_locker_state::m_sort_scan

Optimizer metrics associated with a statement. Conditionally populated, if m_collect_flags & STATE_FLAG_BASE.

PSI_statement_locker_state::m_digest

Query digest. Conditionally populated, if m_collect_flags != 0. May be NULL.

Value set only when bit STATE_FLAG_DIGEST is set in m_collect_flags.

PSI_statement_locker_state::m_schema_name PSI_statement_locker_state::m_schema_name_length

Current schema. Conditionally populated, if m_collect_flags != 0. May be empty.

PSI_statement_locker_state::m_query_sample PSI_statement_locker_state::m_query_sample_length PSI_statement_locker_state::m_query_sample_truncated

Query sample. Conditionally populated, if m_collect_flags != 0. May be empty.

PSI_statement_locker_state::m_secondary

Secondary engine. Conditionally populated, if m_collect_flags != 0.

PSI_statement_locker_state::m_parent_prepared_stmt

Parent prepare statement. Conditionally populated, if m_collect_flags != 0. May be NULL.

PSI_statement_locker_state::m_in_prepare

Prepare or Execute the parent prepared statement. Conditionally populated:

  • m_collect_flags != 0
  • m_parent_prepared_stmt != nullptr

If a parent prepared statement exists, indicate if the code prepares (true) or executes (false) the parent statement.

PSI_statement_locker_state::m_statement

Performance schema STATEMENT_CURRENT record. Conditionally populated, if m_collect_flags != 0. May be NULL.

Value set only if pfs_flags & STATE_FLAG_EVENT

◆ pfs_inc_statement_created_tmp_disk_tables_vc()

void pfs_inc_statement_created_tmp_disk_tables_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_inc_statement_created_tmp_tables_vc()

void pfs_inc_statement_created_tmp_tables_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_inc_statement_select_full_join_vc()

void pfs_inc_statement_select_full_join_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_inc_statement_select_full_range_join_vc()

void pfs_inc_statement_select_full_range_join_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_inc_statement_select_range_check_vc()

void pfs_inc_statement_select_range_check_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_inc_statement_select_range_vc()

void pfs_inc_statement_select_range_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_inc_statement_select_scan_vc()

void pfs_inc_statement_select_scan_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_inc_statement_sort_merge_passes_vc()

void pfs_inc_statement_sort_merge_passes_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_inc_statement_sort_range_vc()

void pfs_inc_statement_sort_range_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_inc_statement_sort_rows_vc()

void pfs_inc_statement_sort_rows_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_inc_statement_sort_scan_vc()

void pfs_inc_statement_sort_scan_vc ( PSI_statement_locker locker,
ulong  count 
)

◆ pfs_notify_statement_query_attributes_vc()

void pfs_notify_statement_query_attributes_vc ( PSI_statement_locker locker,
bool  with_query_attributes 
)

◆ pfs_refine_statement_vc()

PSI_statement_locker * pfs_refine_statement_vc ( PSI_statement_locker locker,
PSI_statement_key  key 
)

◆ pfs_register_statement_vc()

void pfs_register_statement_vc ( const char *  category,
PSI_statement_info info,
int  count 
)

◆ pfs_reprepare_prepared_stmt_vc()

void pfs_reprepare_prepared_stmt_vc ( PSI_prepared_stmt prepared_stmt)

◆ pfs_set_prepared_stmt_secondary_engine_vc()

void pfs_set_prepared_stmt_secondary_engine_vc ( PSI_prepared_stmt prepared_stmt,
bool  secondary 
)

◆ pfs_set_prepared_stmt_text_vc()

void pfs_set_prepared_stmt_text_vc ( PSI_prepared_stmt prepared_stmt,
const char *  text,
uint  text_len 
)

◆ pfs_set_statement_lock_time_vc()

void pfs_set_statement_lock_time_vc ( PSI_statement_locker locker,
ulonglong  count 
)

◆ pfs_set_statement_no_good_index_used_vc()

void pfs_set_statement_no_good_index_used_vc ( PSI_statement_locker locker)

◆ pfs_set_statement_no_index_used_vc()

void pfs_set_statement_no_index_used_vc ( PSI_statement_locker locker)

◆ pfs_set_statement_query_id_vc()

void pfs_set_statement_query_id_vc ( PSI_statement_locker locker,
ulonglong  count 
)

◆ pfs_set_statement_rows_examined_vc()

void pfs_set_statement_rows_examined_vc ( PSI_statement_locker locker,
ulonglong  count 
)

◆ pfs_set_statement_rows_sent_vc()

void pfs_set_statement_rows_sent_vc ( PSI_statement_locker locker,
ulonglong  count 
)

◆ pfs_set_statement_secondary_engine_vc()

void pfs_set_statement_secondary_engine_vc ( PSI_statement_locker locker,
bool  secondary 
)

◆ pfs_set_statement_text_vc()

void pfs_set_statement_text_vc ( PSI_statement_locker locker,
const char *  text,
uint  text_len 
)

◆ pfs_start_statement_vc()

void pfs_start_statement_vc ( PSI_statement_locker locker,
const char *  db,
uint  db_len,
const char *  src_file,
uint  src_line 
)

◆ pfs_statement_abort_telemetry_vc()

void pfs_statement_abort_telemetry_vc ( PSI_statement_locker locker)