MySQL 8.1.0
Source Code Documentation
bootstrap_ctx.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2023, 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 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__BOOTSTRAP_CTX_INCLUDED
24#define DD__BOOTSTRAP_CTX_INCLUDED
25
26#include <assert.h>
27#include <set>
28
29#include "my_inttypes.h" // uint
30#include "mysql_version.h" // MYSQL_VERSION_ID
31#include "sql/dd/dd_version.h" // DD_VERSION
32#include "sql/dd/info_schema/metadata.h" // IS_DD_VERSION
33#include "sql/mysqld.h" // opt_initialize
34
35class THD;
36
37namespace dd {
38namespace bootstrap {
39
40// Enumeration of bootstrapping stages.
41enum class Stage {
42 NOT_STARTED, // Not started.
43 STARTED, // Started, nothing prepared yet.
44 CREATED_TABLESPACES, // Created predefined tablespaces.
45 FETCHED_PROPERTIES, // Done reading DD properties.
46 CREATED_TABLES, // Tables created, able to store persistently.
47 SYNCED, // Cached meta data synced with persistent storage.
48 UPGRADED_TABLES, // Created new table versions and migrated meta data.
49 POPULATED, // (Re)populated tables with meta data.
50 STORED_DD_META_DATA, // Stored the hard coded meta data of the DD tables.
51 VERSION_UPDATED, // The properties in 'dd_properties' are updated.
52 FINISHED // Completed.
53};
54
55// Individual DD version labels that we can refer to.
56static constexpr uint DD_VERSION_80011 = 80011;
57static constexpr uint DD_VERSION_80012 = 80012;
58static constexpr uint DD_VERSION_80013 = 80013;
59static constexpr uint DD_VERSION_80014 = 80014;
60static constexpr uint DD_VERSION_80015 = 80015;
61static constexpr uint DD_VERSION_80016 = 80016;
62static constexpr uint DD_VERSION_80017 = 80017;
63static constexpr uint DD_VERSION_80021 = 80021;
64static constexpr uint DD_VERSION_80022 = 80022;
65static constexpr uint DD_VERSION_80023 = 80023;
66
67/*
68 Set of supported DD version labels. A supported DD version is a version
69 from which we can upgrade. In the case of downgrade, this is not relevant,
70 since the set of supported versions is defined when the server is built,
71 and newer version numbers are not added to this set. in the case of
72 downgrade, we instead have to check the MINOR_DOWNGRADE_THRESHOLD, which is
73 stored in the 'dd_properties' table by the server from which we downgrade.
74*/
75static std::set<uint> supported_dd_versions = {
79
80// Individual server version labels that we can refer to.
81static constexpr uint SERVER_VERSION_50700 = 50700;
82static constexpr uint SERVER_VERSION_80011 = 80011;
83static constexpr uint SERVER_VERSION_80013 = 80013;
84static constexpr uint SERVER_VERSION_80014 = 80014;
85static constexpr uint SERVER_VERSION_80015 = 80015;
86static constexpr uint SERVER_VERSION_80016 = 80016;
87
88/*
89 Set of unsupported server version labels. An unsupported server version is a
90 version from which we can't upgrade.
91*/
92static std::set<uint> unsupported_server_versions = {};
93
95 private:
100
103
104 public:
105 DD_bootstrap_ctx() = default;
106
107 static DD_bootstrap_ctx &instance();
108
109 Stage get_stage() const { return m_stage; }
110
111 void set_stage(Stage stage) { m_stage = stage; }
112
113 bool supported_dd_version() const {
116 }
117
118 void set_actual_dd_version(uint actual_dd_version) {
119 m_actual_dd_version = actual_dd_version;
120 }
121
122 void set_actual_I_S_version(uint actual_I_S_version) {
123 m_actual_I_S_version = actual_I_S_version;
124 }
125
127
129
131 assert(m_did_dd_upgrade_from == 0);
132 assert(is_dd_upgrade());
134 }
135
136 bool dd_upgrade_done() const { return m_did_dd_upgrade_from != 0; }
137
139 assert(m_did_I_S_upgrade_from == 0);
141 }
142
143 bool I_S_upgrade_done() const { return m_did_I_S_upgrade_from != 0; }
144
145 bool actual_dd_version_is(uint compare_actual_dd_version) const {
146 return (m_actual_dd_version == compare_actual_dd_version);
147 }
148
150 return (unsupported_server_versions.find(version) ==
153 }
154
157 }
158
159 void set_upgraded_server_version(uint upgraded_server_version) {
160 m_upgraded_server_version = upgraded_server_version;
161 }
162
164
165 bool upgraded_server_version_is(uint compare_upgraded_server_version) const {
166 return (m_upgraded_server_version == compare_upgraded_server_version);
167 }
168
169 bool is_restart() const {
172 }
173
174 bool is_dd_upgrade() const {
176 }
177
178 bool is_server_upgrade() const {
180 }
181
182 bool is_dd_upgrade_from_before(uint compare_actual_dd_version) const {
183 return (is_dd_upgrade() && m_actual_dd_version < compare_actual_dd_version);
184 }
185
187 uint compare_upgraded_server_version) const {
188 return (is_server_upgrade() &&
189 m_upgraded_server_version < compare_upgraded_server_version);
190 }
191
193 uint compare_upgraded_server_version) const {
194 return (is_server_upgrade() &&
195 m_upgraded_server_version > compare_upgraded_server_version);
196 }
197
198 bool is_minor_downgrade() const {
199 return !opt_initialize &&
200 (m_actual_dd_version / 10000 == dd::DD_VERSION / 10000) &&
202 }
203
205
206 bool is_initialize() const {
208 }
209};
210
211} // namespace bootstrap
212} // namespace dd
213
214#endif // DD__BOOTSTRAP_CTX_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
Definition: bootstrap_ctx.h:94
bool I_S_upgrade_done() const
Definition: bootstrap_ctx.h:143
bool is_minor_downgrade() const
Definition: bootstrap_ctx.h:198
bool supported_server_version(uint version) const
Definition: bootstrap_ctx.h:149
bool supported_server_version() const
Definition: bootstrap_ctx.h:155
bool is_server_upgrade_from_after(uint compare_upgraded_server_version) const
Definition: bootstrap_ctx.h:192
bool is_server_upgrade_from_before(uint compare_upgraded_server_version) const
Definition: bootstrap_ctx.h:186
bool is_initialize() const
Definition: bootstrap_ctx.h:206
void set_I_S_upgrade_done()
Definition: bootstrap_ctx.h:138
uint m_actual_dd_version
Definition: bootstrap_ctx.h:97
uint m_did_I_S_upgrade_from
Definition: bootstrap_ctx.h:101
void set_upgraded_server_version(uint upgraded_server_version)
Definition: bootstrap_ctx.h:159
uint get_actual_dd_version() const
Definition: bootstrap_ctx.h:126
void set_dd_upgrade_done()
Definition: bootstrap_ctx.h:130
void set_actual_dd_version(uint actual_dd_version)
Definition: bootstrap_ctx.h:118
uint get_actual_I_S_version() const
Definition: bootstrap_ctx.h:128
bool is_restart() const
Definition: bootstrap_ctx.h:169
bool is_dd_upgrade() const
Definition: bootstrap_ctx.h:174
Stage m_stage
Definition: bootstrap_ctx.h:99
bool supported_dd_version() const
Definition: bootstrap_ctx.h:113
uint m_upgraded_server_version
Definition: bootstrap_ctx.h:98
static DD_bootstrap_ctx & instance()
Definition: bootstrap_ctx.cc:29
Stage get_stage() const
Definition: bootstrap_ctx.h:109
uint get_upgraded_server_version() const
Definition: bootstrap_ctx.h:163
void set_stage(Stage stage)
Definition: bootstrap_ctx.h:111
bool is_server_upgrade() const
Definition: bootstrap_ctx.h:178
bool is_dd_upgrade_from_before(uint compare_actual_dd_version) const
Definition: bootstrap_ctx.h:182
uint m_did_dd_upgrade_from
Definition: bootstrap_ctx.h:96
bool upgraded_server_version_is(uint compare_upgraded_server_version) const
Definition: bootstrap_ctx.h:165
bool actual_dd_version_is(uint compare_actual_dd_version) const
Definition: bootstrap_ctx.h:145
uint m_actual_I_S_version
Definition: bootstrap_ctx.h:102
bool dd_upgrade_done() const
Definition: bootstrap_ctx.h:136
void set_actual_I_S_version(uint actual_I_S_version)
Definition: bootstrap_ctx.h:122
bool is_above_minor_downgrade_threshold(THD *thd) const
Definition: bootstrap_ctx.cc:34
Data dictionary version.
Some integer typedefs for easier portability.
#define MYSQL_VERSION_ID
Definition: mysql_version.h:15
bool opt_initialize
Definition: mysqld.cc:1234
Definition: bootstrap.cc:69
static constexpr uint DD_VERSION_80015
Definition: bootstrap_ctx.h:60
Stage
Definition: bootstrap_ctx.h:41
static constexpr uint SERVER_VERSION_80011
Definition: bootstrap_ctx.h:82
static constexpr uint DD_VERSION_80014
Definition: bootstrap_ctx.h:59
static constexpr uint SERVER_VERSION_80015
Definition: bootstrap_ctx.h:85
static constexpr uint DD_VERSION_80013
Definition: bootstrap_ctx.h:58
static constexpr uint DD_VERSION_80016
Definition: bootstrap_ctx.h:61
static constexpr uint DD_VERSION_80012
Definition: bootstrap_ctx.h:57
static std::set< uint > supported_dd_versions
Definition: bootstrap_ctx.h:75
static constexpr uint DD_VERSION_80023
Definition: bootstrap_ctx.h:65
static constexpr uint DD_VERSION_80022
Definition: bootstrap_ctx.h:64
static constexpr uint SERVER_VERSION_80013
Definition: bootstrap_ctx.h:83
static constexpr uint DD_VERSION_80021
Definition: bootstrap_ctx.h:63
static constexpr uint DD_VERSION_80017
Definition: bootstrap_ctx.h:62
static constexpr uint SERVER_VERSION_50700
Definition: bootstrap_ctx.h:81
static std::set< uint > unsupported_server_versions
Definition: bootstrap_ctx.h:92
static constexpr uint SERVER_VERSION_80014
Definition: bootstrap_ctx.h:84
static constexpr uint SERVER_VERSION_80016
Definition: bootstrap_ctx.h:86
static constexpr uint DD_VERSION_80011
Definition: bootstrap_ctx.h:56
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:42
static const uint DD_VERSION
Definition: dd_version.h:209
required uint64 version
Definition: replication_group_member_actions.proto:40