MySQL 26.7.0
Source Code Documentation
dd::upgrade Namespace Reference

Namespaces

namespace  anonymous_namespace{server.cc}
 

Classes

class  Bootstrap_error_handler
 Bootstrap thread executes SQL statements. More...
 
class  Routine_event_context_guard
 RAII for handling creation context of Events and Stored routines. More...
 
class  Syntax_error_handler
 This class keeps a count of all the syntax errors that occurred while parsing views, routines, events or triggers. More...
 
class  Upgrade_error_counter
 Class to keep track of upgrade errors during upgrade after 8.0 GA. More...
 

Typedefs

using Schema_name_index = std::unordered_map< dd::Object_id, dd::String_type >
 

Functions

bool upgrade_tables (THD *thd)
 
bool mock_open_to_check_def (THD *thd, const char *sn, const char *tn, const dd::Table &table)
 This function is used a replacement for open_table() when performing checks which cannot be done using the dd::Table object alone. More...
 
bool check_all_abstract_tables (THD *thd, const Schema_name_index &sni, const std::set< dd::String_type > *shared_spaces, Upgrade_error_counter *error_count)
 Scans mysql.tables and performs upgrade checks for tables and views. More...
 
void update_upgrade_history_file (bool initialize)
 Maintain a file named "mysql_upgrade_history" in the data directory. More...
 
bool do_server_upgrade_checks (THD *thd)
 Performs validation on server metadata. More...
 
bool invalid_routine (THD *thd, const dd::String_type &schema_name, const dd::Routine &routine)
 Validate a dd::Routine object. More...
 
bool invalid_triggers (THD *thd, const char *schema_name, const dd::Table &table)
 Validate all the triggers of the given table. More...
 
bool invalid_sql (THD *thd, const char *dbname, const dd::String_type &sql)
 Validate the SQL string provided. More...
 
bool build_event_sp (const THD *thd, const char *name, size_t name_len, const char *body, size_t body_len, dd::String_type *sp_sql)
 Helper function to create a stored procedure from an event body. More...
 
bool upgrade_system_schemas (THD *thd)
 Upgrades/restores the system tables to defaults of the current MySQL version. More...
 
bool no_server_upgrade_required ()
 
bool I_S_upgrade_required ()
 
bool plugin_initialize_delayed_after_upgrade ()
 Initialize delayed plugins. More...
 
void delay_initialization_of_dependent_plugins ()
 Reset state of delayed plugins to indicate that they wait for upgrade to complete. More...
 

Variables

constexpr const char * delayed_plugins [] = {"audit_log", "mysql_firewall"}
 

Typedef Documentation

◆ Schema_name_index

using dd::upgrade::Schema_name_index = typedef std::unordered_map<dd::Object_id, dd::String_type>

Function Documentation

◆ build_event_sp()

bool dd::upgrade::build_event_sp ( const THD thd,
const char *  name,
size_t  name_len,
const char *  body,
size_t  body_len,
dd::String_type sp_sql 
)

Helper function to create a stored procedure from an event body.

Parameters
[in]thdThread handle.
[in]nameName of the event.
[in]name_lenLength of the name of the event.
[in]bodyBody of the event.
[in]body_lenLength of the body of the event.
[out]sp_sqlStored procedure SQL string.
Return values
falseON SUCCESS
trueON FAILURE

◆ check_all_abstract_tables()

bool dd::upgrade::check_all_abstract_tables ( THD thd,
const Schema_name_index sni,
const std::set< dd::String_type > *  shared_spaces,
Upgrade_error_counter error_count 
)

Scans mysql.tables and performs upgrade checks for tables and views.

Parameters
thdTHD
sniSchema names indexed on schema_id
shared_spacesset of shared tablespace names
[out]error_counterror counter object
Returns
true if too many error encountered

◆ delay_initialization_of_dependent_plugins()

void dd::upgrade::delay_initialization_of_dependent_plugins ( )

Reset state of delayed plugins to indicate that they wait for upgrade to complete.

This means they will not be initialized yet.

◆ do_server_upgrade_checks()

bool dd::upgrade::do_server_upgrade_checks ( THD thd)

Performs validation on server metadata.

Parameters
thdThread context.
Returns
Upon failure, return true, otherwise false.

◆ I_S_upgrade_required()

bool dd::upgrade::I_S_upgrade_required ( )

◆ invalid_routine()

bool dd::upgrade::invalid_routine ( THD thd,
const dd::String_type schema_name,
const dd::Routine routine 
)

Validate a dd::Routine object.

Parameters
[in]thdThread handle.
[in]schema_nameSchema in which the routine belongs.
[in]routineRoutine to be validated.
Return values
falseON SUCCESS
trueON FAILURE

◆ invalid_sql()

bool dd::upgrade::invalid_sql ( THD thd,
const char *  dbname,
const dd::String_type sql 
)

Validate the SQL string provided.

Parameters
thdThread handle
dbnameThe database used in the SQL string's context.
sqlThe SQL string to be validated
Returns
true
false

◆ invalid_triggers()

bool dd::upgrade::invalid_triggers ( THD thd,
const char *  schema_name,
const dd::Table table 
)

Validate all the triggers of the given table.

Parameters
[in]thdThread handle.
[in]schema_namePointer for database name.
[in]tableTriggers of the table to be checked.
Return values
falseON SUCCESS
trueON FAILURE

◆ mock_open_to_check_def()

bool dd::upgrade::mock_open_to_check_def ( THD thd,
const char *  sn,
const char *  tn,
const dd::Table table 
)

This function is used a replacement for open_table() when performing checks which cannot be done using the dd::Table object alone.

It performs the same checks as opening the table would have, but uses the schema name and dd::Table objects passed as arguments so that a new scan of the dd tables is avoided. It does this by cherry-picking what it needs from get_table_share(). It does not cache the share and consequently does not acquire LOCK_open, does not update schema options, and does not read of histograms.

Note that since LOCK_open is not acquired the share is relased using share->destroy() rather than free_table_share(), and we don't assign a new table id to the share. Neither are required for this use of an uncached share.

Parameters
thdTHD
snschema name
tntable name
tabledd::Table object from for_each iteration
Returns
true on error

◆ no_server_upgrade_required()

bool dd::upgrade::no_server_upgrade_required ( )

◆ plugin_initialize_delayed_after_upgrade()

bool dd::upgrade::plugin_initialize_delayed_after_upgrade ( )

Initialize delayed plugins.

This function is used to initialize plugins that depend on changes in the environment if there has been upgrade of mysql tables used by the plugins.

Note
This function will initialize all plugins that are in state PLUGIN_IS_UNINITIALIZED. Plugins that are not in the submitted list of plugin names will either be in state PLUGIN_IS_READY at this point, or they should have been reaped already.
Returns
Operation outcome, false if no errors

◆ update_upgrade_history_file()

void dd::upgrade::update_upgrade_history_file ( bool  initialize)

Maintain a file named "mysql_upgrade_history" in the data directory.

The file will contain one entry for each upgrade. The format is structured text on JSON format.

Errors will be written as warnings to the error log; if we e.g. fail to open the upgrade history file, we will not abort the server since this file is not considered a critical feature of the server.

Parameters
initializeIf this is the initialization of the data directory.

◆ upgrade_system_schemas()

bool dd::upgrade::upgrade_system_schemas ( THD thd)

Upgrades/restores the system tables to defaults of the current MySQL version.

This is a replacement for the mysql_upgrade client.

There are four SQL scripts executed:

  1. mysql_system_tables.sql - Creates the system tables
  2. mysql_system_tables_fix.sql - Updates the system table
  3. mysql_system_tables_data_fix.sql - Fills the system tables with meta data
  4. ALL_SYS_SCHEMA.sql - Create and/or updates the sys schema

Then the system tables are checked by executing CHECK TABLE SQL statements.

This function is called during startup if the MySQL version present in DD_properties in not the same as the current MySQL version. This function can also be called if the server is started with –upgrade=FORCE option.

If the server is started with –upgrade=MINIMAL option with a newer MySQL server version Z on an older data directory of MySQL server version X, this function checks if server upgrade has been skipped before using another MySQL server version Y such that Y != Z, X < Y and X < Z. If yes, we abort.

The server upgrade ends with updating the MYSQLD_UPGRADED_VERSION value in DD_properties to the current server version (MYSQL_VERSION_ID).

Parameters
[in]thdThread handle.
Return values
falseON SUCCESS
trueON FAILURE

◆ upgrade_tables()

bool dd::upgrade::upgrade_tables ( THD thd)

Variable Documentation

◆ delayed_plugins

constexpr const char* dd::upgrade::delayed_plugins[] = {"audit_log", "mysql_firewall"}
constexpr