Debian Codegraph @

storage/perfschema/pfs_events_transactions.h

raw symbols SCIP
1 /* Copyright (c) 2013, 2026, 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"
37 #include "storage/perfschema/pfs_column_types.h"
38 #include "storage/perfschema/pfs_events.h"
39 #include "storage/perfschema/pfs_global.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
47 struct PFS_thread;
48 struct PFS_account;
49 struct PFS_user;
50 struct 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 */
64 struct PSI_xid {
65 /** Format identifier. */
66 long formatID;
67 /** GTRID length, value 1-64. */
68 long gtrid_length;
69 /** BQUAL length, value 1-64. */
70 long bqual_length;
71 /** XID raw data, not \0-terminated */
72 char data[XIDDATASIZE];
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 };
82 typedef struct PSI_xid PSI_xid;
83
84 /** A transaction record. */
85 struct PFS_events_transactions : public PFS_events {
86 /** Source identifier, mapped from internal format. */
87 rpl_sid m_sid;
88 /** InnoDB transaction ID. */
89 ulonglong m_trxid;
90 /** Status */
91 enum_transaction_state m_state;
92 /** Global Transaction ID specifier. */
93 Gtid_specification m_gtid_spec;
94 /** True if XA transaction. */
95 bool m_xa;
96 /** XA transaction ID. */
97 PSI_xid m_xid;
98 /** XA status */
99 enum_xa_transaction_state m_xa_state;
100 /** Transaction isolation level. */
101 enum_isolation_level m_isolation_level;
102 /** True if read-only transaction, otherwise read-write. */
103 bool m_read_only;
104 /** True if autocommit transaction. */
105 bool m_autocommit;
106 /** Total number of savepoints. */
107 ulonglong m_savepoint_count;
108 /** Number of rollback_to_savepoint. */
109 ulonglong m_rollback_to_savepoint_count;
110 /** Number of release_savepoint. */
111 ulonglong m_release_savepoint_count;
112 };
113
114 bool xid_printable(PSI_xid *xid, size_t offset, size_t length);
115
116 void insert_events_transactions_history(PFS_thread *thread,
117 PFS_events_transactions *transaction);
118 void insert_events_transactions_history_long(
119 PFS_events_transactions *transaction);
120
121 extern bool flag_events_transactions_current;
122 extern bool flag_events_transactions_history;
123 extern bool flag_events_transactions_history_long;
124
125 extern bool events_transactions_history_long_full;
126 extern PFS_cacheline_atomic_uint32 events_transactions_history_long_index;
127 extern PFS_events_transactions *events_transactions_history_long_array;
128 extern ulong events_transactions_history_long_size;
129
130 int init_events_transactions_history_long(
131 uint events_transactions_history_long_sizing);
132 void cleanup_events_transactions_history_long();
133
134 void reset_events_transactions_current();
135 void reset_events_transactions_history();
136 void reset_events_transactions_history_long();
137 void reset_events_transactions_by_thread();
138 void reset_events_transactions_by_account();
139 void reset_events_transactions_by_user();
140 void reset_events_transactions_by_host();
141 void reset_events_transactions_global();
142 void aggregate_account_transactions(PFS_account *account);
143 void aggregate_user_transactions(PFS_user *user);
144 void aggregate_host_transactions(PFS_host *host);
145
146 #endif