MySQL 8.0.31
Source Code Documentation
table_uvar_by_thread.h
Go to the documentation of this file.
1/* Copyright (c) 2013, 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#ifndef TABLE_UVAR_BY_THREAD_H
24#define TABLE_UVAR_BY_THREAD_H
25
26/**
27 @file storage/perfschema/table_uvar_by_thread.h
28 Table USER_VARIABLES_BY_THREAD (declarations).
29*/
30
31#include <assert.h>
32#include <stddef.h>
33#include <sys/types.h>
34
35#include "my_base.h"
36
37#include "my_inttypes.h"
39#include "prealloced_array.h"
43
44class Field;
45class Plugin_table;
46class THD;
47struct TABLE;
48struct THR_LOCK;
49
50/**
51 @addtogroup performance_schema_tables
52 @{
53*/
54
56 public:
57 User_variable() = default;
58
59 User_variable(const User_variable &uv) = default;
60
61 ~User_variable() = default;
62
65};
66
69
70 public:
73
74 void reset() {
75 m_pfs = nullptr;
77 m_array.clear();
78 }
79
80 void materialize(PFS_thread *pfs, THD *thd);
81
83 assert(pfs != nullptr);
84 if (m_pfs != pfs) {
85 return false;
86 }
87 if (m_thread_internal_id != pfs->m_thread_internal_id) {
88 return false;
89 }
90 return true;
91 }
92
93 const User_variable *get(uint index) const {
94 if (index >= m_array.size()) {
95 return nullptr;
96 }
97
98 const User_variable *p = &m_array.at(index);
99 return p;
100 }
101
102 private:
106};
107
108/**
109 A row of table
110 PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD.
111*/
113 /** Column THREAD_ID. */
115 /** Column VARIABLE_NAME. */
117 /** Column VARIABLE_VALUE. */
119};
120
121/**
122 Position of a cursor on
123 PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD.
124 Index 1 on thread (0 based)
125 Index 2 on user variable (0 based)
126*/
129
130 inline void reset(void) {
131 m_index_1 = 0;
132 m_index_2 = 0;
133 }
134
135 inline void next_thread(void) {
136 m_index_1++;
137 m_index_2 = 0;
138 }
139};
140
142 public:
145 m_key_1("THREAD_ID"),
146 m_key_2("VARIABLE_NAME") {}
147
148 ~PFS_index_uvar_by_thread() override = default;
149
150 virtual bool match(PFS_thread *pfs);
151 virtual bool match(const User_variable *pfs);
152
153 private:
156};
157
158/** Table PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD. */
161
162 public:
163 /** Table share */
166 static ha_rows get_row_count();
167
168 void reset_position(void) override;
169
170 int rnd_next() override;
171 int rnd_pos(const void *pos) override;
172
173 int index_init(uint idx, bool sorted) override;
174 int index_next() override;
175
176 protected:
177 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
178 bool read_all) override;
179
181
182 public:
184
185 protected:
186 int materialize(PFS_thread *thread);
187 int make_row(PFS_thread *thread, const User_variable *uvar);
188
189 private:
190 /** Table share lock. */
192 /** Table definition. */
194
195 /** Current THD user variables. */
197 /** Current row. */
199 /** Current position. */
201 /** Next position. */
203
205};
206
207/** @} */
208#endif
Definition: field.h:574
Definition: pfs_engine_table.h:299
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:69
Definition: table_uvar_by_thread.h:141
PFS_key_thread_id m_key_1
Definition: table_uvar_by_thread.h:154
PFS_key_variable_name m_key_2
Definition: table_uvar_by_thread.h:155
~PFS_index_uvar_by_thread() override=default
PFS_index_uvar_by_thread()
Definition: table_uvar_by_thread.h:143
virtual bool match(PFS_thread *pfs)
Definition: table_uvar_by_thread.cc:151
Definition: table_helper.h:1250
Definition: table_helper.h:1531
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:39
void clear()
Removes (and destroys) all elements.
Definition: prealloced_array.h:600
Element_type & at(size_t n)
Definition: prealloced_array.h:230
size_t size() const
Definition: prealloced_array.h:226
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:922
Definition: table_uvar_by_thread.h:67
void reset()
Definition: table_uvar_by_thread.h:74
PFS_thread * m_pfs
Definition: table_uvar_by_thread.h:103
User_variables()
Definition: table_uvar_by_thread.h:71
bool is_materialized(PFS_thread *pfs)
Definition: table_uvar_by_thread.h:82
User_variable_array m_array
Definition: table_uvar_by_thread.h:105
void materialize(PFS_thread *pfs, THD *thd)
Definition: table_uvar_by_thread.cc:66
Prealloced_array< User_variable, 100 > User_variable_array
Definition: table_uvar_by_thread.h:68
ulonglong m_thread_internal_id
Definition: table_uvar_by_thread.h:104
const User_variable * get(uint index) const
Definition: table_uvar_by_thread.h:93
Table PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD.
Definition: table_uvar_by_thread.h:159
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_uvar_by_thread.cc:217
int index_init(uint idx, bool sorted) override
Definition: table_uvar_by_thread.cc:235
static THR_LOCK m_table_lock
Table share lock.
Definition: table_uvar_by_thread.h:191
pos_uvar_by_thread pos_t
Definition: table_uvar_by_thread.h:160
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_uvar_by_thread.cc:194
int make_row(PFS_thread *thread, const User_variable *uvar)
Definition: table_uvar_by_thread.cc:298
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:318
User_variables m_THD_cache
Current THD user variables.
Definition: table_uvar_by_thread.h:196
static PFS_engine_table_share m_share
Table share.
Definition: table_uvar_by_thread.h:164
int index_next() override
Find key in index, read record.
Definition: table_uvar_by_thread.cc:244
static Plugin_table m_table_def
Table definition.
Definition: table_uvar_by_thread.h:193
~table_uvar_by_thread() override
Definition: table_uvar_by_thread.h:183
int materialize(PFS_thread *thread)
Definition: table_uvar_by_thread.cc:274
pos_t m_pos
Current position.
Definition: table_uvar_by_thread.h:200
void reset_position(void) override
Reset the cursor position to the beginning of the table.
Definition: table_uvar_by_thread.cc:189
row_uvar_by_thread m_row
Current row.
Definition: table_uvar_by_thread.h:198
static ha_rows get_row_count()
Definition: table_uvar_by_thread.cc:173
PFS_index_uvar_by_thread * m_opened_index
Definition: table_uvar_by_thread.h:204
table_uvar_by_thread()
Definition: table_uvar_by_thread.cc:186
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_uvar_by_thread.cc:169
pos_t m_next_pos
Next position.
Definition: table_uvar_by_thread.h:202
const char * p
Definition: ctype-mb.cc:1236
char * pos
Definition: do_ctype.cc:76
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
static constexpr unsigned PSI_INSTRUMENT_ME
Definition: psi_bits.h:42
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1139
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Definition: buf0block_hint.cc:29
Performance schema tables (declarations).
Performance schema instruments (declarations).
Performance schema instrumentation interface.
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:65
Position of a double cursor, for iterations using 2 nested loops.
Definition: pfs_engine_table.h:593
uint m_index_1
Outer index.
Definition: pfs_engine_table.h:595
uint m_index_2
Current index within index_1.
Definition: pfs_engine_table.h:597
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:357
Instrumented thread implementation.
Definition: pfs_instr.h:372
Definition: table_helper.h:1121
Definition: table_helper.h:1086
Definition: table.h:1396
Definition: thr_lock.h:138
Definition: table_uvar_by_thread.h:55
~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:64
PFS_variable_name_row m_name
Definition: table_uvar_by_thread.h:63
Position of a cursor on PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD.
Definition: table_uvar_by_thread.h:127
void reset(void)
Definition: table_uvar_by_thread.h:130
void next_thread(void)
Definition: table_uvar_by_thread.h:135
pos_uvar_by_thread()
Definition: table_uvar_by_thread.h:128
A row of table PERFORMANCE_SCHEMA.USER_VARIABLES_BY_THREAD.
Definition: table_uvar_by_thread.h:112
ulonglong m_thread_internal_id
Column THREAD_ID.
Definition: table_uvar_by_thread.h:114
const PFS_variable_name_row * m_variable_name
Column VARIABLE_NAME.
Definition: table_uvar_by_thread.h:116
const PFS_user_variable_value_row * m_variable_value
Column VARIABLE_VALUE.
Definition: table_uvar_by_thread.h:118
Helpers to implement a performance schema table.
unsigned int uint
Definition: uca-dump.cc:29