140#include <sys/types.h>
152#define SYSTEM_VARIABLE_PREALLOC 200
259template <
class Var_type>
383 const Var_type *
get(uint index = 0)
const {
462template <
class Var_type>
469template <
class Var_type>
471 if (unsafe_thd ==
nullptr) {
480 m_thd_finder.set_unsafe_thd(unsafe_thd);
484template <
class Var_type>
486 assert(pfs_thread !=
nullptr);
487 return get_THD(pfs_thread->
m_thd);
494template <
class Var_type>
500 return do_initialize_session();
507template <
class Var_type>
516 return do_initialize_session();
522template <
class Var_type>
524 if (is_materialized()) {
528 return do_materialize_global();
534template <
class Var_type>
540 if (is_materialized(unsafe_thd)) {
544 return do_materialize_all(unsafe_thd);
550template <
class Var_type>
556 if (is_materialized(unsafe_thd)) {
560 return do_materialize_session(unsafe_thd);
566template <
class Var_type>
573 if (is_materialized(pfs_thread)) {
581 m_use_mem_root = use_mem_root;
583 return do_materialize_session(pfs_thread);
589template <
class Var_type>
602 return do_materialize_session(pfs_thread, index);
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
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:244
THD * m_unsafe_thd
Definition: pfs_variable.h:253
void set_unsafe_thd(THD *unsafe_thd)
Definition: pfs_variable.h:250
Find_THD_variable()
Definition: pfs_variable.h:246
Find_THD_variable(THD *unsafe_thd)
Definition: pfs_variable.h:247
bool operator()(THD *thd) override
Override this operator to provide implementation to find specific thd.
Definition: pfs_variable.cc:55
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:335
Status variable cache.
Definition: pfs_variable.h:680
int do_materialize_client(PFS_client *pfs_client)
Build cache of SESSION status variables using the status values provided.
Definition: pfs_variable.cc:1349
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:1061
bool filter_by_name(const SHOW_VAR *show_var)
Definition: pfs_variable.cc:928
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:1212
bool m_show_command
Definition: pfs_variable.h:696
int materialize_host(PFS_host *pfs_host)
Build cache of SESSION status variables for a host.
Definition: pfs_variable.cc:860
bool do_initialize_session() override
Build an internal SHOW_VAR array from the external status variable array.
Definition: pfs_variable.cc:1126
int do_materialize_session(THD *thd) override
Build SESSION status variable cache using values for a non-instrumented thread.
Definition: pfs_variable.cc:1259
bool can_aggregate(enum_mysql_show_type variable_type)
Check that the variable type is aggregatable.
Definition: pfs_variable.cc:949
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:1089
void(* m_sum_client_status)(PFS_client *pfs_client, System_status_var *status_totals)
Definition: pfs_variable.h:710
int do_materialize_session(PFS_thread *, uint) override
Definition: pfs_variable.h:706
PFS_status_variable_cache(bool external_init)
CLASS PFS_status_variable_cache.
Definition: pfs_variable.cc:828
void manifest(THD *thd, const SHOW_VAR *show_var_array, System_status_var *vars, const char *prefix, bool nested_array, bool strict)
Definition: pfs_variable.cc:1390
ulonglong get_status_array_version()
Definition: pfs_variable.h:688
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:994
int materialize_account(PFS_account *pfs_account)
Build cache of SESSION status variables for an account.
Definition: pfs_variable.cc:881
int materialize_user(PFS_user *pfs_user)
Build cache of SESSION status variables for a user.
Definition: pfs_variable.cc:839
virtual PFS_client * get_pfs(PFS_thread *)
Definition: pfs_variable.h:693
int do_materialize_global() override
Build cache for GLOBAL status variables using values totaled from all threads.
Definition: pfs_variable.cc:1160
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:1020
bool match_scope(SHOW_SCOPE variable_scope, bool strict)
Compare status variable scope to desired scope.
Definition: pfs_variable.cc:904
System_status_var * set_status_vars()
For the current THD, use initial_status_vars taken from before the query start.
Definition: pfs_variable.cc:1145
Persisted variables cache.
Definition: pfs_variable.h:666
int do_materialize_all(THD *thd) override
CLASS PFS_system_persisted_variables_cache.
Definition: pfs_variable.cc:505
~PFS_system_persisted_variables_cache() override=default
PFS_system_persisted_variables_cache(bool external_init)
Definition: pfs_variable.h:668
System variable cache.
Definition: pfs_variable.h:608
int do_materialize_session(THD *thd) override
Build a SESSION system variable cache for a THD.
Definition: pfs_variable.cc:393
void set_mem_root()
Allocate and assign mem_root for system variable materialization.
Definition: pfs_variable.cc:242
MEM_ROOT m_mem_sysvar
Definition: pfs_variable.h:628
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:88
MEM_ROOT * m_mem_sysvar_ptr
Definition: pfs_variable.h:634
MEM_ROOT ** m_mem_thd
Definition: pfs_variable.h:630
void free_mem_root()
Free the temporary mem_root.
Definition: pfs_variable.cc:269
PFS_system_variable_cache(bool external_init)
Definition: pfs_variable.cc:78
~PFS_system_variable_cache() override
Definition: pfs_variable.h:613
ulonglong get_sysvar_hash_version()
Definition: pfs_variable.h:612
int do_materialize_all(THD *thd) override
Build a GLOBAL and SESSION system variable cache.
Definition: pfs_variable.cc:191
MEM_ROOT * m_mem_thd_save
Definition: pfs_variable.h:632
int do_materialize_global() override
Build a GLOBAL system variable cache.
Definition: pfs_variable.cc:151
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:256
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:652
int do_materialize_all(THD *thd) override
CLASS PFS_system_variable_info_cache.
Definition: pfs_variable.cc:451
PFS_system_variable_info_cache(bool external_init)
Definition: pfs_variable.h:654
~PFS_system_variable_info_cache() override=default
Base class for a system or status variable cache.
Definition: pfs_variable.h:260
virtual int do_materialize_session(PFS_thread *)
Definition: pfs_variable.h:403
THD_ptr get_THD(THD *thd)
Get a validated THD from the thread manager.
Definition: pfs_variable.h:470
bool is_materialized()
True if variables have been materialized.
Definition: pfs_variable.h:324
bool m_materialized
Definition: pfs_variable.h:438
PFS_client * m_pfs_client
Definition: pfs_variable.h:420
bool initialize_session()
Build array of SHOW_VARs from the external variable source.
Definition: pfs_variable.h:495
THD * m_unsafe_thd
Definition: pfs_variable.h:411
bool is_materialized(PFS_client *pfs_client)
True if variables have been materialized for given PFS_user/host/account.
Definition: pfs_variable.h:367
virtual int do_materialize_session(THD *)
Definition: pfs_variable.h:402
virtual int do_materialize_global()
Definition: pfs_variable.h:400
ulonglong m_version
Definition: pfs_variable.h:447
virtual int do_materialize_all(THD *)
Definition: pfs_variable.h:401
bool initialize_client_session()
Build array of SHOW_VARs suitable for aggregation by user, host or account.
Definition: pfs_variable.h:508
PFS_thread * m_pfs_thread
Definition: pfs_variable.h:417
bool m_external_init
Definition: pfs_variable.h:435
int materialize_session(PFS_thread *pfs_thread, uint index)
Cache a single SESSION variable for an instrumented thread.
Definition: pfs_variable.h:590
bool is_materialized(PFS_user *pfs_user)
True if variables have been materialized for given PFS_user.
Definition: pfs_variable.h:343
bool is_materialized(PFS_thread *pfs_thread)
True if variables have been materialized for given PFS_thread.
Definition: pfs_variable.h:336
bool m_use_mem_root
Definition: pfs_variable.h:453
Variable_array m_cache
Definition: pfs_variable.h:426
int materialize_session(THD *thd)
Build cache of SESSION variables for a non-instrumented thread.
Definition: pfs_variable.h:551
THD_ptr get_THD(PFS_thread *pfs_thread)
Definition: pfs_variable.h:485
PFS_variable_cache(bool external_init)
Definition: pfs_variable.cc:61
THD * m_current_thd
Definition: pfs_variable.h:414
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:262
uint size()
Number of elements in the cache.
Definition: pfs_variable.h:395
virtual int do_materialize_session(PFS_thread *, uint)
Definition: pfs_variable.h:404
int materialize_global()
Build cache of GLOBAL system or status variables.
Definition: pfs_variable.h:523
Show_var_array m_show_var_array
Definition: pfs_variable.h:441
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:567
THD * m_safe_thd
Definition: pfs_variable.h:408
virtual ~PFS_variable_cache()=0
Destructor.
virtual bool do_initialize_session()
Definition: pfs_variable.h:399
bool is_materialized(PFS_host *pfs_host)
True if variables have been materialized for given PFS_host.
Definition: pfs_variable.h:351
const Var_type * get(uint index=0) const
Get a single variable from the cache.
Definition: pfs_variable.h:383
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:359
Find_THD_variable m_thd_finder
Definition: pfs_variable.h:423
bool m_initialized
Definition: pfs_variable.h:429
System_variable_tracker::Array m_sys_var_tracker_array
Definition: pfs_variable.h:444
enum_var_type m_query_scope
Definition: pfs_variable.h:450
bool is_materialized(THD *unsafe_thd)
True if variables have been materialized for given THD.
Definition: pfs_variable.h:329
int materialize_account(PFS_account *pfs_account)
Build cache of SESSION status variables for an account.
bool m_aggregate
Definition: pfs_variable.h:456
virtual bool do_initialize_global()
Definition: pfs_variable.h:398
int materialize_all(THD *thd)
Build cache of GLOBAL and SESSION variables for a non-instrumented thread.
Definition: pfs_variable.h:535
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:236
bool is_null() const
Definition: pfs_variable.h:224
size_t m_name_length
Definition: pfs_variable.h:228
Status_variable()
Definition: pfs_variable.h:210
size_t m_value_length
Definition: pfs_variable.h:230
char m_value_str[SHOW_VAR_FUNC_BUFF_SIZE+1]
Definition: pfs_variable.h:229
SHOW_SCOPE m_scope
Definition: pfs_variable.h:232
const CHARSET_INFO * m_charset
Definition: pfs_variable.h:233
const char * m_name
Definition: pfs_variable.h:227
SHOW_TYPE m_type
Definition: pfs_variable.h:231
void init(const SHOW_VAR *show_var, System_status_var *vars, enum_var_type query_scope)
Resolve status value, convert to string.
Definition: pfs_variable.cc:1476
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:684
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:603
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:36
const char * p
Definition: ctype-mb.cc:1225
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
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:1515
bool status_vars_inited
Definition: sql_show.cc:3250
Status_var_array all_status_vars
void sum_user_status(PFS_client *pfs_user, System_status_var *status_totals)
Definition: pfs_variable.cc:1504
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:1561
void system_variable_warning()
Warning issued if the version of the system variable hash table changes during a query.
Definition: pfs_variable.cc:1550
void sum_account_status(PFS_client *pfs_account, System_status_var *status_totals)
Definition: pfs_variable.cc:1527
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:439
"public" interface to sys_var - server configuration variables.
enum enum_mysql_show_type SHOW_TYPE
Definition: set_var.h:75
enum enum_mysql_show_scope SHOW_SCOPE
Definition: set_var.h:76
enum_var_type
Definition: set_var.h:92
std::vector< SHOW_VAR > Status_var_array
Definition: sql_show.cc:3247
case opt name
Definition: sslopt-case.h:29
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:421
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:375
pfs_lock m_lock
Internal lock.
Definition: pfs_instr.h:459
THD * m_thd
Definition: pfs_instr.h:646
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:525
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