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