MySQL  8.0.17
Source Code Documentation
upgrade.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, 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_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 
30 class THD;
31 
32 namespace dd {
33 namespace 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 dicionary 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 */
72 bool 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 */
81 bool terminate(THD *thd);
82 
83 /**
84  Check if upgrade is in progress
85 */
86 bool in_progress();
87 
88 /**
89  Check if creation of SDI file is allowed by upgrade.
90 */
91 bool allow_sdi_creation();
92 
93 /**
94  Class to manage a temporary file to maintain the progess 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:
132  Upgrade_status();
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  */
160  bool update(enum_stage status);
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);
171  enum_stage read();
172  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
const String_type m_filename
Definition: upgrade.h:177
bool in_progress()
Check if upgrade is in progress.
Definition: upgrade.cc:113
Upgrade_status()
Definition: upgrade.cc:605
bool close()
Definition: upgrade.cc:659
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:830
Char_string_template< String_type_allocator > String_type
Definition: string_type.h:50
FILE * m_file
Definition: upgrade.h:176
const std::string FILE("FILE")
bool exists()
Check if status file exists.
Definition: upgrade.cc:653
enum_stage
Definition: upgrade.h:102
bool write(enum_stage status)
Definition: upgrade.cc:645
bool allow_sdi_creation()
Check if creation of SDI file is allowed by upgrade.
Definition: upgrade.cc:117
bool update(enum_stage status)
Update upgrade status.
Definition: upgrade.cc:594
bool fill_dd_and_finalize(THD *thd)
Finalize upgrade to the new data-dictionary by populating Data Dictionary tables with metadata...
Definition: upgrade.cc:1112
bool open(int flags)
Definition: upgrade.cc:620
bool create()
Create status file.
Definition: upgrade.cc:609
Class to manage a temporary file to maintain the progess of the upgrade.
Definition: upgrade.h:99
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
static STATUS status
Definition: mysql.cc:191
static int flags[50]
Definition: hp_test1.cc:39
enum_stage read()
Definition: upgrade.cc:633
bool terminate(THD *thd)
Drop all DD tables in case there is an error while upgrading server.
Definition: upgrade.cc:681
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:777