MySQL 9.1.0
Source Code Documentation
table_events_statements.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 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_EVENTS_STATEMENTS_H
25#define TABLE_EVENTS_STATEMENTS_H
26
27/**
28 @file storage/perfschema/table_events_statements.h
29 Table EVENTS_STATEMENTS_xxx (declarations).
30*/
31
32#include <sys/types.h>
33
34#include "my_base.h"
35#include "my_inttypes.h"
36#include "mysql_com.h"
37#include "sql/sql_digest.h"
38#include "sql_string.h"
43
44class Field;
45class Plugin_table;
46struct PFS_events;
48struct PFS_thread;
49struct TABLE;
50struct THR_LOCK;
51
52/**
53 @addtogroup performance_schema_tables
54 @{
55*/
56
58 public:
61 m_key_1("THREAD_ID"),
62 m_key_2("EVENT_ID") {}
63
64 ~PFS_index_events_statements() override = default;
65
66 bool match(PFS_thread *pfs);
67 bool match(PFS_events *pfs);
68
69 private:
72};
73
74/** A row of table_events_statements_common. */
76 /** Column THREAD_ID. */
78 /** Column EVENT_ID. */
80 /** Column END_EVENT_ID. */
82 /** Column NESTING_EVENT_ID. */
84 /** Column NESTING_EVENT_TYPE. */
86 /** Column NESTING_EVENT_LEVEL. */
88 /** Column EVENT_NAME. */
89 const char *m_name;
90 /** Length in bytes of @c m_name. */
92 /** Column TIMER_START. */
94 /** Column TIMER_END. */
96 /** Column TIMER_WAIT. */
98 /** Column LOCK_TIME. */
100 /** Column SOURCE. */
102 /** Length in bytes of @c m_source. */
104 /** Column SQL_TEXT. */
106 /** Column DIGEST and DIGEST_TEXT. */
108 /** Column CURRENT_SCHEMA. */
110
111 /** Column OBJECT_TYPE. */
113 /** Column OBJECT_SCHEMA. */
115 /** Column OBJECT_NAME. */
117
118 /** Column MESSAGE_TEXT. */
121 /** Column MYSQL_ERRNO. */
123 /** Column RETURNED_SQLSTATE. */
125 /** Column ERRORS. */
127 /** Column WARNINGS. */
129 /** Column ROWS_AFFECTED. */
131 /** Column ROWS_SENT. */
133 /** Column ROWS_EXAMINED. */
135 /** Column CREATED_TMP_DISK_TABLES. */
137 /** Column CREATED_TMP_TABLES. */
139 /** Column SELECT_FULL_JOIN. */
141 /** Column SELECT_FULL_RANGE_JOIN. */
143 /** Column SELECT_RANGE. */
145 /** Column SELECT_RANGE_CHECK. */
147 /** Column SELECT_SCAN. */
149 /** Column SORT_MERGE_PASSES. */
151 /** Column SORT_RANGE. */
153 /** Column SORT_ROWS. */
155 /** Column SORT_SCAN. */
157 /** Column NO_INDEX_USED. */
159 /** Column NO_GOOD_INDEX_USED. */
161 /** Column CPU_TIME. */
163 /** Column MAX_CONTROLLED_MEMORY. */
165 /** Column MAX_TOTAL_MEMORY. */
167
168 /** Column STATEMENT_ID. */
170 /** Column EXECUTION_ENGINE. */
172};
173
174/** Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT. */
177
178 inline void reset() {
179 m_index_1 = 0;
180 m_index_2 = 0;
181 }
182
183 inline void next_thread() {
184 m_index_1++;
185 m_index_2 = 0;
186 }
187};
188
189/** Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY. */
192
193 inline void reset() {
194 m_index_1 = 0;
195 m_index_2 = 0;
196 }
197
198 inline void next_thread() {
199 m_index_1++;
200 m_index_2 = 0;
201 }
202};
203
204/**
205 Adapter, for table sharing the structure of
206 PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
207*/
209 protected:
210 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
211 bool read_all) override;
212
214 void *pos);
215
217
219 sql_digest_storage *digest);
220
221 int make_row_part_2(const sql_digest_storage *digest);
222
223 /** Current row. */
226};
227
228/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT. */
230 public:
231 /** Table share */
234 static int delete_all_rows();
235 static ha_rows get_row_count();
236
237 void reset_position() override;
238
239 int rnd_init(bool scan) override;
240 int rnd_next() override;
241 int rnd_pos(const void *pos) override;
242
243 int index_init(uint idx, bool sorted) override;
244 int index_next() override;
245
246 protected:
248
249 public:
251
252 private:
255
256 /** Table share lock. */
258 /** Table definition. */
260
262
263 /** Current position. */
265 /** Next position. */
267
269};
270
271/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY. */
273 public:
274 /** Table share */
277 static int delete_all_rows();
278 static ha_rows get_row_count();
279
280 int index_init(uint idx, bool sorted) override;
281 int index_next() override;
282
283 int rnd_init(bool scan) override;
284 int rnd_next() override;
285 int rnd_pos(const void *pos) override;
286 void reset_position() override;
287
288 protected:
290
291 public:
293
294 private:
295 /** Table share lock. */
297 /** Table definition. */
299
301
302 /** Current position. */
304 /** Next position. */
306
308};
309
310/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY_LONG. */
313 public:
314 /** Table share */
317 static int delete_all_rows();
318 static ha_rows get_row_count();
319
320 int rnd_init(bool scan) override;
321 int rnd_next() override;
322 int rnd_pos(const void *pos) override;
323 void reset_position() override;
324
325 protected:
327
328 public:
330
331 private:
332 /** Table share lock. */
334 /** Table definition. */
336
338
339 /** Current position. */
341 /** Next position. */
343};
344
345/** @} */
346#endif
Definition: field.h:577
Definition: pfs_engine_table.h:301
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:70
Definition: table_events_statements.h:57
bool match(PFS_thread *pfs)
Definition: table_events_statements.cc:271
PFS_key_event_id m_key_2
Definition: table_events_statements.h:71
~PFS_index_events_statements() override=default
PFS_key_thread_id m_key_1
Definition: table_events_statements.h:70
PFS_index_events_statements()
Definition: table_events_statements.h:59
Definition: table_helper.h:1295
Definition: table_helper.h:1279
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
Adapter, for table sharing the structure of PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
Definition: table_events_statements.h:208
unsigned char m_token_array[MAX_DIGEST_STORAGE_SIZE]
Definition: table_events_statements.h:225
int make_row_part_2(const sql_digest_storage *digest)
Build a row, part 2.
Definition: table_events_statements.cc:398
~table_events_statements_common() override=default
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_events_statements.cc:423
int make_row_part_1(PFS_events_statements *statement, sql_digest_storage *digest)
Build a row, part 1.
Definition: table_events_statements.cc:304
row_events_statements m_row
Current row.
Definition: table_events_statements.h:224
table_events_statements_common(const PFS_engine_table_share *share, void *pos)
Definition: table_events_statements.cc:289
Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
Definition: table_events_statements.h:229
pos_events_statements_current m_next_pos
Next position.
Definition: table_events_statements.h:266
static int delete_all_rows()
Definition: table_events_statements.cc:795
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_statements.cc:662
static PFS_engine_table_share m_share
Table share.
Definition: table_events_statements.h:232
~table_events_statements_current() override=default
PFS_index_events_statements * m_opened_index
Definition: table_events_statements.h:268
static ha_rows get_row_count()
Definition: table_events_statements.cc:800
static Plugin_table m_table_def
Table definition.
Definition: table_events_statements.h:259
int index_init(uint idx, bool sorted) override
Definition: table_events_statements.cc:804
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_events_statements.cc:655
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_statements.h:257
int index_next() override
Find key in index, read record.
Definition: table_events_statements.cc:728
int make_row(PFS_thread *pfs_thread, PFS_events_statements *statement)
Definition: table_events_statements.cc:770
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_statements.cc:695
pos_events_statements_current m_pos
Current position.
Definition: table_events_statements.h:264
table_events_statements_current()
Definition: table_events_statements.cc:651
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_statements.cc:646
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_statements.cc:660
Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY_LONG.
Definition: table_events_statements.h:312
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_statements.cc:990
int make_row(PFS_events_statements *statement)
Definition: table_events_statements.cc:1046
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_statements.cc:988
PFS_simple_index m_next_pos
Next position.
Definition: table_events_statements.h:342
PFS_simple_index m_pos
Current position.
Definition: table_events_statements.h:340
~table_events_statements_history_long() override=default
static int delete_all_rows()
Definition: table_events_statements.cc:1059
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_statements.cc:973
table_events_statements_history_long()
Definition: table_events_statements.cc:978
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_statements.cc:1017
static PFS_engine_table_share m_share
Table share.
Definition: table_events_statements.h:315
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_events_statements.cc:983
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_statements.h:333
static Plugin_table m_table_def
Table definition.
Definition: table_events_statements.h:335
static ha_rows get_row_count()
Definition: table_events_statements.cc:1064
Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY.
Definition: table_events_statements.h:272
static int delete_all_rows()
Definition: table_events_statements.cc:953
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_statements.cc:828
static Plugin_table m_table_def
Table definition.
Definition: table_events_statements.h:298
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_statements.h:296
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_statements.cc:866
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_statements.cc:814
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_statements.cc:830
static PFS_engine_table_share m_share
Table share.
Definition: table_events_statements.h:275
PFS_index_events_statements * m_opened_index
Definition: table_events_statements.h:307
int index_init(uint idx, bool sorted) override
Definition: table_events_statements.cc:963
int index_next() override
Find key in index, read record.
Definition: table_events_statements.cc:889
static ha_rows get_row_count()
Definition: table_events_statements.cc:958
table_events_statements_history()
Definition: table_events_statements.cc:819
pos_events_statements_history m_pos
Current position.
Definition: table_events_statements.h:303
int make_row(PFS_thread *pfs_thread, PFS_events_statements *statement)
Definition: table_events_statements.cc:932
pos_events_statements_history m_next_pos
Next position.
Definition: table_events_statements.h:305
~table_events_statements_history() override=default
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_events_statements.cc:823
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1141
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Common definition between mysql server & client.
#define MYSQL_ERRMSG_SIZE
Max length of a error message.
Definition: mysql_com.h:881
#define SQLSTATE_LENGTH
Definition: mysql_com.h:75
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: buf0block_hint.cc:30
Data types for columns used in the performance schema tables (declarations)
#define COL_SOURCE_SIZE
Size of the SOURCE columns, in bytes.
Definition: pfs_column_types.h:76
enum_event_type
Enum values for the NESTING_EVENT_TYPE columns.
Definition: pfs_column_types.h:275
enum_object_type
Enum values for the various OBJECT_TYPE columns.
Definition: pfs_column_types.h:227
Performance schema tables (declarations).
Object names (declarations).
#define MAX_DIGEST_STORAGE_SIZE
Definition: sql_digest.h:34
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:66
Our own string classes, used pervasively throughout the executor.
Row fragment for columns DIGEST, DIGEST_TEXT.
Definition: table_helper.h:566
Position of a double cursor, for iterations using 2 nested loops.
Definition: pfs_engine_table.h:602
uint m_index_1
Outer index.
Definition: pfs_engine_table.h:604
uint m_index_2
Current index within index_1.
Definition: pfs_engine_table.h:606
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:359
A statement record.
Definition: pfs_events_statements.h:47
An event record.
Definition: pfs_events.h:38
Definition: pfs_name.h:344
Definition: pfs_name.h:194
Position of a cursor, for simple iterations.
Definition: pfs_engine_table.h:567
Instrumented thread implementation.
Definition: pfs_instr.h:375
Definition: table.h:1421
Definition: thr_lock.h:139
Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
Definition: table_events_statements.h:175
pos_events_statements_current()
Definition: table_events_statements.h:176
void reset()
Definition: table_events_statements.h:178
void next_thread()
Definition: table_events_statements.h:183
Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY.
Definition: table_events_statements.h:190
pos_events_statements_history()
Definition: table_events_statements.h:191
void reset()
Definition: table_events_statements.h:193
void next_thread()
Definition: table_events_statements.h:198
A row of table_events_statements_common.
Definition: table_events_statements.h:75
ulonglong m_select_scan
Column SELECT_SCAN.
Definition: table_events_statements.h:148
ulonglong m_sort_range
Column SORT_RANGE.
Definition: table_events_statements.h:152
ulonglong m_sort_rows
Column SORT_ROWS.
Definition: table_events_statements.h:154
ulonglong m_sort_scan
Column SORT_SCAN.
Definition: table_events_statements.h:156
ulonglong m_timer_start
Column TIMER_START.
Definition: table_events_statements.h:93
PFS_schema_name m_schema_name
Column OBJECT_SCHEMA.
Definition: table_events_statements.h:114
PFS_schema_name m_current_schema_name
Column CURRENT_SCHEMA.
Definition: table_events_statements.h:109
ulonglong m_statement_id
Column STATEMENT_ID.
Definition: table_events_statements.h:169
ulonglong m_timer_end
Column TIMER_END.
Definition: table_events_statements.h:95
const char * m_name
Column EVENT_NAME.
Definition: table_events_statements.h:89
PFS_object_name m_object_name
Column OBJECT_NAME.
Definition: table_events_statements.h:116
uint m_warning_count
Column WARNINGS.
Definition: table_events_statements.h:128
char m_message_text[MYSQL_ERRMSG_SIZE+1]
Column MESSAGE_TEXT.
Definition: table_events_statements.h:119
ulonglong m_no_index_used
Column NO_INDEX_USED.
Definition: table_events_statements.h:158
ulonglong m_sort_merge_passes
Column SORT_MERGE_PASSES.
Definition: table_events_statements.h:150
String m_sqltext
Column SQL_TEXT.
Definition: table_events_statements.h:105
bool m_secondary
Column EXECUTION_ENGINE.
Definition: table_events_statements.h:171
ulonglong m_no_good_index_used
Column NO_GOOD_INDEX_USED.
Definition: table_events_statements.h:160
ulonglong m_timer_wait
Column TIMER_WAIT.
Definition: table_events_statements.h:97
ulonglong m_max_controlled_memory
Column MAX_CONTROLLED_MEMORY.
Definition: table_events_statements.h:164
ulonglong m_select_range
Column SELECT_RANGE.
Definition: table_events_statements.h:144
ulonglong m_lock_time
Column LOCK_TIME.
Definition: table_events_statements.h:99
enum_event_type m_nesting_event_type
Column NESTING_EVENT_TYPE.
Definition: table_events_statements.h:85
ulonglong m_select_range_check
Column SELECT_RANGE_CHECK.
Definition: table_events_statements.h:146
uint m_name_length
Length in bytes of m_name.
Definition: table_events_statements.h:91
ulonglong m_thread_internal_id
Column THREAD_ID.
Definition: table_events_statements.h:77
ulonglong m_created_tmp_disk_tables
Column CREATED_TMP_DISK_TABLES.
Definition: table_events_statements.h:136
ulonglong m_select_full_join
Column SELECT_FULL_JOIN.
Definition: table_events_statements.h:140
ulonglong m_rows_examined
Column ROWS_EXAMINED.
Definition: table_events_statements.h:134
char m_source[COL_SOURCE_SIZE]
Column SOURCE.
Definition: table_events_statements.h:101
ulonglong m_nesting_event_id
Column NESTING_EVENT_ID.
Definition: table_events_statements.h:83
ulonglong m_rows_affected
Column ROWS_AFFECTED.
Definition: table_events_statements.h:130
ulonglong m_select_full_range_join
Column SELECT_FULL_RANGE_JOIN.
Definition: table_events_statements.h:142
uint m_nesting_event_level
Column NESTING_EVENT_LEVEL.
Definition: table_events_statements.h:87
char m_sqlstate[SQLSTATE_LENGTH]
Column RETURNED_SQLSTATE.
Definition: table_events_statements.h:124
ulonglong m_cpu_time
Column CPU_TIME.
Definition: table_events_statements.h:162
ulonglong m_rows_sent
Column ROWS_SENT.
Definition: table_events_statements.h:132
uint m_source_length
Length in bytes of m_source.
Definition: table_events_statements.h:103
uint m_message_text_length
Definition: table_events_statements.h:120
enum_object_type m_object_type
Column OBJECT_TYPE.
Definition: table_events_statements.h:112
ulonglong m_created_tmp_tables
Column CREATED_TMP_TABLES.
Definition: table_events_statements.h:138
ulonglong m_event_id
Column EVENT_ID.
Definition: table_events_statements.h:79
ulonglong m_end_event_id
Column END_EVENT_ID.
Definition: table_events_statements.h:81
PFS_digest_row m_digest
Column DIGEST and DIGEST_TEXT.
Definition: table_events_statements.h:107
uint m_sql_errno
Column MYSQL_ERRNO.
Definition: table_events_statements.h:122
uint m_error_count
Column ERRORS.
Definition: table_events_statements.h:126
ulonglong m_max_total_memory
Column MAX_TOTAL_MEMORY.
Definition: table_events_statements.h:166
Structure to store token count/array for a statement on which digest is to be calculated.
Definition: sql_digest.h:98
Definition: mysqlslap.cc:219
Helpers to implement a performance schema table.