MySQL 8.0.39
Source Code Documentation
table_uvar_by_thread.h
Go to the documentation of this file.
1/* Copyright (c) 2013, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef TABLE_UVAR_BY_THREAD_H
25#define TABLE_UVAR_BY_THREAD_H
26
27/**
28 @file storage/perfschema/table_uvar_by_thread.h
29 Table USER_VARIABLES_BY_THREAD (declarations).
30*/
31
32#include <assert.h>
33#include <stddef.h>
34#include <sys/types.h>
35
36#include "my_base.h"
37
38#include "my_inttypes.h"
40#include "prealloced_array.h"
44
45class Field;
46class Plugin_table;
47class THD;
48struct TABLE;
49struct THR_LOCK;
50
51/**
52 @addtogroup performance_schema_tables
53 @{
54*/
55
57 public:
58 User_variable() = default;
59
60 User_variable(const User_variable &uv) = default;
61
62 ~User_variable() = default;
63
66};
67
70
71 public:
74
75 void reset() {
76 m_pfs = nullptr;
78 m_array.clear();
79 }
80
81 void materialize(PFS_thread *pfs, THD *thd);
82
84 assert(pfs != nullptr);
85 if (m_pfs != pfs) {
86 return false;
87 }
88 if (m_thread_internal_id != pfs->m_thread_internal_id) {
89 return false;
90 }
91 return true;
92 }
93
94 const User_variable *get(uint index) const {
95 if (index >= m_array.size()) {
96 return nullptr;
97 }
98
99 const User_variable *p = &m_array.at(index);
100 return p;
101 }
102
103 private:
107};
108
109/**
110 A row of table
111 PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD.
112*/
114 /** Column THREAD_ID. */
116 /** Column VARIABLE_NAME. */
118 /** Column VARIABLE_VALUE. */
120};
121
122/**
123 Position of a cursor on
124 PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD.
125 Index 1 on thread (0 based)
126 Index 2 on user variable (0 based)
127*/
130
131 inline void reset() {
132 m_index_1 = 0;
133 m_index_2 = 0;
134 }
135
136 inline void next_thread() {
137 m_index_1++;
138 m_index_2 = 0;
139 }
140};
141
143 public:
146 m_key_1("THREAD_ID"),
147 m_key_2("VARIABLE_NAME") {}
148
149 ~PFS_index_uvar_by_thread() override = default;
150
151 virtual bool match(PFS_thread *pfs);
152 virtual bool match(const User_variable *pfs);
153
154 private:
157};
158
159/** Table PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD. */
162
163 public:
164 /** Table share */
167 static ha_rows get_row_count();
168
169 void reset_position() override;
170
171 int rnd_next() override;
172 int rnd_pos(const void *pos) override;
173
174 int index_init(uint idx, bool sorted) override;
175 int index_next() override;
176
177 protected:
178 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
179 bool read_all) override;
180
182
183 public:
185
186 protected:
187 int materialize(PFS_thread *thread);
188 int make_row(PFS_thread *thread, const User_variable *uvar);
189
190 private:
191 /** Table share lock. */
193 /** Table definition. */
195
196 /** Current THD user variables. */
198 /** Current row. */
200 /** Current position. */
202 /** Next position. */
204
206};
207
208/** @} */
209#endif
Definition: field.h:575
Definition: pfs_engine_table.h:300
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:70
Definition: table_uvar_by_thread.h:142
PFS_key_thread_id m_key_1
Definition: table_uvar_by_thread.h:155
PFS_key_variable_name m_key_2
Definition: table_uvar_by_thread.h:156
~PFS_index_uvar_by_thread() override=default
PFS_index_uvar_by_thread()
Definition: table_uvar_by_thread.h:144
virtual bool match(PFS_thread *pfs)
Definition: table_uvar_by_thread.cc:152
Definition: table_helper.h:1278
Definition: table_helper.h:1558
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
void clear()
Removes (and destroys) all elements.
Definition: prealloced_array.h:601
Element_type & at(size_t n)
Definition: prealloced_array.h:231
size_t size() const
Definition: prealloced_array.h:227
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Definition: table_uvar_by_thread.h:68
void reset()
Definition: table_uvar_by_thread.h:75
PFS_thread * m_pfs
Definition: table_uvar_by_thread.h:104
User_variables()
Definition: table_uvar_by_thread.h:72
bool is_materialized(PFS_thread *pfs)
Definition: table_uvar_by_thread.h:83
User_variable_array m_array
Definition: table_uvar_by_thread.h:106
void materialize(PFS_thread *pfs, THD *thd)
Definition: table_uvar_by_thread.cc:67
Prealloced_array< User_variable, 100 > User_variable_array
Definition: table_uvar_by_thread.h:69
ulonglong m_thread_internal_id
Definition: table_uvar_by_thread.h:105
const User_variable * get(uint index) const
Definition: table_uvar_by_thread.h:94
Table PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD.
Definition: table_uvar_by_thread.h:160
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_uvar_by_thread.cc:218
int index_init(uint idx, bool sorted) override
Definition: table_uvar_by_thread.cc:236
static THR_LOCK m_table_lock
Table share lock.
Definition: table_uvar_by_thread.h:192
pos_uvar_by_thread pos_t
Definition: table_uvar_by_thread.h:161
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_uvar_by_thread.cc:195
int make_row(PFS_thread *thread, const User_variable *uvar)
Definition: table_uvar_by_thread.cc:299
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_uvar_by_thread.cc:319
User_variables m_THD_cache
Current THD user variables.
Definition: table_uvar_by_thread.h:197
static PFS_engine_table_share m_share
Table share.
Definition: table_uvar_by_thread.h:165
int index_next() override
Find key in index, read record.
Definition: table_uvar_by_thread.cc:245
static Plugin_table m_table_def
Table definition.
Definition: table_uvar_by_thread.h:194
~table_uvar_by_thread() override
Definition: table_uvar_by_thread.h:184
int materialize(PFS_thread *thread)
Definition: table_uvar_by_thread.cc:275
pos_t m_pos
Current position.
Definition: table_uvar_by_thread.h:201
row_uvar_by_thread m_row
Current row.
Definition: table_uvar_by_thread.h:199
static ha_rows get_row_count()
Definition: table_uvar_by_thread.cc:174
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_uvar_by_thread.cc:190
PFS_index_uvar_by_thread * m_opened_index
Definition: table_uvar_by_thread.h:205
table_uvar_by_thread()
Definition: table_uvar_by_thread.cc:187
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_uvar_by_thread.cc:170
pos_t m_next_pos
Next position.
Definition: table_uvar_by_thread.h:203
const char * p
Definition: ctype-mb.cc:1237
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
static constexpr unsigned PSI_INSTRUMENT_ME
Definition: psi_bits.h:43
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1140
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Definition: buf0block_hint.cc:30
Performance schema tables (declarations).
Performance schema instruments (declarations).
Performance schema instrumentation interface.
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:66
Position of a double cursor, for iterations using 2 nested loops.
Definition: pfs_engine_table.h:601
uint m_index_1
Outer index.
Definition: pfs_engine_table.h:603
uint m_index_2
Current index within index_1.
Definition: pfs_engine_table.h:605
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:358
Instrumented thread implementation.
Definition: pfs_instr.h:373
Definition: table_helper.h:1149
Definition: table_helper.h:1114
Definition: table.h:1399
Definition: thr_lock.h:139
Definition: table_uvar_by_thread.h:56
~User_variable()=default
User_variable()=default
User_variable(const User_variable &uv)=default
PFS_user_variable_value_row m_value
Definition: table_uvar_by_thread.h:65
PFS_variable_name_row m_name
Definition: table_uvar_by_thread.h:64
Position of a cursor on PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD.
Definition: table_uvar_by_thread.h:128
void reset()
Definition: table_uvar_by_thread.h:131
void next_thread()
Definition: table_uvar_by_thread.h:136
pos_uvar_by_thread()
Definition: table_uvar_by_thread.h:129
A row of table PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD.
Definition: table_uvar_by_thread.h:113
ulonglong m_thread_internal_id
Column THREAD_ID.
Definition: table_uvar_by_thread.h:115
const PFS_variable_name_row * m_variable_name
Column VARIABLE_NAME.
Definition: table_uvar_by_thread.h:117
const PFS_user_variable_value_row * m_variable_value
Column VARIABLE_VALUE.
Definition: table_uvar_by_thread.h:119
Helpers to implement a performance schema table.
unsigned int uint
Definition: uca9-dump.cc:75