forked from facebook/mysql-5.6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade.h
182 lines (137 loc) · 4.53 KB
/
upgrade.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is also distributed with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have included with MySQL.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License, version 2.0, for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#ifndef DD_UPGRADE__UPGRADE_H_INCLUDED
#define DD_UPGRADE__UPGRADE_H_INCLUDED
#include <stdio.h>
#include "sql/dd/string_type.h"
class THD;
namespace dd {
namespace upgrade_57 {
/**
Check if the server is starting on a data directory without dictionary
tables or not.
If the dictionary tables are present, continue with restart of the server.
If the dictionary tables are not present, create the dictionary tables in
existing data directory. This function marks dd_upgrade_flag as true to
indicate to the server that Data dictionary is being upgraded.
metadata mysql.plugin table is migrated to the DD tables in case of upgrade.
mysql.plugin table is used to initialize all other Storage Engines.
This is necessary before migrating other user tables.
@param thd Thread context.
@return Upon failure, return true, otherwise false.
*/
bool do_pre_checks_and_initialize_dd(THD *thd);
/**
Finalize upgrade to the new data-dictionary by populating
Data Dictionary tables with metadata.
Populate metadata in Data dictionary tables.
This will be done for following database objects:
- Databases
- Tables
- Views
- Stored Procedures and Stored Functions
- Events
- Triggers
@param thd Thread context.
@return Upon failure, return true, otherwise false.
*/
bool fill_dd_and_finalize(THD *thd);
/**
Drop all DD tables in case there is an error while upgrading server.
@param[in] thd Thread context.
@return Upon failure, return true, otherwise false.
*/
bool terminate(THD *thd);
/**
Check if upgrade is in progress
*/
bool in_progress();
/**
Check if creation of SDI file is allowed by upgrade.
*/
bool allow_sdi_creation();
/**
Class to manage a temporary file to maintain the progress of the
upgrade. This file will help in error handling for crashes
during upgrade. After upgrade is successful, this file will be
deleted.
*/
class Upgrade_status {
public:
// Stages of upgrade to be maintained in the file.
enum class enum_stage {
// Upgrade not started.
NONE,
// Upgrade from 5.7 detected, create this file and write 0 to it.
STARTED,
/*
Started DDSE in upgrade mode, i.e. in the case of InnoDB, undo and redo
logs are upgraded and mysql.ibd is created.
*/
DICT_SPACE_CREATED,
// Dictionary tables are created.
DICT_TABLES_CREATED,
/*
Dictionary initialization is complete and upgrade will start
processing user tables now.
*/
DICTIONARY_CREATED,
// Upgrade of user tables is complete.
USER_TABLE_UPGRADED,
// SDI information is added to tablespaces.
SDI_INFO_UPDATED
};
public:
Upgrade_status();
/**
Check if status file exists.
@returns true if exists, else false.
*/
bool exists();
/**
Create status file.
@returns false on success, else true.
*/
bool create();
/**
Get status from file.
@returns enum_stage.
*/
enum_stage get();
/**
Update upgrade status.
@returns false on success, else true.
*/
bool update(enum_stage status);
/**
Remove upgrade status file.
@returns false on success, else true.
*/
bool remove();
private:
bool open(int flags);
enum_stage read();
[[nodiscard]] bool write(enum_stage status);
bool close();
private:
FILE *m_file;
const String_type m_filename;
};
} // namespace upgrade_57
} // namespace dd
#endif // DD_UPGRADE__UPGRADE_H_INCLUDED