MySQL 8.0.37
Source Code Documentation
pfs_events_transactions.h
Go to the documentation of this file.
1/* Copyright (c) 2013, 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 PFS_EVENTS_TRANSACTIONS_H
25#define PFS_EVENTS_TRANSACTIONS_H
26
27/**
28 @file storage/perfschema/pfs_events_transactions.h
29 Events transactions data structures (declarations).
30*/
31
32#include <sys/types.h>
33#include <atomic>
34
35#include "my_inttypes.h"
36#include "sql/rpl_gtid.h"
40
41// Define XIDDATASIZE manually here to avoid pulling in all of mysql/plugin.h
42// (which is big) just for MYSQL_XIDDATASIZE; this file is included from a lot
43// of places. We have a static_assert in the .cc file to check that they are
44// in sync. See sql/xa.h, which does the same thing.
45#define XIDDATASIZE 128
46
47struct PFS_thread;
48struct PFS_account;
49struct PFS_user;
50struct PFS_host;
51
52/**
53 struct PSI_xid is binary compatible with the XID structure as
54 in the X/Open CAE Specification, Distributed Transaction Processing:
55 The XA Specification, X/Open Company Ltd., 1991.
56 http://www.opengroup.org/bookstore/catalog/c193.htm
57
58 A value of -1 in formatID means that the XID is null.
59 Max length for bqual and gtrid is 64 bytes each.
60
61 @see XID in sql/handler.h
62 @see MYSQL_XID in mysql/plugin.h
63*/
64struct PSI_xid {
65 /** Format identifier. */
67 /** GTRID length, value 1-64. */
69 /** BQUAL length, value 1-64. */
71 /** XID raw data, not \0-terminated */
73
74 PSI_xid() { null(); }
75 bool is_null() const { return formatID == -1; }
76 void null() {
77 formatID = -1;
78 gtrid_length = 0;
79 bqual_length = 0;
80 }
81};
82typedef struct PSI_xid PSI_xid;
83
84/** A transaction record. */
86 /** Source identifier, mapped from internal format. */
88 /** InnoDB transaction ID. */
90 /** Status */
92 /** Global Transaction ID specifier. */
94 /** True if XA transaction. */
95 bool m_xa;
96 /** XA transaction ID. */
98 /** XA status */
100 /** Transaction isolation level. */
102 /** True if read-only transaction, otherwise read-write. */
104 /** True if autocommit transaction. */
106 /** Total number of savepoints. */
108 /** Number of rollback_to_savepoint. */
110 /** Number of release_savepoint. */
112};
113
114bool xid_printable(PSI_xid *xid, size_t offset, size_t length);
115
117 PFS_events_transactions *transaction);
119 PFS_events_transactions *transaction);
120
124
129
131 uint events_transactions_history_long_sizing);
133
145
146#endif
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
char * user
Definition: mysqladmin.cc:60
const char * host
Definition: mysqladmin.cc:59
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
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
enum_xa_transaction_state
Enum values for XA transaction state columns.
Definition: pfs_column_types.h:304
Events data structures (declarations).
void aggregate_account_transactions(PFS_account *account)
void aggregate_user_transactions(PFS_user *user)
bool xid_printable(PSI_xid *xid, size_t offset, size_t length)
Check if the XID consists of printable characters, ASCII 32 - 127.
Definition: pfs_events_transactions.cc:251
void reset_events_transactions_history_long()
Reset table EVENTS_TRANSACTIONS_HISTORY_LONG data.
Definition: pfs_events_transactions.cc:188
PFS_events_transactions * events_transactions_history_long_array
EVENTS_TRANSACTIONS_HISTORY_LONG circular buffer.
Definition: pfs_events_transactions.cc:64
ulong events_transactions_history_long_size
Definition: pfs_events_transactions.cc:51
void reset_events_transactions_current()
Reset table EVENTS_TRANSACTIONS_CURRENT data.
Definition: pfs_events_transactions.cc:166
void reset_events_transactions_global()
Reset table EVENTS_TRANSACTIONS_GLOBAL_BY_EVENT_NAME data.
Definition: pfs_events_transactions.cc:242
void reset_events_transactions_by_user()
Reset table EVENTS_TRANSACTIONS_SUMMARY_BY_USER_BY_EVENT_NAME data.
Definition: pfs_events_transactions.cc:228
void cleanup_events_transactions_history_long()
Cleanup table EVENTS_TRANSACTIONS_HISTORY_LONG.
Definition: pfs_events_transactions.cc:91
bool events_transactions_history_long_full
True if EVENTS_TRANSACTIONS_HISTORY_LONG circular buffer is full.
Definition: pfs_events_transactions.cc:60
void reset_events_transactions_by_thread()
Reset table EVENTS_TRANSACTIONS_SUMMARY_BY_THREAD_BY_EVENT_NAME data.
Definition: pfs_events_transactions.cc:208
void reset_events_transactions_by_host()
Reset table EVENTS_TRANSACTIONS_SUMMARY_BY_HOST_BY_EVENT_NAME data.
Definition: pfs_events_transactions.cc:237
void aggregate_host_transactions(PFS_host *host)
int init_events_transactions_history_long(uint events_transactions_history_long_sizing)
Initialize table EVENTS_TRANSACTIONS_HISTORY_LONG.
Definition: pfs_events_transactions.cc:71
bool flag_events_transactions_history_long
Consumer flag for table EVENTS_TRANSACTIONS_HISTORY_LONG.
Definition: pfs_events_transactions.cc:57
bool flag_events_transactions_current
Consumer flag for table EVENTS_TRANSACTIONS_CURRENT.
Definition: pfs_events_transactions.cc:53
void reset_events_transactions_by_account()
Reset table EVENTS_TRANSACTIONS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME data.
Definition: pfs_events_transactions.cc:219
bool flag_events_transactions_history
Consumer flag for table EVENTS_TRANSACTIONS_HISTORY.
Definition: pfs_events_transactions.cc:55
PFS_cacheline_atomic_uint32 events_transactions_history_long_index
Index in EVENTS_TRANSACTIONS_HISTORY_LONG circular buffer.
Definition: pfs_events_transactions.cc:62
void insert_events_transactions_history(PFS_thread *thread, PFS_events_transactions *transaction)
Insert a transaction record in table EVENTS_TRANSACTIONS_HISTORY.
Definition: pfs_events_transactions.cc:109
void reset_events_transactions_history()
Reset table EVENTS_TRANSACTIONS_HISTORY data.
Definition: pfs_events_transactions.cc:183
void insert_events_transactions_history_long(PFS_events_transactions *transaction)
Insert a transaction record in table EVENTS_TRANSACTIONS_HISTORY_LONG.
Definition: pfs_events_transactions.cc:141
#define XIDDATASIZE
Definition: pfs_events_transactions.h:45
Miscellaneous global dependencies (declarations).
This struct represents a specification of a GTID for a statement to be executed: either "AUTOMATIC",...
Definition: rpl_gtid.h:3791
Per account statistics.
Definition: pfs_account.h:67
An atomic uint32 variable, guaranteed to be alone in a CPU cache line.
Definition: pfs_global.h:77
A transaction record.
Definition: pfs_events_transactions.h:85
enum_xa_transaction_state m_xa_state
XA status.
Definition: pfs_events_transactions.h:99
enum_transaction_state m_state
Status.
Definition: pfs_events_transactions.h:91
bool m_autocommit
True if autocommit transaction.
Definition: pfs_events_transactions.h:105
rpl_sid m_sid
Source identifier, mapped from internal format.
Definition: pfs_events_transactions.h:87
bool m_xa
True if XA transaction.
Definition: pfs_events_transactions.h:95
ulonglong m_trxid
InnoDB transaction ID.
Definition: pfs_events_transactions.h:89
ulonglong m_rollback_to_savepoint_count
Number of rollback_to_savepoint.
Definition: pfs_events_transactions.h:109
ulonglong m_release_savepoint_count
Number of release_savepoint.
Definition: pfs_events_transactions.h:111
enum_isolation_level m_isolation_level
Transaction isolation level.
Definition: pfs_events_transactions.h:101
bool m_read_only
True if read-only transaction, otherwise read-write.
Definition: pfs_events_transactions.h:103
PSI_xid m_xid
XA transaction ID.
Definition: pfs_events_transactions.h:97
ulonglong m_savepoint_count
Total number of savepoints.
Definition: pfs_events_transactions.h:107
Gtid_specification m_gtid_spec
Global Transaction ID specifier.
Definition: pfs_events_transactions.h:93
An event record.
Definition: pfs_events.h:38
Per host statistics.
Definition: pfs_host.h:64
Instrumented thread implementation.
Definition: pfs_instr.h:373
Per user statistics.
Definition: pfs_user.h:63
struct PSI_xid is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: pfs_events_transactions.h:64
long bqual_length
BQUAL length, value 1-64.
Definition: pfs_events_transactions.h:70
long formatID
Format identifier.
Definition: pfs_events_transactions.h:66
PSI_xid()
Definition: pfs_events_transactions.h:74
char data[XIDDATASIZE]
XID raw data, not \0-terminated.
Definition: pfs_events_transactions.h:72
bool is_null() const
Definition: pfs_events_transactions.h:75
long gtrid_length
GTRID length, value 1-64.
Definition: pfs_events_transactions.h:68
This is a POD.
Definition: uuid.h:61
unsigned int uint
Definition: uca9-dump.cc:75