MySQL 8.0.39
Source Code Documentation
psi_transaction_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 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 COMPONENTS_SERVICES_BITS_PSI_TRANSACTION_BITS_H
25#define COMPONENTS_SERVICES_BITS_PSI_TRANSACTION_BITS_H
26
27/**
28 @file mysql/components/services/bits/psi_transaction_bits.h
29 Performance schema instrumentation interface.
30
31 @defgroup psi_abi_transaction Transaction Instrumentation (ABI)
32 @ingroup psi_abi
33 @{
34*/
35
36/**
37 Interface for an instrumented transaction.
38 This is an opaque structure.
39*/
42
43/**
44 State data storage for @c get_thread_transaction_locker_v1_t,
45 @c get_thread_transaction_locker_v1_t.
46 This structure provide temporary storage to a transaction locker.
47 The content of this structure is considered opaque,
48 the fields are only hints of what an implementation
49 of the psi interface can use.
50 This memory is provided by the instrumented code for performance reasons.
51 @sa get_thread_transaction_locker_v1_t
52*/
54 /** Internal state. */
55 unsigned int m_flags;
56 /** Instrumentation class. */
57 void *m_class;
58 /** Current thread. */
60 /** Timer start. */
61 unsigned long long m_timer_start;
62 /** Timer function. */
63 unsigned long long (*m_timer)(void);
64 /** Internal data. */
66 /** True if read-only transaction, false if read-write. */
68 /** True if transaction is autocommit. */
70 /** Number of statements. */
71 unsigned long m_statement_count;
72 /** Total number of savepoints. */
73 unsigned long m_savepoint_count;
74 /** Number of rollback_to_savepoint. */
76 /** Number of release_savepoint. */
78};
80
81/**
82 Get a transaction instrumentation locker.
83 @param state data storage for the locker
84 @param xid the xid for this transaction
85 @param trxid the InnoDB transaction id
86 @param isolation_level isolation level for this transaction
87 @param read_only true if transaction access mode is read-only
88 @param autocommit true if transaction is autocommit
89 @return a transaction locker, or NULL
90*/
91typedef struct PSI_transaction_locker *(*get_thread_transaction_locker_v1_t)(
92 struct PSI_transaction_locker_state_v1 *state, const void *xid,
93 const unsigned long long *trxid, int isolation_level, bool read_only,
94 bool autocommit);
95
96/**
97 Start a new transaction event.
98 @param locker the transaction locker for this event
99 @param src_file source file name
100 @param src_line source line number
101*/
102typedef void (*start_transaction_v1_t)(struct PSI_transaction_locker *locker,
103 const char *src_file,
104 unsigned int src_line);
105
106/**
107 Set the transaction xid.
108 @param locker the transaction locker for this event
109 @param xid the id of the XA transaction
110 @param xa_state the state of the XA transaction
111*/
113 const void *xid, int xa_state);
114
115/**
116 Set the state of the XA transaction.
117 @param locker the transaction locker for this event
118 @param xa_state the new state of the xa transaction
119*/
121 struct PSI_transaction_locker *locker, int xa_state);
122
123/**
124 Set the transaction gtid.
125 @param locker the transaction locker for this event
126 @param sid the source id for the transaction, mapped from sidno
127 @param gtid_spec the gtid specifier for the transaction
128*/
130 const void *sid,
131 const void *gtid_spec);
132
133/**
134 Set the transaction trx_id.
135 @param locker the transaction locker for this event
136 @param trxid the storage engine transaction ID
137*/
139 struct PSI_transaction_locker *locker, const unsigned long long *trxid);
140
141/**
142 Increment a transaction event savepoint count.
143 @param locker the transaction locker
144 @param count the increment value
145*/
147 struct PSI_transaction_locker *locker, unsigned long count);
148
149/**
150 Increment a transaction event rollback to savepoint count.
151 @param locker the transaction locker
152 @param count the increment value
153*/
155 struct PSI_transaction_locker *locker, unsigned long count);
156
157/**
158 Increment a transaction event release savepoint count.
159 @param locker the transaction locker
160 @param count the increment value
161*/
163 struct PSI_transaction_locker *locker, unsigned long count);
164
165/**
166 Commit or rollback the transaction.
167 @param locker the transaction locker for this event
168 @param commit true if transaction was committed, false if rolled back
169*/
170typedef void (*end_transaction_v1_t)(struct PSI_transaction_locker *locker,
171 bool commit);
172
174
175/** @} (end of group psi_abi_transaction) */
176
177#endif /* COMPONENTS_SERVICES_BITS_PSI_TRANSACTION_BITS_H */
struct PSI_thread PSI_thread
Definition: psi_thread_bits.h:82
void(* end_transaction_v1_t)(struct PSI_transaction_locker *locker, bool commit)
Commit or rollback the transaction.
Definition: psi_transaction_bits.h:170
void(* set_transaction_trxid_v1_t)(struct PSI_transaction_locker *locker, const unsigned long long *trxid)
Set the transaction trx_id.
Definition: psi_transaction_bits.h:138
void(* set_transaction_gtid_v1_t)(struct PSI_transaction_locker *locker, const void *sid, const void *gtid_spec)
Set the transaction gtid.
Definition: psi_transaction_bits.h:129
void(* inc_transaction_release_savepoint_v1_t)(struct PSI_transaction_locker *locker, unsigned long count)
Increment a transaction event release savepoint count.
Definition: psi_transaction_bits.h:162
void(* inc_transaction_rollback_to_savepoint_v1_t)(struct PSI_transaction_locker *locker, unsigned long count)
Increment a transaction event rollback to savepoint count.
Definition: psi_transaction_bits.h:154
struct PSI_transaction_locker PSI_transaction_locker
Definition: psi_transaction_bits.h:41
void(* set_transaction_xa_state_v1_t)(struct PSI_transaction_locker *locker, int xa_state)
Set the state of the XA transaction.
Definition: psi_transaction_bits.h:120
void(* inc_transaction_savepoints_v1_t)(struct PSI_transaction_locker *locker, unsigned long count)
Increment a transaction event savepoint count.
Definition: psi_transaction_bits.h:146
void(* set_transaction_xid_v1_t)(struct PSI_transaction_locker *locker, const void *xid, int xa_state)
Set the transaction xid.
Definition: psi_transaction_bits.h:112
void(* start_transaction_v1_t)(struct PSI_transaction_locker *locker, const char *src_file, unsigned int src_line)
Start a new transaction event.
Definition: psi_transaction_bits.h:102
static int count
Definition: myisam_ftdump.cc:43
constexpr value_type read_only
Definition: classic_protocol_constants.h:213
constexpr value_type autocommit
Definition: classic_protocol_constants.h:152
static bool commit(THD *thd)
Commit the current statement and transaction.
Definition: sql_cmd_srs.cc:152
State data storage for get_thread_transaction_locker_v1_t, get_thread_transaction_locker_v1_t.
Definition: psi_transaction_bits.h:53
bool m_autocommit
True if transaction is autocommit.
Definition: psi_transaction_bits.h:69
void * m_class
Instrumentation class.
Definition: psi_transaction_bits.h:57
unsigned long m_rollback_to_savepoint_count
Number of rollback_to_savepoint.
Definition: psi_transaction_bits.h:75
unsigned long long m_timer_start
Timer start.
Definition: psi_transaction_bits.h:61
void * m_transaction
Internal data.
Definition: psi_transaction_bits.h:65
bool m_read_only
True if read-only transaction, false if read-write.
Definition: psi_transaction_bits.h:67
unsigned long m_statement_count
Number of statements.
Definition: psi_transaction_bits.h:71
struct PSI_thread * m_thread
Current thread.
Definition: psi_transaction_bits.h:59
unsigned long m_savepoint_count
Total number of savepoints.
Definition: psi_transaction_bits.h:73
unsigned long long(* m_timer)(void)
Timer function.
Definition: psi_transaction_bits.h:63
unsigned long m_release_savepoint_count
Number of release_savepoint.
Definition: psi_transaction_bits.h:77
unsigned int m_flags
Internal state.
Definition: psi_transaction_bits.h:55