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