MySQL 9.3.0
Source Code Documentation
transaction_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2025, 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 DD__TRANSACTION_IMPL_INCLUDED
25#define DD__TRANSACTION_IMPL_INCLUDED
26
27#include <sys/types.h>
28#include <map>
29
30#include "my_inttypes.h"
32#include "sql/dd/dd_kill_immunizer.h" // dd::DD_kill_immunizer
58#include "sql/dd/string_type.h" // dd::String_type
60#include "sql/field.h"
61#include "sql/handler.h"
62#include "sql/set_var.h"
63#include "sql/sql_class.h" // THD::killed_state
64#include "thr_lock.h"
65
67
68namespace dd {
69
70class Raw_table;
71
72///////////////////////////////////////////////////////////////////////////
73
74/**
75 Auxiliary class for opening dictionary tables.
76*/
78 public:
80 : m_thd(thd), m_lock_type(lock_type), m_ignore_global_read_lock(false) {}
81
83
84 Raw_table *get_table(const String_type &name) const;
85
86 template <typename T>
88 return get_table(T::DD_table::instance().name());
89 }
90
91 template <typename X>
93 X::Impl::register_tables(this);
94 }
95
96 template <typename X>
97 void add_table() {
98 this->add_table(X::instance().name());
99 }
100
101 /**
102 Open all the DD tables in list Open_dictionary_tables_ctx::m_tables.
103
104 @return true - On failure and error is reported.
105 @return false - On success.
106 */
107 bool open_tables();
108
109 void add_table(const String_type &name);
110
111 THD *get_thd() const { return m_thd; }
112
113 /**
114 Ignore global read lock when opening the tables.
115 */
118 }
119
120 private:
124 typedef std::map<String_type, Raw_table *> Object_table_map;
126};
127
128/**
129 Implementation of read-only data-dictionary transaction.
130 Relies on attachable transactions infrastructure.
131*/
133 public:
135 : otx(thd, TL_READ), m_thd(thd), m_kill_immunizer(thd) {
137 thd->tx_isolation = isolation;
138 }
139
141
143
144 private:
146
148};
149
150///////////////////////////////////////////////////////////////////////////
151
152/**
153 Class for storing/restoring state during dictionary update operations.
154*/
156 public:
158
160
162
163 private:
165
167
169
170 // Stores state before DD operations
179
180 /*
181 Save auto_increment_increment state.
182
183 Value of the auto_increment_increment is set to 1 in the constructor.
184 auto_increment_offset is used only when auto_increment_increment is greater
185 than 1. So saving only auto_increment_increment value.
186 */
188
189 // Save auto_inc_intervals_in_cur_stmt_for_binlog
191
193};
194
195///////////////////////////////////////////////////////////////////////////
196
197} // namespace dd
198
199#endif // DD__TRANSACTION_IMPL_INCLUDED
List of Discrete_interval objects.
Definition: discrete_interval.h:87
Storage for backup of Open_tables_state.
Definition: sql_class.h:693
Definition: sql_lex.h:2753
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
enum_tx_isolation tx_isolation
Definition: sql_class.h:2643
void end_attachable_transaction()
End an active attachable transaction.
Definition: sql_class.cc:2309
void begin_attachable_ro_transaction()
Start a read-only attachable transaction.
Definition: sql_class.cc:2305
RAII class for immunizing the THD from kill operations.
Definition: dd_kill_immunizer.h:46
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:77
void mark_ignore_global_read_lock()
Ignore global read lock when opening the tables.
Definition: transaction_impl.h:116
std::map< String_type, Raw_table * > Object_table_map
Definition: transaction_impl.h:124
Raw_table * get_table() const
Definition: transaction_impl.h:87
THD * m_thd
Definition: transaction_impl.h:121
bool m_ignore_global_read_lock
Definition: transaction_impl.h:123
bool open_tables()
Open all the DD tables in list Open_dictionary_tables_ctx::m_tables.
Definition: transaction_impl.cc:56
~Open_dictionary_tables_ctx()
Definition: transaction_impl.cc:43
Open_dictionary_tables_ctx(THD *thd, thr_lock_type lock_type)
Definition: transaction_impl.h:79
THD * get_thd() const
Definition: transaction_impl.h:111
thr_lock_type m_lock_type
Definition: transaction_impl.h:122
void register_tables()
Definition: transaction_impl.h:92
void add_table()
Definition: transaction_impl.h:97
Object_table_map m_tables
Definition: transaction_impl.h:125
Definition: raw_table.h:44
Implementation of read-only data-dictionary transaction.
Definition: transaction_impl.h:132
Transaction_ro(THD *thd, enum_tx_isolation isolation)
Definition: transaction_impl.h:134
~Transaction_ro()
Definition: transaction_impl.h:140
DD_kill_immunizer m_kill_immunizer
Definition: transaction_impl.h:147
Open_dictionary_tables_ctx otx
Definition: transaction_impl.h:142
THD * m_thd
Definition: transaction_impl.h:145
Class for storing/restoring state during dictionary update operations.
Definition: transaction_impl.h:155
enum_check_fields m_saved_check_for_truncated_fields
Definition: transaction_impl.h:176
~Update_dictionary_tables_ctx()
Definition: transaction_impl.cc:199
THD * m_thd
Definition: transaction_impl.h:164
DD_kill_immunizer m_kill_immunizer
Definition: transaction_impl.h:166
sql_mode_t m_saved_mode
Definition: transaction_impl.h:174
Query_tables_list * m_query_tables_list_backup
Definition: transaction_impl.h:168
long long m_latest_auto_incr_id
Definition: transaction_impl.h:175
ulong m_saved_auto_increment_increment
Definition: transaction_impl.h:187
uint m_saved_in_sub_stmt
Definition: transaction_impl.h:177
Open_dictionary_tables_ctx otx
Definition: transaction_impl.h:161
Open_tables_backup m_open_tables_state_backup
Definition: transaction_impl.h:171
ulonglong m_saved_options
Definition: transaction_impl.h:173
Update_dictionary_tables_ctx(THD *thd)
Definition: transaction_impl.cc:138
bool m_saved_binlog_row_based
Definition: transaction_impl.h:172
Discrete_intervals_list m_auto_inc_intervals_forced_saved
Definition: transaction_impl.h:192
Discrete_intervals_list m_auto_inc_intervals_in_cur_stmt_for_binlog_saved
Definition: transaction_impl.h:190
bool m_saved_time_zone_used
Definition: transaction_impl.h:178
uint64_t sql_mode_t
Definition: dd_event.h:39
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:51
"public" interface to sys_var - server configuration variables.
enum_check_fields
Definition: field.h:170
enum_tx_isolation
Definition: handler.h:3222
case opt name
Definition: sslopt-case.h:29
thr_lock_type
Definition: thr_lock.h:51
@ TL_WRITE
Definition: thr_lock.h:92
@ TL_READ
Definition: thr_lock.h:62