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