MySQL 8.0.40
Source Code Documentation
upgrade.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 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_UPGRADE__UPGRADE_H_INCLUDED
25#define DD_UPGRADE__UPGRADE_H_INCLUDED
26
27#include <stdio.h>
28
29#include "sql/dd/string_type.h"
30
31class THD;
32
33namespace dd {
34namespace upgrade_57 {
35
36/**
37 Check if the server is starting on a data directory without dictionary
38 tables or not.
39
40 If the dictionary tables are present, continue with restart of the server.
41
42 If the dictionary tables are not present, create the dictionary tables in
43 existing data directory. This function marks dd_upgrade_flag as true to
44 indicate to the server that Data dictionary is being upgraded.
45
46 metadata mysql.plugin table is migrated to the DD tables in case of upgrade.
47 mysql.plugin table is used to initialize all other Storage Engines.
48 This is necessary before migrating other user tables.
49
50 @param thd Thread context.
51
52 @return Upon failure, return true, otherwise false.
53*/
55
56/**
57 Finalize upgrade to the new data-dictionary by populating
58 Data Dictionary tables with metadata.
59
60 Populate metadata in Data dictionary tables.
61 This will be done for following database objects:
62 - Databases
63 - Tables
64 - Views
65 - Stored Procedures and Stored Functions
66 - Events
67 - Triggers
68
69 @param thd Thread context.
70
71 @return Upon failure, return true, otherwise false.
72*/
73bool fill_dd_and_finalize(THD *thd);
74
75/**
76 Drop all DD tables in case there is an error while upgrading server.
77
78 @param[in] thd Thread context.
79
80 @return Upon failure, return true, otherwise false.
81*/
82bool terminate(THD *thd);
83
84/**
85 Check if upgrade is in progress
86*/
87bool in_progress();
88
89/**
90 Check if creation of SDI file is allowed by upgrade.
91*/
93
94/**
95 Class to manage a temporary file to maintain the progress of the
96 upgrade. This file will help in error handling for crashes
97 during upgrade. After upgrade is successful, this file will be
98 deleted.
99*/
101 public:
102 // Stages of upgrade to be maintained in the file.
103 enum class enum_stage {
104 // Upgrade not started.
105 NONE,
106
107 // Upgrade from 5.7 detected, create this file and write 0 to it.
108 STARTED,
109
110 /*
111 Started InnoDB in upgrade mode, i.e., undo and redo logs are
112 upgraded and mysql.ibd is created.
113 */
115
116 // Dictionary tables are created.
118
119 /*
120 Dictionary initialization is complete and upgrade will start
121 processing user tables now.
122 */
124
125 // Upgrade of user tables is complete.
127
128 // SDI information is added to tablespaces.
130 };
131
132 public:
134
135 /**
136 Check if status file exists.
137
138 @returns true if exists, else false.
139 */
140 bool exists();
141
142 /**
143 Create status file.
144
145 @returns false on success, else true.
146 */
147 bool create();
148
149 /**
150 Get status from file.
151
152 @returns enum_stage.
153 */
154 enum_stage get();
155
156 /**
157 Update upgrade status.
158
159 @returns false on success, else true.
160 */
162
163 /**
164 Remove upgrade status file.
165
166 @returns false on success, else true.
167 */
168 bool remove();
169
170 private:
171 bool open(int flags);
173 [[nodiscard]] bool write(enum_stage status);
174 bool close();
175
176 private:
179};
180
181} // namespace upgrade_57
182} // namespace dd
183#endif // DD_UPGRADE__UPGRADE_H_INCLUDED
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Class to manage a temporary file to maintain the progress of the upgrade.
Definition: upgrade.h:100
bool open(int flags)
Definition: upgrade.cc:620
bool write(enum_stage status)
Definition: upgrade.cc:645
enum_stage get()
Get status from file.
Definition: upgrade.cc:583
bool create()
Create status file.
Definition: upgrade.cc:609
Upgrade_status()
Definition: upgrade.cc:605
bool exists()
Check if status file exists.
Definition: upgrade.cc:658
bool remove()
Remove upgrade status file.
Definition: upgrade.cc:679
enum_stage
Definition: upgrade.h:103
FILE * m_file
Definition: upgrade.h:177
const String_type m_filename
Definition: upgrade.h:178
enum_stage read()
Definition: upgrade.cc:633
bool close()
Definition: upgrade.cc:664
bool update(enum_stage status)
Update upgrade status.
Definition: upgrade.cc:594
static int flags[50]
Definition: hp_test1.cc:40
const std::string FILE("FILE")
bool fill_dd_and_finalize(THD *thd)
Finalize upgrade to the new data-dictionary by populating Data Dictionary tables with metadata.
Definition: upgrade.cc:1158
bool in_progress()
Check if upgrade is in progress.
Definition: upgrade.cc:114
bool allow_sdi_creation()
Check if creation of SDI file is allowed by upgrade.
Definition: upgrade.cc:118
bool do_pre_checks_and_initialize_dd(THD *thd)
Check if the server is starting on a data directory without dictionary tables or not.
Definition: upgrade.cc:837
bool terminate(THD *thd)
Drop all DD tables in case there is an error while upgrading server.
Definition: upgrade.cc:686
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
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:61