MySQL 8.0.31
Source Code Documentation
table_events_statements.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#ifndef TABLE_EVENTS_STATEMENTS_H
24#define TABLE_EVENTS_STATEMENTS_H
25
26/**
27 @file storage/perfschema/table_events_statements.h
28 Table EVENTS_STATEMENTS_xxx (declarations).
29*/
30
31#include <sys/types.h>
32
33#include "my_base.h"
34#include "my_inttypes.h"
35#include "mysql_com.h"
36#include "sql/sql_digest.h"
37#include "sql_string.h"
42
43class Field;
44class Plugin_table;
45struct PFS_events;
47struct PFS_thread;
48struct TABLE;
49struct THR_LOCK;
50
51/**
52 @addtogroup performance_schema_tables
53 @{
54*/
55
57 public:
60 m_key_1("THREAD_ID"),
61 m_key_2("EVENT_ID") {}
62
63 ~PFS_index_events_statements() override = default;
64
65 bool match(PFS_thread *pfs);
66 bool match(PFS_events *pfs);
67
68 private:
71};
72
73/** A row of table_events_statements_common. */
75 /** Column THREAD_ID. */
77 /** Column EVENT_ID. */
79 /** Column END_EVENT_ID. */
81 /** Column NESTING_EVENT_ID. */
83 /** Column NESTING_EVENT_TYPE. */
85 /** Column NESTING_EVENT_LEVEL. */
87 /** Column EVENT_NAME. */
88 const char *m_name;
89 /** Length in bytes of @c m_name. */
91 /** Column TIMER_START. */
93 /** Column TIMER_END. */
95 /** Column TIMER_WAIT. */
97 /** Column LOCK_TIME. */
99 /** Column SOURCE. */
101 /** Length in bytes of @c m_source. */
103 /** Column SQL_TEXT. */
105 /** Column DIGEST and DIGEST_TEXT. */
107 /** Column CURRENT_SCHEMA. */
109
110 /** Column OBJECT_TYPE. */
112 /** Column OBJECT_SCHEMA. */
114 /** Column OBJECT_NAME. */
116
117 /** Column MESSAGE_TEXT. */
119 /** Column MYSQL_ERRNO. */
121 /** Column RETURNED_SQLSTATE. */
123 /** Column ERRORS. */
125 /** Column WARNINGS. */
127 /** Column ROWS_AFFECTED. */
129 /** Column ROWS_SENT. */
131 /** Column ROWS_EXAMINED. */
133 /** Column CREATED_TMP_DISK_TABLES. */
135 /** Column CREATED_TMP_TABLES. */
137 /** Column SELECT_FULL_JOIN. */
139 /** Column SELECT_FULL_RANGE_JOIN. */
141 /** Column SELECT_RANGE. */
143 /** Column SELECT_RANGE_CHECK. */
145 /** Column SELECT_SCAN. */
147 /** Column SORT_MERGE_PASSES. */
149 /** Column SORT_RANGE. */
151 /** Column SORT_ROWS. */
153 /** Column SORT_SCAN. */
155 /** Column NO_INDEX_USED. */
157 /** Column NO_GOOD_INDEX_USED. */
159 /** Column CPU_TIME. */
161 /** Column MAX_CONTROLLED_MEMORY. */
163 /** Column MAX_TOTAL_MEMORY. */
165
166 /** Column STATEMENT_ID. */
168 /** Column EXECUTION_ENGINE. */
170};
171
172/** Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT. */
175
176 inline void reset(void) {
177 m_index_1 = 0;
178 m_index_2 = 0;
179 }
180
181 inline void next_thread(void) {
182 m_index_1++;
183 m_index_2 = 0;
184 }
185};
186
187/** Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY. */
190
191 inline void reset(void) {
192 m_index_1 = 0;
193 m_index_2 = 0;
194 }
195
196 inline void next_thread(void) {
197 m_index_1++;
198 m_index_2 = 0;
199 }
200};
201
202/**
203 Adapter, for table sharing the structure of
204 PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
205*/
207 protected:
208 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
209 bool read_all) override;
210
212 void *pos);
213
215
217 sql_digest_storage *digest);
218
219 int make_row_part_2(const sql_digest_storage *digest);
220
221 /** Current row. */
224};
225
226/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT. */
228 public:
229 /** Table share */
232 static int delete_all_rows();
233 static ha_rows get_row_count();
234
235 void reset_position(void) override;
236
237 int rnd_init(bool scan) override;
238 int rnd_next() override;
239 int rnd_pos(const void *pos) override;
240
241 int index_init(uint idx, bool sorted) override;
242 int index_next() override;
243
244 protected:
246
247 public:
249
250 private:
253
254 /** Table share lock. */
256 /** Table definition. */
258
260
261 /** Current position. */
263 /** Next position. */
265
267};
268
269/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY. */
271 public:
272 /** Table share */
275 static int delete_all_rows();
276 static ha_rows get_row_count();
277
278 int index_init(uint idx, bool sorted) override;
279 int index_next() override;
280
281 int rnd_init(bool scan) override;
282 int rnd_next() override;
283 int rnd_pos(const void *pos) override;
284 void reset_position(void) override;
285
286 protected:
288
289 public:
291
292 private:
293 /** Table share lock. */
295 /** Table definition. */
297
299
300 /** Current position. */
302 /** Next position. */
304
306};
307
308/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY_LONG. */
311 public:
312 /** Table share */
315 static int delete_all_rows();
316 static ha_rows get_row_count();
317
318 int rnd_init(bool scan) override;
319 int rnd_next() override;
320 int rnd_pos(const void *pos) override;
321 void reset_position(void) override;
322
323 protected:
325
326 public:
328
329 private:
330 /** Table share lock. */
332 /** Table definition. */
334
336
337 /** Current position. */
339 /** Next position. */
341};
342
343/** @} */
344#endif
Definition: field.h:574
Definition: pfs_engine_table.h:299
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:69
Definition: table_events_statements.h:56
bool match(PFS_thread *pfs)
Definition: table_events_statements.cc:270
PFS_key_event_id m_key_2
Definition: table_events_statements.h:70
~PFS_index_events_statements() override=default
PFS_key_thread_id m_key_1
Definition: table_events_statements.h:69
PFS_index_events_statements()
Definition: table_events_statements.h:58
Definition: table_helper.h:1266
Definition: table_helper.h:1250
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:39
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
Adapter, for table sharing the structure of PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
Definition: table_events_statements.h:206
unsigned char m_token_array[MAX_DIGEST_STORAGE_SIZE]
Definition: table_events_statements.h:223
int make_row_part_2(const sql_digest_storage *digest)
Build a row, part 2.
Definition: table_events_statements.cc:392
~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:417
int make_row_part_1(PFS_events_statements *statement, sql_digest_storage *digest)
Build a row, part 1.
Definition: table_events_statements.cc:303
row_events_statements m_row
Current row.
Definition: table_events_statements.h:222
table_events_statements_common(const PFS_engine_table_share *share, void *pos)
Definition: table_events_statements.cc:288
Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
Definition: table_events_statements.h:227
pos_events_statements_current m_next_pos
Next position.
Definition: table_events_statements.h:264
static int delete_all_rows()
Definition: table_events_statements.cc:788
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_statements.cc:655
static PFS_engine_table_share m_share
Table share.
Definition: table_events_statements.h:230
~table_events_statements_current() override=default
PFS_index_events_statements * m_opened_index
Definition: table_events_statements.h:266
static ha_rows get_row_count()
Definition: table_events_statements.cc:793
static Plugin_table m_table_def
Table definition.
Definition: table_events_statements.h:257
int index_init(uint idx, bool sorted) override
Definition: table_events_statements.cc:797
void reset_position(void) override
Reset the cursor position to the beginning of the table.
Definition: table_events_statements.cc:648
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_statements.h:255
int index_next() override
Find key in index, read record.
Definition: table_events_statements.cc:721
int make_row(PFS_thread *pfs_thread, PFS_events_statements *statement)
Definition: table_events_statements.cc:763
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_statements.cc:687
pos_events_statements_current m_pos
Current position.
Definition: table_events_statements.h:262
table_events_statements_current()
Definition: table_events_statements.cc:645
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_statements.cc:640
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_statements.cc:653
Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY_LONG.
Definition: table_events_statements.h:310
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_statements.cc:984
int make_row(PFS_events_statements *statement)
Definition: table_events_statements.cc:1040
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_statements.cc:982
PFS_simple_index m_next_pos
Next position.
Definition: table_events_statements.h:340
PFS_simple_index m_pos
Current position.
Definition: table_events_statements.h:338
~table_events_statements_history_long() override=default
void reset_position(void) override
Reset the cursor position to the beginning of the table.
Definition: table_events_statements.cc:977
static int delete_all_rows()
Definition: table_events_statements.cc:1053
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_statements.cc:967
table_events_statements_history_long()
Definition: table_events_statements.cc:972
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_statements.cc:1011
static PFS_engine_table_share m_share
Table share.
Definition: table_events_statements.h:313
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_statements.h:331
static Plugin_table m_table_def
Table definition.
Definition: table_events_statements.h:333
static ha_rows get_row_count()
Definition: table_events_statements.cc:1058
Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY.
Definition: table_events_statements.h:270
static int delete_all_rows()
Definition: table_events_statements.cc:947
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_statements.cc:820
static Plugin_table m_table_def
Table definition.
Definition: table_events_statements.h:296
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_statements.h:294
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_statements.cc:858
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_statements.cc:807
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_statements.cc:822
static PFS_engine_table_share m_share
Table share.
Definition: table_events_statements.h:273
PFS_index_events_statements * m_opened_index
Definition: table_events_statements.h:305
int index_init(uint idx, bool sorted) override
Definition: table_events_statements.cc:957
int index_next() override
Find key in index, read record.
Definition: table_events_statements.cc:883
static ha_rows get_row_count()
Definition: table_events_statements.cc:952
table_events_statements_history()
Definition: table_events_statements.cc:812
void reset_position(void) override
Reset the cursor position to the beginning of the table.
Definition: table_events_statements.cc:815
pos_events_statements_history m_pos
Current position.
Definition: table_events_statements.h:301
int make_row(PFS_thread *pfs_thread, PFS_events_statements *statement)
Definition: table_events_statements.cc:926
pos_events_statements_history m_next_pos
Next position.
Definition: table_events_statements.h:303
~table_events_statements_history() override=default
char * pos
Definition: do_ctype.cc:76
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
Common definition between mysql server & client.
#define MYSQL_ERRMSG_SIZE
Max length of a error message.
Definition: mysql_com.h:877
#define SQLSTATE_LENGTH
Definition: mysql_com.h:74
Definition: buf0block_hint.cc:29
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:75
enum_event_type
Enum values for the NESTING_EVENT_TYPE columns.
Definition: pfs_column_types.h:270
enum_object_type
Enum values for the various OBJECT_TYPE columns.
Definition: pfs_column_types.h:221
Performance schema tables (declarations).
Object names (declarations).
#define MAX_DIGEST_STORAGE_SIZE
Definition: sql_digest.h:33
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:65
Our own string classes, used pervasively throughout the executor.
Row fragment for columns DIGEST, DIGEST_TEXT.
Definition: table_helper.h:564
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
A statement record.
Definition: pfs_events_statements.h:46
An event record.
Definition: pfs_events.h:37
Definition: pfs_name.h:182
Definition: pfs_name.h:115
Position of a cursor, for simple iterations.
Definition: pfs_engine_table.h:558
Instrumented thread implementation.
Definition: pfs_instr.h:372
Definition: table.h:1396
Definition: thr_lock.h:138
Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
Definition: table_events_statements.h:173
pos_events_statements_current()
Definition: table_events_statements.h:174
void reset(void)
Definition: table_events_statements.h:176
void next_thread(void)
Definition: table_events_statements.h:181
Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY.
Definition: table_events_statements.h:188
pos_events_statements_history()
Definition: table_events_statements.h:189
void next_thread(void)
Definition: table_events_statements.h:196
void reset(void)
Definition: table_events_statements.h:191
A row of table_events_statements_common.
Definition: table_events_statements.h:74
ulonglong m_select_scan
Column SELECT_SCAN.
Definition: table_events_statements.h:146
ulonglong m_sort_range
Column SORT_RANGE.
Definition: table_events_statements.h:150
ulonglong m_sort_rows
Column SORT_ROWS.
Definition: table_events_statements.h:152
ulonglong m_sort_scan
Column SORT_SCAN.
Definition: table_events_statements.h:154
ulonglong m_timer_start
Column TIMER_START.
Definition: table_events_statements.h:92
PFS_schema_name m_schema_name
Column OBJECT_SCHEMA.
Definition: table_events_statements.h:113
PFS_schema_name m_current_schema_name
Column CURRENT_SCHEMA.
Definition: table_events_statements.h:108
ulonglong m_statement_id
Column STATEMENT_ID.
Definition: table_events_statements.h:167
ulonglong m_timer_end
Column TIMER_END.
Definition: table_events_statements.h:94
const char * m_name
Column EVENT_NAME.
Definition: table_events_statements.h:88
PFS_object_name m_object_name
Column OBJECT_NAME.
Definition: table_events_statements.h:115
uint m_warning_count
Column WARNINGS.
Definition: table_events_statements.h:126
char m_message_text[MYSQL_ERRMSG_SIZE+1]
Column MESSAGE_TEXT.
Definition: table_events_statements.h:118
ulonglong m_no_index_used
Column NO_INDEX_USED.
Definition: table_events_statements.h:156
ulonglong m_sort_merge_passes
Column SORT_MERGE_PASSES.
Definition: table_events_statements.h:148
String m_sqltext
Column SQL_TEXT.
Definition: table_events_statements.h:104
bool m_secondary
Column EXECUTION_ENGINE.
Definition: table_events_statements.h:169
ulonglong m_no_good_index_used
Column NO_GOOD_INDEX_USED.
Definition: table_events_statements.h:158
ulonglong m_timer_wait
Column TIMER_WAIT.
Definition: table_events_statements.h:96
ulonglong m_max_controlled_memory
Column MAX_CONTROLLED_MEMORY.
Definition: table_events_statements.h:162
ulonglong m_select_range
Column SELECT_RANGE.
Definition: table_events_statements.h:142
ulonglong m_lock_time
Column LOCK_TIME.
Definition: table_events_statements.h:98
enum_event_type m_nesting_event_type
Column NESTING_EVENT_TYPE.
Definition: table_events_statements.h:84
ulonglong m_select_range_check
Column SELECT_RANGE_CHECK.
Definition: table_events_statements.h:144
uint m_name_length
Length in bytes of m_name.
Definition: table_events_statements.h:90
ulonglong m_thread_internal_id
Column THREAD_ID.
Definition: table_events_statements.h:76
ulonglong m_created_tmp_disk_tables
Column CREATED_TMP_DISK_TABLES.
Definition: table_events_statements.h:134
ulonglong m_select_full_join
Column SELECT_FULL_JOIN.
Definition: table_events_statements.h:138
ulonglong m_rows_examined
Column ROWS_EXAMINED.
Definition: table_events_statements.h:132
char m_source[COL_SOURCE_SIZE]
Column SOURCE.
Definition: table_events_statements.h:100
ulonglong m_nesting_event_id
Column NESTING_EVENT_ID.
Definition: table_events_statements.h:82
ulonglong m_rows_affected
Column ROWS_AFFECTED.
Definition: table_events_statements.h:128
ulonglong m_select_full_range_join
Column SELECT_FULL_RANGE_JOIN.
Definition: table_events_statements.h:140
uint m_nesting_event_level
Column NESTING_EVENT_LEVEL.
Definition: table_events_statements.h:86
char m_sqlstate[SQLSTATE_LENGTH]
Column RETURNED_SQLSTATE.
Definition: table_events_statements.h:122
ulonglong m_cpu_time
Column CPU_TIME.
Definition: table_events_statements.h:160
ulonglong m_rows_sent
Column ROWS_SENT.
Definition: table_events_statements.h:130
uint m_source_length
Length in bytes of m_source.
Definition: table_events_statements.h:102
enum_object_type m_object_type
Column OBJECT_TYPE.
Definition: table_events_statements.h:111
ulonglong m_created_tmp_tables
Column CREATED_TMP_TABLES.
Definition: table_events_statements.h:136
ulonglong m_event_id
Column EVENT_ID.
Definition: table_events_statements.h:78
ulonglong m_end_event_id
Column END_EVENT_ID.
Definition: table_events_statements.h:80
PFS_digest_row m_digest
Column DIGEST and DIGEST_TEXT.
Definition: table_events_statements.h:106
uint m_sql_errno
Column MYSQL_ERRNO.
Definition: table_events_statements.h:120
uint m_error_count
Column ERRORS.
Definition: table_events_statements.h:124
ulonglong m_max_total_memory
Column MAX_TOTAL_MEMORY.
Definition: table_events_statements.h:164
Structure to store token count/array for a statement on which digest is to be calculated.
Definition: sql_digest.h:97
Definition: mysqlslap.cc:216
Helpers to implement a performance schema table.
unsigned int uint
Definition: uca-dump.cc:29