MySQL 8.0.29
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
162 /** Column STATEMENT_ID. */
164 /** Column EXECUTION_ENGINE. */
166};
167
168/** Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT. */
171
172 inline void reset(void) {
173 m_index_1 = 0;
174 m_index_2 = 0;
175 }
176
177 inline void next_thread(void) {
178 m_index_1++;
179 m_index_2 = 0;
180 }
181};
182
183/** Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY. */
186
187 inline void reset(void) {
188 m_index_1 = 0;
189 m_index_2 = 0;
190 }
191
192 inline void next_thread(void) {
193 m_index_1++;
194 m_index_2 = 0;
195 }
196};
197
198/**
199 Adapter, for table sharing the structure of
200 PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
201*/
203 protected:
204 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
205 bool read_all) override;
206
208 void *pos);
209
211
213 sql_digest_storage *digest);
214
215 int make_row_part_2(const sql_digest_storage *digest);
216
217 /** Current row. */
220};
221
222/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT. */
224 public:
225 /** Table share */
228 static int delete_all_rows();
229 static ha_rows get_row_count();
230
231 void reset_position(void) override;
232
233 int rnd_init(bool scan) override;
234 int rnd_next() override;
235 int rnd_pos(const void *pos) override;
236
237 int index_init(uint idx, bool sorted) override;
238 int index_next() override;
239
240 protected:
242
243 public:
245
246 private:
249
250 /** Table share lock. */
252 /** Table definition. */
254
256
257 /** Current position. */
259 /** Next position. */
261
263};
264
265/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY. */
267 public:
268 /** Table share */
271 static int delete_all_rows();
272 static ha_rows get_row_count();
273
274 int index_init(uint idx, bool sorted) override;
275 int index_next() override;
276
277 int rnd_init(bool scan) override;
278 int rnd_next() override;
279 int rnd_pos(const void *pos) override;
280 void reset_position(void) override;
281
282 protected:
284
285 public:
287
288 private:
289 /** Table share lock. */
291 /** Table definition. */
293
295
296 /** Current position. */
298 /** Next position. */
300
302};
303
304/** Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY_LONG. */
307 public:
308 /** Table share */
311 static int delete_all_rows();
312 static ha_rows get_row_count();
313
314 int rnd_init(bool scan) override;
315 int rnd_next() override;
316 int rnd_pos(const void *pos) override;
317 void reset_position(void) override;
318
319 protected:
321
322 public:
324
325 private:
326 /** Table share lock. */
328 /** Table definition. */
330
332
333 /** Current position. */
335 /** Next position. */
337};
338
339/** @} */
340#endif
Definition: field.h:573
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:264
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:202
unsigned char m_token_array[MAX_DIGEST_STORAGE_SIZE]
Definition: table_events_statements.h:219
int make_row_part_2(const sql_digest_storage *digest)
Build a row, part 2.
Definition: table_events_statements.cc:384
~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:409
int make_row_part_1(PFS_events_statements *statement, sql_digest_storage *digest)
Build a row, part 1.
Definition: table_events_statements.cc:297
row_events_statements m_row
Current row.
Definition: table_events_statements.h:218
table_events_statements_common(const PFS_engine_table_share *share, void *pos)
Definition: table_events_statements.cc:282
Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
Definition: table_events_statements.h:223
pos_events_statements_current m_next_pos
Next position.
Definition: table_events_statements.h:260
static int delete_all_rows()
Definition: table_events_statements.cc:774
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_statements.cc:641
static PFS_engine_table_share m_share
Table share.
Definition: table_events_statements.h:226
~table_events_statements_current() override=default
PFS_index_events_statements * m_opened_index
Definition: table_events_statements.h:262
static ha_rows get_row_count()
Definition: table_events_statements.cc:779
static Plugin_table m_table_def
Table definition.
Definition: table_events_statements.h:253
int index_init(uint idx, bool sorted) override
Definition: table_events_statements.cc:783
void reset_position(void) override
Reset the cursor position to the beginning of the table.
Definition: table_events_statements.cc:634
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_statements.h:251
int index_next() override
Find key in index, read record.
Definition: table_events_statements.cc:707
int make_row(PFS_thread *pfs_thread, PFS_events_statements *statement)
Definition: table_events_statements.cc:749
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_statements.cc:673
pos_events_statements_current m_pos
Current position.
Definition: table_events_statements.h:258
table_events_statements_current()
Definition: table_events_statements.cc:631
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_statements.cc:626
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_statements.cc:639
Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY_LONG.
Definition: table_events_statements.h:306
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_statements.cc:970
int make_row(PFS_events_statements *statement)
Definition: table_events_statements.cc:1026
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_statements.cc:968
PFS_simple_index m_next_pos
Next position.
Definition: table_events_statements.h:336
PFS_simple_index m_pos
Current position.
Definition: table_events_statements.h:334
~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:963
static int delete_all_rows()
Definition: table_events_statements.cc:1039
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_statements.cc:953
table_events_statements_history_long()
Definition: table_events_statements.cc:958
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_statements.cc:997
static PFS_engine_table_share m_share
Table share.
Definition: table_events_statements.h:309
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_statements.h:327
static Plugin_table m_table_def
Table definition.
Definition: table_events_statements.h:329
static ha_rows get_row_count()
Definition: table_events_statements.cc:1044
Table PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY.
Definition: table_events_statements.h:266
static int delete_all_rows()
Definition: table_events_statements.cc:933
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_statements.cc:806
static Plugin_table m_table_def
Table definition.
Definition: table_events_statements.h:292
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_statements.h:290
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_statements.cc:844
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_statements.cc:793
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_statements.cc:808
static PFS_engine_table_share m_share
Table share.
Definition: table_events_statements.h:269
PFS_index_events_statements * m_opened_index
Definition: table_events_statements.h:301
int index_init(uint idx, bool sorted) override
Definition: table_events_statements.cc:943
int index_next() override
Find key in index, read record.
Definition: table_events_statements.cc:869
static ha_rows get_row_count()
Definition: table_events_statements.cc:938
table_events_statements_history()
Definition: table_events_statements.cc:798
void reset_position(void) override
Reset the cursor position to the beginning of the table.
Definition: table_events_statements.cc:801
pos_events_statements_history m_pos
Current position.
Definition: table_events_statements.h:297
int make_row(PFS_thread *pfs_thread, PFS_events_statements *statement)
Definition: table_events_statements.cc:912
pos_events_statements_history m_next_pos
Next position.
Definition: table_events_statements.h:299
~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:269
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:579
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:180
Definition: pfs_name.h:113
Position of a cursor, for simple iterations.
Definition: pfs_engine_table.h:558
Instrumented thread implementation.
Definition: pfs_instr.h:372
Definition: table.h:1394
Definition: thr_lock.h:138
Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_CURRENT.
Definition: table_events_statements.h:169
pos_events_statements_current()
Definition: table_events_statements.h:170
void reset(void)
Definition: table_events_statements.h:172
void next_thread(void)
Definition: table_events_statements.h:177
Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_HISTORY.
Definition: table_events_statements.h:184
pos_events_statements_history()
Definition: table_events_statements.h:185
void next_thread(void)
Definition: table_events_statements.h:192
void reset(void)
Definition: table_events_statements.h:187
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:163
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:165
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_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
Structure to store token count/array for a statement on which digest is to be calculated.
Definition: sql_digest.h:97
Definition: mysqlslap.cc:213
Helpers to implement a performance schema table.
unsigned int uint
Definition: uca-dump.cc:29