MySQL 8.0.29
Source Code Documentation
table_events_transactions.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_TRANSACTIONS_H
24#define TABLE_EVENTS_TRANSACTIONS_H
25
26/**
27 @file storage/perfschema/table_events_transactions.h
28 Table EVENTS_TRANSACTIONS_xxx (declarations).
29*/
30
31#include <sys/types.h>
32
33#include "my_base.h"
34#include "my_inttypes.h"
35#include "sql/rpl_gtid.h"
40
41class Field;
42class Plugin_table;
43struct PFS_events;
44struct PFS_thread;
45struct TABLE;
46struct THR_LOCK;
47
48/**
49 @addtogroup performance_schema_tables
50 @{
51*/
52
54 public:
57 m_key_1("THREAD_ID"),
58 m_key_2("EVENT_ID") {}
59
60 ~PFS_index_events_transactions() override = default;
61
62 bool match(PFS_thread *pfs);
63 bool match(PFS_events *pfs);
64
65 private:
68};
69
70/** A row of table_events_transactions_common. */
72 /** Column THREAD_ID. */
74 /** Column EVENT_ID. */
76 /** Column END_EVENT_ID. */
78 /** Column NESTING_EVENT_ID. */
80 /** Column NESTING_EVENT_TYPE. */
82 /** Column EVENT_NAME. */
83 const char *m_name;
84 /** Length in bytes of @c m_name. */
86 /** Column TIMER_START. */
88 /** Column TIMER_END. */
90 /** Column TIMER_WAIT. */
92 /** Column SOURCE. */
94 /** Length in bytes of @c m_source. */
96 /** InnoDB transaction id. */
98 /** Transaction state. */
100 /** Global Transaction ID. */
102 /** GTID length in bytes*/
104 /** XA transaction ID. */
106 /** XA transaction state. */
108 /** True if XA transaction. */
109 bool m_xa;
110 /** True if autocommit transaction. */
112 /** Isolation level. */
114 /** True if read-only, read-write otherwise. */
116 /** Column NUMBER_OF_SAVEPOINTS. */
118 /** Column NUMBER_OF_ROLLBACK_TO_SAVEPOINT. */
120 /** Column NUMBER_OF_RELEASE_SAVEPOINT. */
122};
123
124/**
125 Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY.
126 Index 1 on thread (0 based)
127 Index 2 on transaction event record in thread history (0 based)
128*/
131
132 inline void reset(void) {
133 m_index_1 = 0;
134 m_index_2 = 0;
135 }
136
137 inline void next_thread(void) {
138 m_index_1++;
139 m_index_2 = 0;
140 }
141};
142
143/**
144 Adapter, for table sharing the structure of
145 PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_CURRENT.
146*/
148 protected:
149 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
150 bool read_all) override;
151
153 void *pos);
154
156
158
159 /** Current row. */
161};
162
163/** Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_CURRENT. */
166 public:
167 /** Table share */
170 static int delete_all_rows();
171 static ha_rows get_row_count();
172
173 void reset_position(void) override;
174
175 int rnd_init(bool scan) override;
176 int rnd_next() override;
177 int rnd_pos(const void *pos) override;
178
179 int index_init(uint idx, bool sorted) override;
180 int index_next() override;
181
182 protected:
184
185 public:
187
188 private:
191
192 /** Table share lock. */
194 /** Table definition. */
196
197 /** Current position. */
199 /** Next position. */
201
203};
204
205/** Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY. */
208 public:
209 /** Table share */
212 static int delete_all_rows();
213 static ha_rows get_row_count();
214
215 void reset_position(void) override;
216
217 int rnd_init(bool scan) override;
218 int rnd_next() override;
219 int rnd_pos(const void *pos) override;
220
221 int index_init(uint idx, bool sorted) override;
222 int index_next() override;
223
224 protected:
226
227 public:
229
230 private:
231 /** Table share lock. */
233 /** Table definition. */
235
236 /** Current position. */
238 /** Next position. */
240
242};
243
244/** Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY_LONG. */
247 public:
248 /** Table share */
251 static int delete_all_rows();
252 static ha_rows get_row_count();
253
254 int rnd_init(bool scan) override;
255 int rnd_next() override;
256 int rnd_pos(const void *pos) override;
257 void reset_position(void) override;
258
259 protected:
261
262 public:
264
265 private:
266 /** Table share lock. */
268 /** Table definition. */
270
271 /** Current position. */
273 /** Next position. */
275};
276
277/** @} */
278#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_transactions.h:53
PFS_key_thread_id m_key_1
Definition: table_events_transactions.h:66
PFS_key_event_id m_key_2
Definition: table_events_transactions.h:67
PFS_index_events_transactions()
Definition: table_events_transactions.h:55
bool match(PFS_thread *pfs)
Definition: table_events_transactions.cc:205
~PFS_index_events_transactions() override=default
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
Adapter, for table sharing the structure of PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_CURRENT.
Definition: table_events_transactions.h:147
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_events_transactions.cc:367
row_events_transactions m_row
Current row.
Definition: table_events_transactions.h:160
~table_events_transactions_common() override=default
int make_row(PFS_events_transactions *statement)
Build a row.
Definition: table_events_transactions.cc:233
table_events_transactions_common(const PFS_engine_table_share *share, void *pos)
Definition: table_events_transactions.cc:223
Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_CURRENT.
Definition: table_events_transactions.h:165
table_events_transactions_current()
Definition: table_events_transactions.cc:515
PFS_simple_index m_pos
Current position.
Definition: table_events_transactions.h:198
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_transactions.h:193
static ha_rows get_row_count()
Definition: table_events_transactions.cc:599
int index_init(uint idx, bool sorted) override
Definition: table_events_transactions.cc:561
int index_next() override
Find key in index, read record.
Definition: table_events_transactions.cc:571
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_transactions.cc:510
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_transactions.cc:527
static int delete_all_rows()
Definition: table_events_transactions.cc:594
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_transactions.cc:525
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_transactions.cc:544
PFS_simple_index m_next_pos
Next position.
Definition: table_events_transactions.h:200
void reset_position(void) override
Reset the cursor position to the beginning of the table.
Definition: table_events_transactions.cc:520
static Plugin_table m_table_def
Table definition.
Definition: table_events_transactions.h:195
PFS_index_events_transactions * m_opened_index
Definition: table_events_transactions.h:202
static PFS_engine_table_share m_share
Table share.
Definition: table_events_transactions.h:168
~table_events_transactions_current() override=default
Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY_LONG.
Definition: table_events_transactions.h:246
void reset_position(void) override
Reset the cursor position to the beginning of the table.
Definition: table_events_transactions.cc:753
static PFS_engine_table_share m_share
Table share.
Definition: table_events_transactions.h:249
PFS_simple_index m_pos
Current position.
Definition: table_events_transactions.h:272
static ha_rows get_row_count()
Definition: table_events_transactions.cc:821
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_transactions.cc:743
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_transactions.cc:787
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_transactions.cc:758
static int delete_all_rows()
Definition: table_events_transactions.cc:816
~table_events_transactions_history_long() override=default
static Plugin_table m_table_def
Table definition.
Definition: table_events_transactions.h:269
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_transactions.cc:760
table_events_transactions_history_long()
Definition: table_events_transactions.cc:748
PFS_simple_index m_next_pos
Next position.
Definition: table_events_transactions.h:274
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_transactions.h:267
Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY.
Definition: table_events_transactions.h:207
int index_init(uint idx, bool sorted) override
Definition: table_events_transactions.cc:680
pos_events_transactions_history m_pos
Current position.
Definition: table_events_transactions.h:237
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_transactions.cc:603
void reset_position(void) override
Reset the cursor position to the beginning of the table.
Definition: table_events_transactions.cc:613
~table_events_transactions_history() override=default
static int delete_all_rows()
Definition: table_events_transactions.cc:733
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_transactions.cc:620
static PFS_engine_table_share m_share
Table share.
Definition: table_events_transactions.h:210
static Plugin_table m_table_def
Table definition.
Definition: table_events_transactions.h:234
static ha_rows get_row_count()
Definition: table_events_transactions.cc:738
pos_events_transactions_history m_next_pos
Next position.
Definition: table_events_transactions.h:239
table_events_transactions_history()
Definition: table_events_transactions.cc:608
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_transactions.cc:655
PFS_index_events_transactions * m_opened_index
Definition: table_events_transactions.h:241
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_transactions.h:232
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_transactions.cc:618
int index_next() override
Find key in index, read record.
Definition: table_events_transactions.cc:690
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
Definition: buf0block_hint.cc:29
Data types for columns used in the performance schema tables (declarations)
enum_isolation_level
Enum values for transaction isolation level columns.
Definition: pfs_column_types.h:323
enum_transaction_state
Enum values for transaction state columns.
Definition: pfs_column_types.h:286
#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_xa_transaction_state
Enum values for XA transaction state columns.
Definition: pfs_column_types.h:303
Performance schema tables (declarations).
Events transactions data structures (declarations).
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:65
static const int MAX_TEXT_LENGTH
Definition: rpl_gtid.h:3841
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 transaction record.
Definition: pfs_events_transactions.h:84
An event record.
Definition: pfs_events.h:37
Position of a cursor, for simple iterations.
Definition: pfs_engine_table.h:558
Instrumented thread implementation.
Definition: pfs_instr.h:372
struct PSI_xid is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: pfs_events_transactions.h:63
Definition: table.h:1394
Definition: thr_lock.h:138
Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY.
Definition: table_events_transactions.h:129
void reset(void)
Definition: table_events_transactions.h:132
void next_thread(void)
Definition: table_events_transactions.h:137
pos_events_transactions_history()
Definition: table_events_transactions.h:130
A row of table_events_transactions_common.
Definition: table_events_transactions.h:71
char m_gtid[Gtid_specification::MAX_TEXT_LENGTH+1]
Global Transaction ID.
Definition: table_events_transactions.h:101
ulonglong m_rollback_to_savepoint_count
Column NUMBER_OF_ROLLBACK_TO_SAVEPOINT.
Definition: table_events_transactions.h:119
bool m_read_only
True if read-only, read-write otherwise.
Definition: table_events_transactions.h:115
enum_event_type m_nesting_event_type
Column NESTING_EVENT_TYPE.
Definition: table_events_transactions.h:81
int m_gtid_length
GTID length in bytes.
Definition: table_events_transactions.h:103
PSI_xid m_xid
XA transaction ID.
Definition: table_events_transactions.h:105
ulonglong m_nesting_event_id
Column NESTING_EVENT_ID.
Definition: table_events_transactions.h:79
ulonglong m_timer_wait
Column TIMER_WAIT.
Definition: table_events_transactions.h:91
ulonglong m_event_id
Column EVENT_ID.
Definition: table_events_transactions.h:75
enum_isolation_level m_isolation_level
Isolation level.
Definition: table_events_transactions.h:113
const char * m_name
Column EVENT_NAME.
Definition: table_events_transactions.h:83
bool m_autocommit
True if autocommit transaction.
Definition: table_events_transactions.h:111
enum_transaction_state m_state
Transaction state.
Definition: table_events_transactions.h:99
uint m_source_length
Length in bytes of m_source.
Definition: table_events_transactions.h:95
ulonglong m_timer_start
Column TIMER_START.
Definition: table_events_transactions.h:87
char m_source[COL_SOURCE_SIZE]
Column SOURCE.
Definition: table_events_transactions.h:93
ulonglong m_thread_internal_id
Column THREAD_ID.
Definition: table_events_transactions.h:73
ulonglong m_end_event_id
Column END_EVENT_ID.
Definition: table_events_transactions.h:77
uint m_name_length
Length in bytes of m_name.
Definition: table_events_transactions.h:85
enum_xa_transaction_state m_xa_state
XA transaction state.
Definition: table_events_transactions.h:107
bool m_xa
True if XA transaction.
Definition: table_events_transactions.h:109
ulonglong m_timer_end
Column TIMER_END.
Definition: table_events_transactions.h:89
ulonglong m_savepoint_count
Column NUMBER_OF_SAVEPOINTS.
Definition: table_events_transactions.h:117
ulonglong m_trxid
InnoDB transaction id.
Definition: table_events_transactions.h:97
ulonglong m_release_savepoint_count
Column NUMBER_OF_RELEASE_SAVEPOINT.
Definition: table_events_transactions.h:121
Definition: mysqlslap.cc:213
Helpers to implement a performance schema table.
unsigned int uint
Definition: uca-dump.cc:29