MySQL 9.0.0
Source Code Documentation
transaction_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 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 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
57#include "sql/dd/string_type.h" // dd::String_type
59#include "sql/field.h"
60#include "sql/handler.h"
61#include "sql/set_var.h"
62#include "sql/sql_class.h" // THD::killed_state
63#include "thr_lock.h"
64
66
67namespace dd {
68
69class Raw_table;
70
71///////////////////////////////////////////////////////////////////////////
72
73/**
74 Auxiliary class for opening dictionary tables.
75*/
77 public:
79 : m_thd(thd), m_lock_type(lock_type), m_ignore_global_read_lock(false) {}
80
82
83 Raw_table *get_table(const String_type &name) const;
84
85 template <typename T>
87 return get_table(T::DD_table::instance().name());
88 }
89
90 template <typename X>
92 X::Impl::register_tables(this);
93 }
94
95 template <typename X>
96 void add_table() {
97 this->add_table(X::instance().name());
98 }
99
100 /**
101 Open all the DD tables in list Open_dictionary_tables_ctx::m_tables.
102
103 @return true - On failure and error is reported.
104 @return false - On success.
105 */
106 bool open_tables();
107
108 void add_table(const String_type &name);
109
110 THD *get_thd() const { return m_thd; }
111
112 /**
113 Ignore global read lock when opening the tables.
114 */
117 }
118
119 private:
123 typedef std::map<String_type, Raw_table *> Object_table_map;
125};
126
127/**
128 Implementation of read-only data-dictionary transaction.
129 Relies on attachable transactions infrastructure.
130*/
132 public:
134 : otx(thd, TL_READ), m_thd(thd), m_kill_immunizer(thd) {
136 thd->tx_isolation = isolation;
137 }
138
140
142
143 private:
145
147};
148
149///////////////////////////////////////////////////////////////////////////
150
151/**
152 Class for storing/restoring state during dictionary update operations.
153*/
155 public:
157
159
161
162 private:
164
166
168
169 // Stores state before DD operations
178
179 /*
180 Save auto_increment_increment state.
181
182 Value of the auto_increment_increment is set to 1 in the constructor.
183 auto_increment_offset is used only when auto_increment_increment is greater
184 than 1. So saving only auto_increment_increment value.
185 */
187
188 // Save auto_inc_intervals_in_cur_stmt_for_binlog
190
192};
193
194///////////////////////////////////////////////////////////////////////////
195
196} // namespace dd
197
198#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:2613
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:2602
void end_attachable_transaction()
End an active attachable transaction.
Definition: sql_class.cc:2234
void begin_attachable_ro_transaction()
Start a read-only attachable transaction.
Definition: sql_class.cc:2230
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:76
void mark_ignore_global_read_lock()
Ignore global read lock when opening the tables.
Definition: transaction_impl.h:115
std::map< String_type, Raw_table * > Object_table_map
Definition: transaction_impl.h:123
Raw_table * get_table() const
Definition: transaction_impl.h:86
THD * m_thd
Definition: transaction_impl.h:120
bool m_ignore_global_read_lock
Definition: transaction_impl.h:122
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:78
THD * get_thd() const
Definition: transaction_impl.h:110
thr_lock_type m_lock_type
Definition: transaction_impl.h:121
void register_tables()
Definition: transaction_impl.h:91
void add_table()
Definition: transaction_impl.h:96
Object_table_map m_tables
Definition: transaction_impl.h:124
Definition: raw_table.h:44
Implementation of read-only data-dictionary transaction.
Definition: transaction_impl.h:131
Transaction_ro(THD *thd, enum_tx_isolation isolation)
Definition: transaction_impl.h:133
~Transaction_ro()
Definition: transaction_impl.h:139
DD_kill_immunizer m_kill_immunizer
Definition: transaction_impl.h:146
Open_dictionary_tables_ctx otx
Definition: transaction_impl.h:141
THD * m_thd
Definition: transaction_impl.h:144
Class for storing/restoring state during dictionary update operations.
Definition: transaction_impl.h:154
enum_check_fields m_saved_check_for_truncated_fields
Definition: transaction_impl.h:175
~Update_dictionary_tables_ctx()
Definition: transaction_impl.cc:199
THD * m_thd
Definition: transaction_impl.h:163
DD_kill_immunizer m_kill_immunizer
Definition: transaction_impl.h:165
sql_mode_t m_saved_mode
Definition: transaction_impl.h:173
Query_tables_list * m_query_tables_list_backup
Definition: transaction_impl.h:167
long long m_latest_auto_incr_id
Definition: transaction_impl.h:174
ulong m_saved_auto_increment_increment
Definition: transaction_impl.h:186
uint m_saved_in_sub_stmt
Definition: transaction_impl.h:176
Open_dictionary_tables_ctx otx
Definition: transaction_impl.h:160
Open_tables_backup m_open_tables_state_backup
Definition: transaction_impl.h:170
ulonglong m_saved_options
Definition: transaction_impl.h:172
Update_dictionary_tables_ctx(THD *thd)
Definition: transaction_impl.cc:138
bool m_saved_binlog_row_based
Definition: transaction_impl.h:171
Discrete_intervals_list m_auto_inc_intervals_forced_saved
Definition: transaction_impl.h:191
Discrete_intervals_list m_auto_inc_intervals_in_cur_stmt_for_binlog_saved
Definition: transaction_impl.h:189
bool m_saved_time_zone_used
Definition: transaction_impl.h:177
uint64_t sql_mode_t
Definition: dd_event.h:39
enum_check_fields
Definition: field.h:174
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_tx_isolation
Definition: handler.h:3186
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