Debian Codegraph @

storage/innobase/include/dict0upgrade.h

raw
1 /*****************************************************************************
2
3 Copyright (c) 1996, 2026, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20 for more details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26 *****************************************************************************/
27
28 #include "my_inttypes.h"
29
30 class THD;
31 struct TABLE;
32
33 /* This is used only during upgrade. We don't use ids
34 from DICT_HDR during upgrade because unlike bootstrap case,
35 the ids are moved after user table creation. Since we
36 want to create dictionary tables with fixed ids, we use
37 in-memory counter for upgrade */
38 extern uint32_t dd_upgrade_indexes_num;
39
40 namespace dd {
41 class Table;
42 class Tablespace;
43 } // namespace dd
44
45 /** Migrate table from InnoDB Dictionary (INNODB SYS_*) tables to new Data
46 Dictionary. Since FTS tables contain table_id in their physical file name
47 and during upgrade we reserve DICT_MAX_DD_TABLES for dictionary tables.
48 So we rename FTS tablespace files
49 @param[in] thd Server thread object
50 @param[in] db_name database name
51 @param[in] table_name table name
52 @param[in,out] dd_table new dictionary table object to be filled
53 @param[in] srv_table server table object
54 @return false on success, true on failure. */
55 bool dd_upgrade_table(THD *thd, const char *db_name, const char *table_name,
56 dd::Table *dd_table, TABLE *srv_table);
57
58 /** Migrate tablespace entries from InnoDB SYS_TABLESPACES to new data
59 dictionary. FTS Tablespaces are not registered as they are handled differently.
60 FTS tablespaces have table_id in their name and we increment table_id of each
61 table by DICT_MAX_DD_TABLES
62 @param[in,out] thd THD
63 @return MySQL error code */
64 int dd_upgrade_tablespace(THD *thd);
65
66 /** Add server and space version number to tablespace while upgrading.
67 @param[in] space_id space id of tablespace
68 @param[in] server_version_only leave space version unchanged
69 @return false on success, true on failure. */
70 bool upgrade_space_version(const uint32_t space_id, bool server_version_only);
71
72 /** Add server version number to tablespace while upgrading.
73 @param[in] tablespace dd::Tablespace
74 @return false on success, true on failure. */
75 bool upgrade_space_version(dd::Tablespace *tablespace);
76
77 /** Upgrade innodb undo logs after upgrade. Also increment the table_id
78 offset by DICT_MAX_DD_TABLES. This offset increment is because the
79 first 256 table_ids are reserved for dictionary.
80 @param[in,out] thd THD
81 @return MySQL error code */
82 int dd_upgrade_logs(THD *thd);
83
84 /** If upgrade is successful, this API is used to flush innodb
85 dirty pages to disk. In case of server crash, this function
86 sets storage engine for rollback any changes.
87 @param[in,out] thd THD
88 @param[in] failed_upgrade true when upgrade failed
89 @return MySQL error code*/
90 int dd_upgrade_finish(THD *thd, bool failed_upgrade);