MySQL 8.0.29
Source Code Documentation
pfs_user.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef PFS_USER_H
25#define PFS_USER_H
26
27/**
28 @file storage/perfschema/pfs_user.h
29 Performance schema user (declarations).
30*/
31
32#include <sys/types.h>
33#include <atomic>
34
35#include "lf.h"
36#include "my_inttypes.h"
37#include "mysql_com.h"
42
43struct PFS_global_param;
47struct PFS_thread;
48
49/**
50 @addtogroup performance_schema_buffers
51 @{
52*/
53
54/** Hash key for a user. */
56 /** User name. */
58};
59
60/** Per user statistics. */
62 public:
63 inline void init_refcount(void) { m_refcount.store(1); }
64
65 inline int get_refcount(void) { return m_refcount.load(); }
66
67 inline void inc_refcount(void) { ++m_refcount; }
68
69 inline void dec_refcount(void) { --m_refcount; }
70
71 void aggregate(bool alive);
72 void aggregate_waits(void);
73 void aggregate_stages(void);
74 void aggregate_statements(void);
75 void aggregate_transactions(void);
76 void aggregate_errors(void);
77 void aggregate_memory(bool alive);
78 void aggregate_status(void);
79 void aggregate_stats(void);
80 void release(void);
81
82 /** Reset all memory statistics. */
83 void rebase_memory_stats();
84
85 void carry_memory_stat_alloc_delta(PFS_memory_stat_alloc_delta *delta,
86 uint index);
87 void carry_memory_stat_free_delta(PFS_memory_stat_free_delta *delta,
88 uint index);
89
91 m_has_memory_stats = false;
92 m_instr_class_memory_stats = array;
93 }
94
96 if (!m_has_memory_stats) {
97 return nullptr;
98 }
99 return m_instr_class_memory_stats;
100 }
101
103 if (!m_has_memory_stats) {
104 rebase_memory_stats();
105 m_has_memory_stats = true;
106 }
107 return m_instr_class_memory_stats;
108 }
109
110 /** Internal lock. */
113
115
116 private:
117 std::atomic<int> m_refcount;
118
119 /**
120 Per user memory aggregated statistics.
121 This member holds the data for the table
122 PERFORMANCE_SCHEMA.MEMORY_SUMMARY_BY_USER_BY_EVENT_NAME.
123 Immutable, safe to use without internal lock.
124 */
126};
127
128int init_user(const PFS_global_param *param);
129void cleanup_user(void);
130int init_user_hash(const PFS_global_param *param);
131void cleanup_user_hash(void);
132
134
136void purge_all_user(void);
137
138/* For show status. */
139
140extern LF_HASH user_hash;
141
142/** @} */
143#endif
int init_user_hash(const PFS_global_param *param)
Initialize the user hash.
Definition: pfs_user.cc:121
void cleanup_user_hash(void)
Cleanup the user hash.
Definition: pfs_user.cc:132
void purge_all_user(void)
Purge non connected users, reset stats of connected users.
Definition: pfs_user.cc:337
void cleanup_user(void)
Cleanup all the user buffers.
Definition: pfs_user.cc:65
LF_HASH user_hash
Definition: pfs_user.cc:48
int init_user(const PFS_global_param *param)
Initialize the user buffers.
Definition: pfs_user.cc:56
PFS_user * find_or_create_user(PFS_thread *thread, const PFS_user_name *user)
Definition: pfs_user.cc:153
PFS_user * sanitize_user(PFS_user *unsafe)
Definition: pfs_user.cc:296
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Common definition between mysql server & client.
char * user
Definition: mysqladmin.cc:59
Performance schema connection slice (declarations).
Miscellaneous global dependencies (declarations).
#define PFS_ALIGNED
Definition: pfs_global.h:54
Performance schema internal locks (declarations).
Object names (declarations).
Definition: lf.h:184
A connection slice, an arbitrary grouping of several connections.
Definition: pfs_con_slice.h:53
Performance schema global sizing parameters.
Definition: pfs_server.h:112
Definition: pfs_stat.h:919
Definition: pfs_stat.h:865
Definition: pfs_stat.h:870
Instrumented thread implementation.
Definition: pfs_instr.h:372
Hash key for a user.
Definition: pfs_user.h:55
PFS_user_name m_user_name
User name.
Definition: pfs_user.h:57
Definition: pfs_name.h:220
Per user statistics.
Definition: pfs_user.h:61
int get_refcount(void)
Definition: pfs_user.h:65
const PFS_memory_shared_stat * read_instr_class_memory_stats() const
Definition: pfs_user.h:95
std::atomic< int > m_refcount
Definition: pfs_user.h:117
void inc_refcount(void)
Definition: pfs_user.h:67
PFS_memory_shared_stat * m_instr_class_memory_stats
Per user memory aggregated statistics.
Definition: pfs_user.h:125
PFS_memory_shared_stat * write_instr_class_memory_stats()
Definition: pfs_user.h:102
void set_instr_class_memory_stats(PFS_memory_shared_stat *array)
Definition: pfs_user.h:90
ulonglong m_disconnected_count
Definition: pfs_user.h:114
pfs_lock m_lock
Internal lock.
Definition: pfs_user.h:111
void dec_refcount(void)
Definition: pfs_user.h:69
PFS_user_key m_key
Definition: pfs_user.h:112
void init_refcount(void)
Definition: pfs_user.h:63
A 'lock' protecting performance schema internal buffers.
Definition: pfs_lock.h:151
unsigned int uint
Definition: uca-dump.cc:29
static void alive(server *s)
Definition: xcom_transport.cc:159