MySQL 9.1.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...
 

Functions

bool upgrade_tables (THD *thd)
 
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::Schema &schema, 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"}
 

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

◆ 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::Schema schema,
const dd::Routine routine 
)

Validate a dd::Routine object.

Parameters
[in]thdThread handle.
[in]schemaSchema 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

◆ 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