140#include <sys/types.h>
152#define SYSTEM_VARIABLE_PREALLOC 200
257template <
class Var_type>
460template <
class Var_type>
467template <
class Var_type>
469 if (unsafe_thd ==
nullptr) {
478 m_thd_finder.set_unsafe_thd(unsafe_thd);
482template <
class Var_type>
484 assert(pfs_thread !=
nullptr);
485 return get_THD(pfs_thread->
m_thd);
492template <
class Var_type>
498 return do_initialize_session();
505template <
class Var_type>
514 return do_initialize_session();
520template <
class Var_type>
522 if (is_materialized()) {
526 return do_materialize_global();
532template <
class Var_type>
538 if (is_materialized(unsafe_thd)) {
542 return do_materialize_all(unsafe_thd);
548template <
class Var_type>
554 if (is_materialized(unsafe_thd)) {
558 return do_materialize_session(unsafe_thd);
564template <
class Var_type>
571 if (is_materialized(pfs_thread)) {
579 m_use_mem_root = use_mem_root;
581 return do_materialize_session(pfs_thread);
587template <
class Var_type>
600 return do_materialize_session(pfs_thread, index);
744 bool nested_array,
bool strict);
Base class to find specific thd from the thd list.
Definition: mysqld_thd_manager.h:64
Get and lock a validated THD from the thread manager.
Definition: pfs_variable.h:242
THD * m_unsafe_thd
Definition: pfs_variable.h:251
void set_unsafe_thd(THD *unsafe_thd)
Definition: pfs_variable.h:248
Find_THD_variable()
Definition: pfs_variable.h:244
Find_THD_variable(THD *unsafe_thd)
Definition: pfs_variable.h:245
bool operator()(THD *thd) override
Override this operator to provide implementation to find specific thd.
Definition: pfs_variable.cc:53
static Global_THD_manager * get_instance()
Retrieves singleton instance.
Definition: mysqld_thd_manager.h:213
THD_ptr find_thd(Find_THD_Impl *func)
Returns a THD_ptr containing first THD for which operator() returns true.
Definition: mysqld_thd_manager.cc:321
Status variable cache.
Definition: pfs_variable.h:678
int do_materialize_client(PFS_client *pfs_client)
Build cache of SESSION status variables using the status values provided.
Definition: pfs_variable.cc:1365
void expand_show_var_array(const SHOW_VAR *show_var_array, const char *prefix, bool strict)
Expand a nested sub array of status variables, indicated by a type of SHOW_ARRAY.
Definition: pfs_variable.cc:1074
bool filter_by_name(const SHOW_VAR *show_var)
Definition: pfs_variable.cc:939
int do_materialize_all(THD *thd) override
Build GLOBAL and SESSION status variable cache using values for a non-instrumented thread.
Definition: pfs_variable.cc:1225
bool m_show_command
Definition: pfs_variable.h:694
int materialize_host(PFS_host *pfs_host)
Build cache of SESSION status variables for a host.
Definition: pfs_variable.cc:865
bool do_initialize_session() override
Build an internal SHOW_VAR array from the external status variable array.
Definition: pfs_variable.cc:1139
int do_materialize_session(THD *thd) override
Build SESSION status variable cache using values for a non-instrumented thread.
Definition: pfs_variable.cc:1273
bool can_aggregate(enum_mysql_show_type variable_type)
Check that the variable type is aggregatable.
Definition: pfs_variable.cc:960
char * make_show_var_name(const char *prefix, const char *name, char *name_buf, size_t buf_len)
Build the complete status variable name, with prefix.
Definition: pfs_variable.cc:1102
void(* m_sum_client_status)(PFS_client *pfs_client, System_status_var *status_totals)
Definition: pfs_variable.h:708
int do_materialize_session(PFS_thread *, uint) override
Definition: pfs_variable.h:704
PFS_status_variable_cache(bool external_init)
CLASS PFS_status_variable_cache.
Definition: pfs_variable.cc:833
ulonglong get_status_array_version()
Definition: pfs_variable.h:686
void manifest(THD *thd, const SHOW_VAR *show_var_array, System_status_var *status_vars, const char *prefix, bool nested_array, bool strict)
Definition: pfs_variable.cc:1406
bool filter_show_var(const SHOW_VAR *show_var, bool strict)
Check if a status variable should be excluded from the query.
Definition: pfs_variable.cc:1007
int materialize_account(PFS_account *pfs_account)
Build cache of SESSION status variables for an account.
Definition: pfs_variable.cc:886
int materialize_user(PFS_user *pfs_user)
Build cache of SESSION status variables for a user.
Definition: pfs_variable.cc:844
virtual PFS_client * get_pfs(PFS_thread *)
Definition: pfs_variable.h:691
int do_materialize_global() override
Build cache for GLOBAL status variables using values totaled from all threads.
Definition: pfs_variable.cc:1173
bool init_show_var_array(enum_var_type scope, bool strict)
Build an array of SHOW_VARs from the global status array.
Definition: pfs_variable.cc:1033
bool match_scope(SHOW_SCOPE variable_scope, bool strict)
Compare status variable scope to desired scope.
Definition: pfs_variable.cc:909
System_status_var * set_status_vars()
For the current THD, use initial_status_vars taken from before the query start.
Definition: pfs_variable.cc:1158
Persisted variables cache.
Definition: pfs_variable.h:664
int do_materialize_all(THD *thd) override
CLASS PFS_system_persisted_variables_cache.
Definition: pfs_variable.cc:510
~PFS_system_persisted_variables_cache() override=default
PFS_system_persisted_variables_cache(bool external_init)
Definition: pfs_variable.h:666
System variable cache.
Definition: pfs_variable.h:606
int do_materialize_session(THD *thd) override
Build a SESSION system variable cache for a THD.
Definition: pfs_variable.cc:398
void set_mem_root()
Allocate and assign mem_root for system variable materialization.
Definition: pfs_variable.cc:247
MEM_ROOT m_mem_sysvar
Definition: pfs_variable.h:626
bool init_show_var_array(enum_var_type scope, bool strict)
Build a sorted list of all system variables from the system variable hash.
Definition: pfs_variable.cc:87
MEM_ROOT * m_mem_sysvar_ptr
Definition: pfs_variable.h:632
MEM_ROOT ** m_mem_thd
Definition: pfs_variable.h:628
void free_mem_root()
Free the temporary mem_root.
Definition: pfs_variable.cc:274
PFS_system_variable_cache(bool external_init)
Definition: pfs_variable.cc:77
~PFS_system_variable_cache() override
Definition: pfs_variable.h:611
ulonglong get_sysvar_hash_version()
Definition: pfs_variable.h:610
int do_materialize_all(THD *thd) override
Build a GLOBAL and SESSION system variable cache.
Definition: pfs_variable.cc:196
MEM_ROOT * m_mem_thd_save
Definition: pfs_variable.h:630
int do_materialize_global() override
Build a GLOBAL system variable cache.
Definition: pfs_variable.cc:156
bool match_scope(int scope)
Match system variable scope to desired scope.
Definition: pfs_variable.cc:132
void clear_mem_root()
Mark memory blocks in the temporary mem_root as free.
Definition: pfs_variable.cc:261
bool do_initialize_session() override
Build an array of SHOW_VARs from the system variable hash.
Definition: pfs_variable.cc:118
System variable info cache.
Definition: pfs_variable.h:650
int do_materialize_all(THD *thd) override
CLASS PFS_system_variable_info_cache.
Definition: pfs_variable.cc:456
PFS_system_variable_info_cache(bool external_init)
Definition: pfs_variable.h:652
~PFS_system_variable_info_cache() override=default
Base class for a system or status variable cache.
Definition: pfs_variable.h:258
virtual int do_materialize_session(PFS_thread *)
Definition: pfs_variable.h:401
THD_ptr get_THD(THD *thd)
Get a validated THD from the thread manager.
Definition: pfs_variable.h:468
bool is_materialized()
True if variables have been materialized.
Definition: pfs_variable.h:322
bool m_materialized
Definition: pfs_variable.h:436
PFS_client * m_pfs_client
Definition: pfs_variable.h:418
bool initialize_session()
Build array of SHOW_VARs from the external variable source.
Definition: pfs_variable.h:493
THD * m_unsafe_thd
Definition: pfs_variable.h:409
bool is_materialized(PFS_client *pfs_client)
True if variables have been materialized for given PFS_user/host/account.
Definition: pfs_variable.h:365
virtual int do_materialize_session(THD *)
Definition: pfs_variable.h:400
virtual int do_materialize_global()
Definition: pfs_variable.h:398
ulonglong m_version
Definition: pfs_variable.h:445
virtual int do_materialize_all(THD *)
Definition: pfs_variable.h:399
bool initialize_client_session()
Build array of SHOW_VARs suitable for aggregation by user, host or account.
Definition: pfs_variable.h:506
PFS_thread * m_pfs_thread
Definition: pfs_variable.h:415
bool m_external_init
Definition: pfs_variable.h:433
int materialize_session(PFS_thread *pfs_thread, uint index)
Cache a single SESSION variable for an instrumented thread.
Definition: pfs_variable.h:588
bool is_materialized(PFS_user *pfs_user)
True if variables have been materialized for given PFS_user.
Definition: pfs_variable.h:341
bool is_materialized(PFS_thread *pfs_thread)
True if variables have been materialized for given PFS_thread.
Definition: pfs_variable.h:334
bool m_use_mem_root
Definition: pfs_variable.h:451
Variable_array m_cache
Definition: pfs_variable.h:424
int materialize_session(THD *thd)
Build cache of SESSION variables for a non-instrumented thread.
Definition: pfs_variable.h:549
THD_ptr get_THD(PFS_thread *pfs_thread)
Definition: pfs_variable.h:483
PFS_variable_cache(bool external_init)
Definition: pfs_variable.cc:59
THD * m_current_thd
Definition: pfs_variable.h:412
int materialize_user(PFS_user *pfs_user)
Build cache of SESSION status variables for a user.
Prealloced_array< Var_type, SYSTEM_VARIABLE_PREALLOC > Variable_array
Definition: pfs_variable.h:260
uint size()
Number of elements in the cache.
Definition: pfs_variable.h:393
virtual int do_materialize_session(PFS_thread *, uint)
Definition: pfs_variable.h:402
int materialize_global()
Build cache of GLOBAL system or status variables.
Definition: pfs_variable.h:521
Show_var_array m_show_var_array
Definition: pfs_variable.h:439
int materialize_session(PFS_thread *pfs_thread, bool use_mem_root=false)
Build cache of SESSION variables for an instrumented thread.
Definition: pfs_variable.h:565
THD * m_safe_thd
Definition: pfs_variable.h:406
virtual ~PFS_variable_cache()=0
Destructor.
virtual bool do_initialize_session()
Definition: pfs_variable.h:397
bool is_materialized(PFS_host *pfs_host)
True if variables have been materialized for given PFS_host.
Definition: pfs_variable.h:349
const Var_type * get(uint index=0) const
Get a single variable from the cache.
Definition: pfs_variable.h:381
int materialize_host(PFS_host *pfs_host)
Build cache of SESSION status variables for a host.
bool is_materialized(PFS_account *pfs_account)
True if variables have been materialized for given PFS_account.
Definition: pfs_variable.h:357
Find_THD_variable m_thd_finder
Definition: pfs_variable.h:421
bool m_initialized
Definition: pfs_variable.h:427
System_variable_tracker::Array m_sys_var_tracker_array
Definition: pfs_variable.h:442
enum_var_type m_query_scope
Definition: pfs_variable.h:448
bool is_materialized(THD *unsafe_thd)
True if variables have been materialized for given THD.
Definition: pfs_variable.h:327
int materialize_account(PFS_account *pfs_account)
Build cache of SESSION status variables for an account.
bool m_aggregate
Definition: pfs_variable.h:454
virtual bool do_initialize_global()
Definition: pfs_variable.h:396
int materialize_all(THD *thd)
Build cache of GLOBAL and SESSION variables for a non-instrumented thread.
Definition: pfs_variable.h:533
Element_type & at(size_t n)
Definition: prealloced_array.h:231
size_t size() const
Definition: prealloced_array.h:227
Status variable derived from SHOW_VAR.
Definition: pfs_variable.h:208
bool m_initialized
Definition: pfs_variable.h:234
bool is_null() const
Definition: pfs_variable.h:222
size_t m_name_length
Definition: pfs_variable.h:226
Status_variable()
Definition: pfs_variable.h:210
size_t m_value_length
Definition: pfs_variable.h:228
char m_value_str[SHOW_VAR_FUNC_BUFF_SIZE+1]
Definition: pfs_variable.h:227
SHOW_SCOPE m_scope
Definition: pfs_variable.h:230
void init(const SHOW_VAR *show_var, System_status_var *status_vars, enum_var_type query_scope)
Resolve status value, convert to string.
Definition: pfs_variable.cc:1492
const CHARSET_INFO * m_charset
Definition: pfs_variable.h:231
const char * m_name
Definition: pfs_variable.h:225
SHOW_TYPE m_type
Definition: pfs_variable.h:229
System variable derived from sys_var object.
Definition: pfs_variable.h:169
size_t m_value_length
Definition: pfs_variable.h:182
size_t m_path_length
Definition: pfs_variable.h:188
char m_set_user_str[USERNAME_LENGTH]
Definition: pfs_variable.h:194
char m_set_host_str[HOSTNAME_LENGTH]
Definition: pfs_variable.h:196
bool m_initialized
Definition: pfs_variable.h:200
void init(THD *thd, const SHOW_VAR *show_var, enum_var_type query_scope)
Get sys_var value from global or local source then convert to string.
Definition: pfs_variable.cc:689
char m_min_value_str[SHOW_VAR_FUNC_BUFF_SIZE+1]
Definition: pfs_variable.h:189
const char * m_name
Definition: pfs_variable.h:179
size_t m_set_host_str_length
Definition: pfs_variable.h:197
int m_scope
Definition: pfs_variable.h:184
char m_value_str[SHOW_VAR_FUNC_BUFF_SIZE+1]
Definition: pfs_variable.h:181
bool is_null() const
Definition: pfs_variable.h:176
char m_max_value_str[SHOW_VAR_FUNC_BUFF_SIZE+1]
Definition: pfs_variable.h:191
enum_mysql_show_type m_type
Definition: pfs_variable.h:183
enum_variable_source m_source
Definition: pfs_variable.h:186
size_t m_name_length
Definition: pfs_variable.h:180
size_t m_min_value_length
Definition: pfs_variable.h:190
ulonglong m_set_time
Definition: pfs_variable.h:193
char m_path_str[SHOW_VAR_FUNC_BUFF_SIZE+1]
Definition: pfs_variable.h:187
const CHARSET_INFO * m_charset
Definition: pfs_variable.h:185
System_variable()
CLASS System_variable.
Definition: pfs_variable.cc:608
size_t m_set_user_str_length
Definition: pfs_variable.h:195
size_t m_max_value_length
Definition: pfs_variable.h:192
This class encapsulates THD instance, controls access to the actual THD.
Definition: mysqld_thd_manager.h:98
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
const char * p
Definition: ctype-mb.cc:1237
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
static constexpr int HOSTNAME_LENGTH
Definition: my_hostname.h:43
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
#define USERNAME_LENGTH
Definition: mysql_com.h:69
SHOW_VAR status_vars[]
Definition: mysqld.cc:9662
Performance schema account (declarations).
Performance schema host (declarations).
Performance schema instruments (declarations).
Performance schema user (declarations).
void sum_host_status(PFS_client *pfs_host, System_status_var *status_totals)
Definition: pfs_variable.cc:1533
bool status_vars_inited
Definition: sql_show.cc:3246
Status_var_array all_status_vars
void sum_user_status(PFS_client *pfs_user, System_status_var *status_totals)
Definition: pfs_variable.cc:1522
static const uint SYSVAR_MEMROOT_BLOCK_SIZE
Definition: pfs_variable.h:158
void status_variable_warning()
Warning issued if the global status variable array changes during a query.
Definition: pfs_variable.cc:1579
void system_variable_warning()
Warning issued if the version of the system variable hash table changes during a query.
Definition: pfs_variable.cc:1568
void sum_account_status(PFS_client *pfs_account, System_status_var *status_totals)
Definition: pfs_variable.cc:1545
Prealloced_array< SHOW_VAR, SYSTEM_VARIABLE_PREALLOC > Show_var_array
Definition: pfs_variable.h:153
PFS_connection_slice PFS_client
Definition: pfs_variable.h:163
std::vector< SHOW_VAR > Status_var_array
Definition: pfs_variable.h:149
mysql_mutex_t LOCK_plugin_delete
Definition: sql_plugin.cc:437
"public" interface to sys_var - server configuration variables.
enum enum_mysql_show_type SHOW_TYPE
Definition: set_var.h:73
enum enum_mysql_show_scope SHOW_SCOPE
Definition: set_var.h:74
enum_var_type
Definition: set_var.h:90
std::vector< SHOW_VAR > Status_var_array
Definition: sql_show.cc:3243
case opt name
Definition: sslopt-case.h:33
enum_mysql_show_type
Declarations for SHOW STATUS support in plugins.
Definition: status_var.h:30
@ SHOW_UNDEF
Definition: status_var.h:31
#define SHOW_VAR_FUNC_BUFF_SIZE
Definition: status_var.h:87
@ SHOW_SCOPE_UNDEF
Definition: status_var.h:69
Definition: m_ctype.h:385
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Per account statistics.
Definition: pfs_account.h:67
A connection slice, an arbitrary grouping of several connections.
Definition: pfs_con_slice.h:54
Per host statistics.
Definition: pfs_host.h:64
Instrumented thread implementation.
Definition: pfs_instr.h:373
pfs_lock m_lock
Internal lock.
Definition: pfs_instr.h:457
THD * m_thd
Definition: pfs_instr.h:644
Per user statistics.
Definition: pfs_user.h:63
SHOW STATUS Server status variable.
Definition: status_var.h:79
Per thread status variables.
Definition: system_variables.h:511
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50
bool is_populated()
Returns true if the record contains values that can be read.
Definition: pfs_lock.h:189
enum_variable_source
This enum values define how system variables are set.
Definition: system_variable_source_type.h:33
unsigned int uint
Definition: uca9-dump.cc:75