MySQL  8.0.19
Source Code Documentation
transaction_impl.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2019, 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 
114  @returns void.
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
view_impl.h
spatial_reference_system_impl.h
sql_class.h
THD
Definition: sql_class.h:764
dd::Open_dictionary_tables_ctx::open_tables
bool open_tables()
Open all the DD tables in list Open_dictionary_tables_ctx::m_tables.
Definition: transaction_impl.cc:55
dd::Update_dictionary_tables_ctx::m_saved_time_zone_used
bool m_saved_time_zone_used
Definition: transaction_impl.h:178
dd::Update_dictionary_tables_ctx
Class for storing/restoring state during dictionary update operations.
Definition: transaction_impl.h:155
dd::Update_dictionary_tables_ctx::m_auto_inc_intervals_in_cur_stmt_for_binlog_saved
Discrete_intervals_list m_auto_inc_intervals_in_cur_stmt_for_binlog_saved
Definition: transaction_impl.h:190
dd::Transaction_ro::otx
Open_dictionary_tables_ctx otx
Definition: transaction_impl.h:142
dd::Open_dictionary_tables_ctx::add_table
void add_table()
Definition: transaction_impl.h:95
dd::String_type
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
dd::Open_dictionary_tables_ctx::get_thd
THD * get_thd() const
Definition: transaction_impl.h:109
dd::Update_dictionary_tables_ctx::m_auto_inc_intervals_forced_saved
Discrete_intervals_list m_auto_inc_intervals_forced_saved
Definition: transaction_impl.h:192
parameter_impl.h
dd::Open_dictionary_tables_ctx::m_tables
Object_table_map m_tables
Definition: transaction_impl.h:125
dd::Update_dictionary_tables_ctx::m_lex_saved
LEX * m_lex_saved
Definition: transaction_impl.h:168
table_impl.h
view_routine_impl.h
Open_tables_backup
Storage for backup of Open_tables_state.
Definition: sql_class.h:562
dd::Update_dictionary_tables_ctx::m_saved_check_for_truncated_fields
enum_check_fields m_saved_check_for_truncated_fields
Definition: transaction_impl.h:176
column_impl.h
dd::Transaction_ro::Transaction_ro
Transaction_ro(THD *thd, enum_tx_isolation isolation)
Definition: transaction_impl.h:134
index_stat_impl.h
dd::Open_dictionary_tables_ctx::get_table
Raw_table * get_table() const
Definition: transaction_impl.h:85
enum_check_fields
enum_check_fields
Definition: field.h:169
dd::Update_dictionary_tables_ctx::m_open_tables_state_backup
Open_tables_backup m_open_tables_state_backup
Definition: transaction_impl.h:171
routine_impl.h
view_table_impl.h
dd
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
THD::begin_attachable_ro_transaction
void begin_attachable_ro_transaction()
Start a read-only attachable transaction.
Definition: sql_class.cc:1840
dd::Transaction_ro::~Transaction_ro
~Transaction_ro()
Definition: transaction_impl.h:140
handler.h
column_statistics_impl.h
dd::Open_dictionary_tables_ctx
Auxiliary class for opening dictionary tables.
Definition: transaction_impl.h:75
dd::Update_dictionary_tables_ctx::m_latest_auto_incr_id
long long m_latest_auto_incr_id
Definition: transaction_impl.h:175
dd::Transaction_ro::m_kill_immunizer
DD_kill_immunizer m_kill_immunizer
Definition: transaction_impl.h:147
my_inttypes.h
discrete_interval.h
dd::Open_dictionary_tables_ctx::mark_ignore_global_read_lock
void mark_ignore_global_read_lock()
Ignore global read lock when opening the tables.
Definition: transaction_impl.h:116
field.h
dd::Open_dictionary_tables_ctx::m_lock_type
thr_lock_type m_lock_type
Definition: transaction_impl.h:122
dd::Open_dictionary_tables_ctx::Object_table_map
std::map< String_type, Raw_table * > Object_table_map
Definition: transaction_impl.h:124
dd::Open_dictionary_tables_ctx::register_tables
void register_tables()
Definition: transaction_impl.h:90
schema_impl.h
dd::Update_dictionary_tables_ctx::m_thd
THD * m_thd
Definition: transaction_impl.h:164
dd::DD_kill_immunizer
RAII class for immunizing the THD from kill operations.
Definition: dd_kill_immunizer.h:45
set_var.h
uint
unsigned int uint
Definition: uca-dump.cc:29
dd::Update_dictionary_tables_ctx::m_saved_options
ulonglong m_saved_options
Definition: transaction_impl.h:173
string_type.h
dd::Transaction_ro::m_thd
THD * m_thd
Definition: transaction_impl.h:145
foreign_key_impl.h
dd::Update_dictionary_tables_ctx::m_saved_mode
sql_mode_t m_saved_mode
Definition: transaction_impl.h:174
collation_impl.h
trigger_impl.h
resource_group_impl.h
dd::Open_dictionary_tables_ctx::m_ignore_global_read_lock
bool m_ignore_global_read_lock
Definition: transaction_impl.h:123
dd::Update_dictionary_tables_ctx::m_kill_immunizer
DD_kill_immunizer m_kill_immunizer
Definition: transaction_impl.h:166
sql_mode_t
ulonglong sql_mode_t
Definition: dd_event.h:36
thr_lock_type
thr_lock_type
Definition: thr_lock.h:50
check_constraint_impl.h
name
const string name("\"Name\"")
TL_READ
@ TL_READ
Definition: thr_lock.h:61
charset_impl.h
dd_kill_immunizer.h
LEX
Definition: sql_lex.h:3221
dd::Open_dictionary_tables_ctx::Open_dictionary_tables_ctx
Open_dictionary_tables_ctx(THD *thd, thr_lock_type lock_type)
Definition: transaction_impl.h:77
tablespace_impl.h
dd::Update_dictionary_tables_ctx::~Update_dictionary_tables_ctx
~Update_dictionary_tables_ctx()
Definition: transaction_impl.cc:199
dd::Open_dictionary_tables_ctx::m_thd
THD * m_thd
Definition: transaction_impl.h:121
dd::Update_dictionary_tables_ctx::otx
Open_dictionary_tables_ctx otx
Definition: transaction_impl.h:161
abstract_table_impl.h
event_impl.h
dd::Update_dictionary_tables_ctx::Update_dictionary_tables_ctx
Update_dictionary_tables_ctx(THD *thd)
Definition: transaction_impl.cc:139
ulong
unsigned long ulong
Definition: my_inttypes.h:48
function_impl.h
ulonglong
unsigned long long int ulonglong
Definition: my_inttypes.h:55
thr_lock.h
Discrete_intervals_list
List of Discrete_interval objects.
Definition: discrete_interval.h:86
dd::Open_dictionary_tables_ctx::~Open_dictionary_tables_ctx
~Open_dictionary_tables_ctx()
Definition: transaction_impl.cc:42
udf_registration_types.h
THD::end_attachable_transaction
void end_attachable_transaction()
End an active attachable transaction.
Definition: sql_class.cc:1844
partition_impl.h
dd::Raw_table
Definition: raw_table.h:43
dd::Update_dictionary_tables_ctx::m_saved_binlog_row_based
bool m_saved_binlog_row_based
Definition: transaction_impl.h:172
THD::tx_isolation
enum_tx_isolation tx_isolation
Definition: sql_class.h:2207
procedure_impl.h
dd::Transaction_ro
Implementation of read-only data-dictionary transaction.
Definition: transaction_impl.h:132
table_stat_impl.h
dd::Update_dictionary_tables_ctx::m_saved_auto_increment_increment
ulong m_saved_auto_increment_increment
Definition: transaction_impl.h:187
TL_WRITE
@ TL_WRITE
Definition: thr_lock.h:91
enum_tx_isolation
enum_tx_isolation
Definition: handler.h:2614
dd::Update_dictionary_tables_ctx::m_saved_in_sub_stmt
uint m_saved_in_sub_stmt
Definition: transaction_impl.h:177
false
#define false
Definition: config_static.h:43