MySQL 8.0.40
Source Code Documentation
|
#include "dict0upgrade.h"
#include <sql_backup_lock.h>
#include <sql_class.h>
#include <sql_show.h>
#include <sql_table.h>
#include <sql_tablespace.h>
#include <algorithm>
#include <regex>
#include "dict0boot.h"
#include "dict0crea.h"
#include "dict0dd.h"
#include "dict0dict.h"
#include "dict0load.h"
#include "ha_innodb.h"
#include "ha_innopart.h"
#include "log0buf.h"
#include "log0chkp.h"
#include "row0sel.h"
#include "srv0start.h"
Classes | |
struct | upgrade_space_t |
Tablespace information required to create a dd::Tablespace object. More... | |
Functions | |
static bool | dd_upgrade_table_fk (dict_table_t *ib_table, dd::Table *dd_table) |
Fill foreign key information from InnoDB table to server table. More... | |
static dd::Tablespace * | dd_upgrade_get_tablespace (dd::cache::Dictionary_client *dd_client, dict_table_t *ib_table) |
Get Server Tablespace object for a InnoDB table. More... | |
static Field * | dd_upgrade_get_field (const TABLE *srv_table, const char *name) |
Get field from Server table object. More... | |
static bool | dd_has_explicit_pk (const dd::Table *dd_table) |
Return true if table has primary key given by user else false. More... | |
static bool | dd_upgrade_match_single_col (const Field *field, const dict_col_t *col) |
Match InnoDB column object and Server column object. More... | |
static bool | dd_upgrade_match_cols (const TABLE *srv_table, const dd::Table *dd_table, const dict_table_t *ib_table, bool skip_fts_col) |
static uint32_t | dd_upgrade_find_index (TABLE *srv_table, const char *name) |
Find key number from a server table object. More... | |
static bool | dd_upgrade_match_index (TABLE *srv_table, dict_index_t *index) |
Match InnoDB index definition from Server object. More... | |
static bool | dd_upgrade_check_for_autoinc (TABLE *srv_table, const char *&auto_inc_index_name, const char *&auto_inc_col_name) |
static void | dd_upgrade_set_auto_inc (const TABLE *srv_table, dd::Table *dd_table, uint64_t auto_inc_value) |
Set auto-inc field value in dd::Table object. More... | |
template<typename Index > | |
static void | dd_upgrade_process_index (Index dd_index, dict_index_t *index, dd::Object_id dd_space_id, bool has_auto_inc, const char *auto_inc_index_name, const char *auto_inc_col_name, uint64_t *read_auto_inc) |
static bool | dd_upgrade_ensure_has_dd_space_id (THD *thd, dict_table_t *ib_table) |
Ensures that the ib_table->dd_space_id is properly initialized. More... | |
static bool | dd_upgrade_partitions (THD *thd, const char *norm_name, dd::Table *dd_table, TABLE *srv_table) |
Migrate partitions to new dictionary. More... | |
static void | dd_upgrade_set_row_type (dict_table_t *ib_table, dd::Table *dd_table) |
bool | dd_upgrade_fix_fts_column (dd::Table *dd_table, dict_table_t *ib_table) |
bool | dd_upgrade_table (THD *thd, const char *db_name, const char *table_name, dd::Table *dd_table, TABLE *srv_table) |
Migrate table from InnoDB Dictionary (INNODB SYS_*) tables to new Data Dictionary. More... | |
static uint32_t | dd_upgrade_register_tablespace (dd::cache::Dictionary_client *dd_client, dd::Tablespace *dd_space, upgrade_space_t *upgrade_space) |
Register InnoDB tablespace to mysql dictionary table mysql.tablespaces. More... | |
int | dd_upgrade_tablespace (THD *thd) |
Migrate tablespace entries from InnoDB SYS_TABLESPACES to new data dictionary. More... | |
bool | upgrade_space_version (const uint32_t space_id, bool server_version_only) |
Add server and space version number to tablespace while upgrading. More... | |
bool | upgrade_space_version (dd::Tablespace *tablespace) |
Add server version number to tablespace while upgrading. More... | |
int | dd_upgrade_logs (THD *) |
Upgrade innodb undo logs after upgrade. More... | |
static void | dd_upgrade_drop_sys_tables () |
Drop all InnoDB Dictionary tables (SYS_*). More... | |
static void | dd_upgrade_drop_57_backup_spaces () |
Stat backup tables(innodb_*_stats_backup57) are created by server before upgrade and dropped after upgrade is successful. More... | |
static void | dd_upgrade_fts_rename_cleanup (bool failed_upgrade) |
Rename back the FTS AUX tablespace names from 8.0 format to 5.7 format on upgrade failure, else mark FTS aux tables evictable. More... | |
int | dd_upgrade_finish (THD *, bool failed_upgrade) |
If upgrade is successful, this API is used to flush innodb dirty pages to disk. More... | |
Variables | |
uint32_t | dd_upgrade_indexes_num = 1 |
static std::vector< std::string > | tables_with_fts |
Vector of tables that have FTS indexes. More... | |
|
static |
Return true if table has primary key given by user else false.
[in] | dd_table | Server table object |
true | Table has PK given by user |
false | Primary Key is hidden and generated |
|
static |
|
static |
Stat backup tables(innodb_*_stats_backup57) are created by server before upgrade and dropped after upgrade is successful.
Innodb tablespaces for these tables still exists because InnoDB post DDL hook is skipped on bootstrap thread. This is a work around to cleanup the Innodb tablespaces till the time server could enable post DDL hook while dropping these tables.
|
static |
Drop all InnoDB Dictionary tables (SYS_*).
This is done only at the end of successful upgrade
|
static |
Ensures that the ib_table->dd_space_id is properly initialized.
[in] | thd | The THD to identify as during lookup |
[in] | ib_table | The instance to be initialized |
|
static |
Find key number from a server table object.
[in] | srv_table | server table object |
[in] | name | index name |
UINT32_MAX | if index not found, else key number |
int dd_upgrade_finish | ( | THD * | thd, |
bool | failed_upgrade | ||
) |
If upgrade is successful, this API is used to flush innodb dirty pages to disk.
In case of server crash, this function sets storage engine for rollback any changes.
[in,out] | thd | THD |
[in] | failed_upgrade | true when upgrade failed |
bool dd_upgrade_fix_fts_column | ( | dd::Table * | dd_table, |
dict_table_t * | ib_table | ||
) |
|
static |
Rename back the FTS AUX tablespace names from 8.0 format to 5.7 format on upgrade failure, else mark FTS aux tables evictable.
[in] | failed_upgrade | true on upgrade failure, else false |
Get field from Server table object.
[in] | srv_table | server table object |
[in] | name | Field name |
|
static |
Get Server Tablespace object for a InnoDB table.
The tablespace is acquired with MDL and for modification, so the caller can update the dd::Tablespace object returned.
[in,out] | dd_client | dictionary client to retrieve tablespace object |
[in] | ib_table | InnoDB table |
int dd_upgrade_logs | ( | THD * | thd | ) |
Upgrade innodb undo logs after upgrade.
Also increment the table_id offset by DICT_MAX_DD_TABLES. This offset increment is because the first 256 table_ids are reserved for dictionary.
[in,out] | thd | THD |
|
static |
|
static |
Match InnoDB index definition from Server object.
[in] | srv_table | Server table object |
[in] | index | InnoDB index |
false | Index definition matches |
true | Index definition mismatch |
|
static |
Match InnoDB column object and Server column object.
[in] | field | Server field object |
[in] | col | InnoDB column object |
false | column definition matches |
true | column definition mismatch |
|
static |
Migrate partitions to new dictionary.
[in] | thd | Server thread object |
[in] | norm_name | partition table name |
[in,out] | dd_table | Server new DD table object to be filled |
[in] | srv_table | Server table object |
|
static |
|
static |
Register InnoDB tablespace to mysql dictionary table mysql.tablespaces.
[in] | dd_client | dictionary client |
[in] | dd_space | server tablespace object |
[in] | upgrade_space | upgrade tablespace object |
|
static |
Set auto-inc field value in dd::Table object.
[in] | srv_table | server table object |
[in,out] | dd_table | dd table object to be filled |
[in,out] | auto_inc_value | auto_inc value |
|
static |
bool dd_upgrade_table | ( | THD * | thd, |
const char * | db_name, | ||
const char * | table_name, | ||
dd::Table * | dd_table, | ||
TABLE * | srv_table | ||
) |
Migrate table from InnoDB Dictionary (INNODB SYS_*) tables to new Data Dictionary.
Since FTS tables contain table_id in their physical file name and during upgrade we reserve DICT_MAX_DD_TABLES for dictionary tables. So we rename FTS tablespace files
[in] | thd | Server thread object |
[in] | db_name | database name |
[in] | table_name | table name |
[in,out] | dd_table | new dictionary table object to be filled |
[in] | srv_table | server table object |
|
static |
Fill foreign key information from InnoDB table to server table.
[in] | ib_table | InnoDB table object |
[in,out] | dd_table | DD table object |
int dd_upgrade_tablespace | ( | THD * | thd | ) |
Migrate tablespace entries from InnoDB SYS_TABLESPACES to new data dictionary.
FTS Tablespaces are not registered as they are handled differently. FTS tablespaces have table_id in their name and we increment table_id of each table by DICT_MAX_DD_TABLES
[in,out] | thd | THD |
bool upgrade_space_version | ( | const uint32_t | space_id, |
bool | server_version_only | ||
) |
Add server and space version number to tablespace while upgrading.
[in] | space_id | space id of tablespace |
[in] | server_version_only | leave space version unchanged |
bool upgrade_space_version | ( | dd::Tablespace * | tablespace | ) |
Add server version number to tablespace while upgrading.
[in] | tablespace | dd::Tablespace |
uint32_t dd_upgrade_indexes_num = 1 |
|
static |
Vector of tables that have FTS indexes.
Used for reverting from 8.0 format FTS AUX table names to 5.7 FTS AUX table names