MySQL 8.0.40
Source Code Documentation
table_events_transactions.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_TRANSACTIONS_H
25#define TABLE_EVENTS_TRANSACTIONS_H
26
27/**
28 @file storage/perfschema/table_events_transactions.h
29 Table EVENTS_TRANSACTIONS_xxx (declarations).
30*/
31
32#include <sys/types.h>
33
34#include "my_base.h"
35#include "my_inttypes.h"
36#include "sql/rpl_gtid.h"
41
42class Field;
43class Plugin_table;
44struct PFS_events;
45struct PFS_thread;
46struct TABLE;
47struct THR_LOCK;
48
49/**
50 @addtogroup performance_schema_tables
51 @{
52*/
53
55 public:
58 m_key_1("THREAD_ID"),
59 m_key_2("EVENT_ID") {}
60
61 ~PFS_index_events_transactions() override = default;
62
63 bool match(PFS_thread *pfs);
64 bool match(PFS_events *pfs);
65
66 private:
69};
70
71/** A row of table_events_transactions_common. */
73 /** Column THREAD_ID. */
75 /** Column EVENT_ID. */
77 /** Column END_EVENT_ID. */
79 /** Column NESTING_EVENT_ID. */
81 /** Column NESTING_EVENT_TYPE. */
83 /** Column EVENT_NAME. */
84 const char *m_name;
85 /** Length in bytes of @c m_name. */
87 /** Column TIMER_START. */
89 /** Column TIMER_END. */
91 /** Column TIMER_WAIT. */
93 /** Column SOURCE. */
95 /** Length in bytes of @c m_source. */
97 /** InnoDB transaction id. */
99 /** Transaction state. */
101 /** Global Transaction ID. */
103 /** GTID length in bytes*/
105 /** XA transaction ID. */
107 /** XA transaction state. */
109 /** True if XA transaction. */
110 bool m_xa;
111 /** True if autocommit transaction. */
113 /** Isolation level. */
115 /** True if read-only, read-write otherwise. */
117 /** Column NUMBER_OF_SAVEPOINTS. */
119 /** Column NUMBER_OF_ROLLBACK_TO_SAVEPOINT. */
121 /** Column NUMBER_OF_RELEASE_SAVEPOINT. */
123};
124
125/**
126 Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY.
127 Index 1 on thread (0 based)
128 Index 2 on transaction event record in thread history (0 based)
129*/
132
133 inline void reset() {
134 m_index_1 = 0;
135 m_index_2 = 0;
136 }
137
138 inline void next_thread() {
139 m_index_1++;
140 m_index_2 = 0;
141 }
142};
143
144/**
145 Adapter, for table sharing the structure of
146 PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_CURRENT.
147*/
149 protected:
150 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
151 bool read_all) override;
152
154 void *pos);
155
157
158 int make_row(PFS_events_transactions *transaction);
159
160 /** Current row. */
162};
163
164/** Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_CURRENT. */
167 public:
168 /** Table share */
171 static int delete_all_rows();
172 static ha_rows get_row_count();
173
174 void reset_position() override;
175
176 int rnd_init(bool scan) override;
177 int rnd_next() override;
178 int rnd_pos(const void *pos) override;
179
180 int index_init(uint idx, bool sorted) override;
181 int index_next() override;
182
183 protected:
185
186 public:
188
189 private:
192
193 /** Table share lock. */
195 /** Table definition. */
197
198 /** Current position. */
200 /** Next position. */
202
204};
205
206/** Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY. */
209 public:
210 /** Table share */
213 static int delete_all_rows();
214 static ha_rows get_row_count();
215
216 void reset_position() override;
217
218 int rnd_init(bool scan) override;
219 int rnd_next() override;
220 int rnd_pos(const void *pos) override;
221
222 int index_init(uint idx, bool sorted) override;
223 int index_next() override;
224
225 protected:
227
228 public:
230
231 private:
232 /** Table share lock. */
234 /** Table definition. */
236
237 /** Current position. */
239 /** Next position. */
241
243};
244
245/** Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY_LONG. */
248 public:
249 /** Table share */
252 static int delete_all_rows();
253 static ha_rows get_row_count();
254
255 int rnd_init(bool scan) override;
256 int rnd_next() override;
257 int rnd_pos(const void *pos) override;
258 void reset_position() override;
259
260 protected:
262
263 public:
265
266 private:
267 /** Table share lock. */
269 /** Table definition. */
271
272 /** Current position. */
274 /** Next position. */
276};
277
278/** @} */
279#endif
Definition: field.h:575
Definition: pfs_engine_table.h:301
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:70
Definition: table_events_transactions.h:54
PFS_key_thread_id m_key_1
Definition: table_events_transactions.h:67
PFS_key_event_id m_key_2
Definition: table_events_transactions.h:68
PFS_index_events_transactions()
Definition: table_events_transactions.h:56
bool match(PFS_thread *pfs)
Definition: table_events_transactions.cc:206
~PFS_index_events_transactions() override=default
Definition: table_helper.h:1294
Definition: table_helper.h:1278
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
Adapter, for table sharing the structure of PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_CURRENT.
Definition: table_events_transactions.h:148
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:368
int make_row(PFS_events_transactions *transaction)
Build a row.
Definition: table_events_transactions.cc:234
row_events_transactions m_row
Current row.
Definition: table_events_transactions.h:161
~table_events_transactions_common() override=default
table_events_transactions_common(const PFS_engine_table_share *share, void *pos)
Definition: table_events_transactions.cc:224
Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_CURRENT.
Definition: table_events_transactions.h:166
table_events_transactions_current()
Definition: table_events_transactions.cc:516
PFS_simple_index m_pos
Current position.
Definition: table_events_transactions.h:199
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_transactions.h:194
static ha_rows get_row_count()
Definition: table_events_transactions.cc:600
int index_init(uint idx, bool sorted) override
Definition: table_events_transactions.cc:562
int index_next() override
Find key in index, read record.
Definition: table_events_transactions.cc:572
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_transactions.cc:511
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_transactions.cc:528
static int delete_all_rows()
Definition: table_events_transactions.cc:595
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_transactions.cc:526
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_transactions.cc:545
PFS_simple_index m_next_pos
Next position.
Definition: table_events_transactions.h:201
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_events_transactions.cc:521
static Plugin_table m_table_def
Table definition.
Definition: table_events_transactions.h:196
PFS_index_events_transactions * m_opened_index
Definition: table_events_transactions.h:203
static PFS_engine_table_share m_share
Table share.
Definition: table_events_transactions.h:169
~table_events_transactions_current() override=default
Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY_LONG.
Definition: table_events_transactions.h:247
static PFS_engine_table_share m_share
Table share.
Definition: table_events_transactions.h:250
PFS_simple_index m_pos
Current position.
Definition: table_events_transactions.h:273
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_events_transactions.cc:754
static ha_rows get_row_count()
Definition: table_events_transactions.cc:822
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_transactions.cc:744
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_transactions.cc:788
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_transactions.cc:759
static int delete_all_rows()
Definition: table_events_transactions.cc:817
~table_events_transactions_history_long() override=default
static Plugin_table m_table_def
Table definition.
Definition: table_events_transactions.h:270
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_transactions.cc:761
table_events_transactions_history_long()
Definition: table_events_transactions.cc:749
PFS_simple_index m_next_pos
Next position.
Definition: table_events_transactions.h:275
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_transactions.h:268
Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY.
Definition: table_events_transactions.h:208
int index_init(uint idx, bool sorted) override
Definition: table_events_transactions.cc:681
pos_events_transactions_history m_pos
Current position.
Definition: table_events_transactions.h:238
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_events_transactions.cc:604
~table_events_transactions_history() override=default
static int delete_all_rows()
Definition: table_events_transactions.cc:734
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_events_transactions.cc:621
static PFS_engine_table_share m_share
Table share.
Definition: table_events_transactions.h:211
static Plugin_table m_table_def
Table definition.
Definition: table_events_transactions.h:235
static ha_rows get_row_count()
Definition: table_events_transactions.cc:739
pos_events_transactions_history m_next_pos
Next position.
Definition: table_events_transactions.h:240
table_events_transactions_history()
Definition: table_events_transactions.cc:609
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_events_transactions.cc:656
PFS_index_events_transactions * m_opened_index
Definition: table_events_transactions.h:242
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_events_transactions.cc:614
static THR_LOCK m_table_lock
Table share lock.
Definition: table_events_transactions.h:233
int rnd_init(bool scan) override
Initialize table scan.
Definition: table_events_transactions.cc:619
int index_next() override
Find key in index, read record.
Definition: table_events_transactions.cc:691
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1140
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Definition: buf0block_hint.cc:30
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:324
enum_transaction_state
Enum values for transaction state columns.
Definition: pfs_column_types.h:287
#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:270
enum_xa_transaction_state
Enum values for XA transaction state columns.
Definition: pfs_column_types.h:304
Performance schema tables (declarations).
Events transactions data structures (declarations).
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:66
static const int MAX_TEXT_LENGTH
Definition: rpl_gtid.h:3850
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 transaction record.
Definition: pfs_events_transactions.h:85
An event record.
Definition: pfs_events.h:38
Position of a cursor, for simple iterations.
Definition: pfs_engine_table.h:567
Instrumented thread implementation.
Definition: pfs_instr.h:373
struct PSI_xid is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: pfs_events_transactions.h:64
Definition: table.h:1399
Definition: thr_lock.h:139
Position of a cursor on PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_HISTORY.
Definition: table_events_transactions.h:130
void next_thread()
Definition: table_events_transactions.h:138
void reset()
Definition: table_events_transactions.h:133
pos_events_transactions_history()
Definition: table_events_transactions.h:131
A row of table_events_transactions_common.
Definition: table_events_transactions.h:72
char m_gtid[Gtid_specification::MAX_TEXT_LENGTH+1]
Global Transaction ID.
Definition: table_events_transactions.h:102
ulonglong m_rollback_to_savepoint_count
Column NUMBER_OF_ROLLBACK_TO_SAVEPOINT.
Definition: table_events_transactions.h:120
bool m_read_only
True if read-only, read-write otherwise.
Definition: table_events_transactions.h:116
enum_event_type m_nesting_event_type
Column NESTING_EVENT_TYPE.
Definition: table_events_transactions.h:82
int m_gtid_length
GTID length in bytes.
Definition: table_events_transactions.h:104
PSI_xid m_xid
XA transaction ID.
Definition: table_events_transactions.h:106
ulonglong m_nesting_event_id
Column NESTING_EVENT_ID.
Definition: table_events_transactions.h:80
ulonglong m_timer_wait
Column TIMER_WAIT.
Definition: table_events_transactions.h:92
ulonglong m_event_id
Column EVENT_ID.
Definition: table_events_transactions.h:76
enum_isolation_level m_isolation_level
Isolation level.
Definition: table_events_transactions.h:114
const char * m_name
Column EVENT_NAME.
Definition: table_events_transactions.h:84
bool m_autocommit
True if autocommit transaction.
Definition: table_events_transactions.h:112
enum_transaction_state m_state
Transaction state.
Definition: table_events_transactions.h:100
uint m_source_length
Length in bytes of m_source.
Definition: table_events_transactions.h:96
ulonglong m_timer_start
Column TIMER_START.
Definition: table_events_transactions.h:88
char m_source[COL_SOURCE_SIZE]
Column SOURCE.
Definition: table_events_transactions.h:94
ulonglong m_thread_internal_id
Column THREAD_ID.
Definition: table_events_transactions.h:74
ulonglong m_end_event_id
Column END_EVENT_ID.
Definition: table_events_transactions.h:78
uint m_name_length
Length in bytes of m_name.
Definition: table_events_transactions.h:86
enum_xa_transaction_state m_xa_state
XA transaction state.
Definition: table_events_transactions.h:108
bool m_xa
True if XA transaction.
Definition: table_events_transactions.h:110
ulonglong m_timer_end
Column TIMER_END.
Definition: table_events_transactions.h:90
ulonglong m_savepoint_count
Column NUMBER_OF_SAVEPOINTS.
Definition: table_events_transactions.h:118
ulonglong m_trxid
InnoDB transaction id.
Definition: table_events_transactions.h:98
ulonglong m_release_savepoint_count
Column NUMBER_OF_RELEASE_SAVEPOINT.
Definition: table_events_transactions.h:122
Helpers to implement a performance schema table.
unsigned int uint
Definition: uca9-dump.cc:75