MySQL 8.3.0
Source Code Documentation
mysqlbackup.cc File Reference
#include "mysqlbackup.h"
#include <atomic>
#include "backup_comp_constants.h"
#include "backup_page_tracker.h"
#include "mysql/components/library_mysys/my_memory.h"
#include "mysql/components/services/psi_memory.h"
#include "mysql/service_security_context.h"
#include "mysqld_error.h"
#include "string_with_len.h"

Functions

bool have_backup_admin_privilege (void *opaque_thd)
 Method to check if the current user has got backup privilege. More...
 
mysql_service_status_t register_udfs ()
 Register UDF(s) More...
 
mysql_service_status_t unregister_udfs ()
 Unregister UDF(s) More...
 
static bool register_status_variables ()
 Register the server status variables defined by this component. More...
 
static bool unregister_status_variables ()
 Unregister the server status variables defined by this component. More...
 
static int mysqlbackup_backup_id_check (MYSQL_THD thd, SYS_VAR *self, void *save, struct st_mysql_value *value)
 Method to set the system variable "mysqlbackup.backupid". More...
 
static void mysqlbackup_backup_id_update (MYSQL_THD, SYS_VAR *, void *var_ptr, const void *save)
 Update function for mysqlbackup_backup_id. More...
 
static bool register_system_variables ()
 Register the server system variables defined by this component. More...
 
static bool unregister_system_variables ()
 Unregister the server system variables defined by this component. More...
 
static bool initialize_log_service ()
 Initialize logging service. More...
 
static bool deinitialize_log_service ()
 Deinitialize logging service. More...
 
mysql_service_status_t mysqlbackup_init ()
 Initialize the component when loading the component. More...
 
mysql_service_status_t mysqlbackup_deinit ()
 Deinitialize the component when unloading the component. More...
 
 END_COMPONENT_PROVIDES ()
 This component does not provide any services. More...
 
 REQUIRES_SERVICE_PLACEHOLDER (log_builtins)
 A block for specifying dependencies of this Component. More...
 
 REQUIRES_SERVICE_PLACEHOLDER (log_builtins_string)
 
 REQUIRES_SERVICE_PLACEHOLDER (component_sys_variable_register)
 
 REQUIRES_SERVICE_PLACEHOLDER (component_sys_variable_unregister)
 
 REQUIRES_SERVICE_PLACEHOLDER (status_variable_registration)
 
 REQUIRES_SERVICE_PLACEHOLDER (udf_registration)
 
 REQUIRES_SERVICE_PLACEHOLDER (mysql_thd_security_context)
 
 REQUIRES_SERVICE_PLACEHOLDER (mysql_runtime_error)
 
 REQUIRES_SERVICE_PLACEHOLDER (mysql_security_context_options)
 
 REQUIRES_SERVICE_PLACEHOLDER (mysql_page_track)
 
 REQUIRES_SERVICE_PLACEHOLDER (global_grants_check)
 
 REQUIRES_SERVICE_PLACEHOLDER (mysql_current_thread_reader)
 
 REQUIRES_SERVICE_PLACEHOLDER (psi_memory_v2)
 
 REQUIRES_SERVICE (registry)
 A list of dependencies. More...
 
 REQUIRES_SERVICE (log_builtins)
 
 REQUIRES_SERVICE (log_builtins_string)
 
 REQUIRES_SERVICE (component_sys_variable_register)
 
 REQUIRES_SERVICE (component_sys_variable_unregister)
 
 REQUIRES_SERVICE (status_variable_registration)
 
 REQUIRES_SERVICE (udf_registration)
 
 REQUIRES_SERVICE (mysql_thd_security_context)
 
 REQUIRES_SERVICE (mysql_runtime_error)
 
 REQUIRES_SERVICE (mysql_security_context_options)
 
 REQUIRES_SERVICE (mysql_page_track)
 
 REQUIRES_SERVICE (global_grants_check)
 
 REQUIRES_SERVICE (mysql_current_thread_reader)
 
 REQUIRES_SERVICE (psi_memory_v2)
 
 END_COMPONENT_REQUIRES ()
 
 METADATA ("mysql.mysqlbackup", "Oracle Corporation")
 A list of metadata to describe the Component. More...
 
 METADATA ("mysql.license", "Commercial")
 
 END_COMPONENT_METADATA ()
 

Variables

static char * mysqlbackup_component_version {nullptr}
 This file contains a definition of the mysqlbackup component. More...
 
char * mysqlbackup_backup_id = nullptr
 
static std::atomic< bool > mysqlbackup_component_sys_var_registered {false}
 
static SHOW_VAR mysqlbackup_status_variables []
 
const mysql_service_log_builtins_tlog_bi
 Types for the logging service. More...
 
const mysql_service_log_builtins_string_tlog_bs
 string built-ins More...
 
mysql_component_t mysql_component_mysqlbackup
 Declaration of the Component. More...
 

Function Documentation

◆ deinitialize_log_service()

static bool deinitialize_log_service ( )
static

Deinitialize logging service.

Returns
Status
Return values
falsesuccess
truefailure

◆ END_COMPONENT_METADATA()

END_COMPONENT_METADATA ( )

◆ END_COMPONENT_PROVIDES()

END_COMPONENT_PROVIDES ( )

This component does not provide any services.

◆ END_COMPONENT_REQUIRES()

END_COMPONENT_REQUIRES ( )

◆ have_backup_admin_privilege()

bool have_backup_admin_privilege ( void *  opaque_thd)

Method to check if the current user has got backup privilege.

Parameters
[in]opaque_thdCurrent thread context.
Returns
true, if the seurity context of the thread has backup_admin privileges
Return values
falseotherwise

◆ initialize_log_service()

static bool initialize_log_service ( )
static

Initialize logging service.

Returns
Status
Return values
falsesuccess
truefailure

◆ METADATA() [1/2]

METADATA ( "mysql.license"  ,
"Commercial"   
)

◆ METADATA() [2/2]

METADATA ( "mysql.mysqlbackup"  ,
"Oracle Corporation"   
)

A list of metadata to describe the Component.

◆ mysqlbackup_backup_id_check()

static int mysqlbackup_backup_id_check ( MYSQL_THD  thd,
SYS_VAR self,
void *  save,
struct st_mysql_value value 
)
static

Method to set the system variable "mysqlbackup.backupid".

Will check if the user has SUPER or BACKUP_ADMIN privilege.

Returns
Status
Return values
0on success, errorno on failure

◆ mysqlbackup_backup_id_update()

static void mysqlbackup_backup_id_update ( MYSQL_THD  ,
SYS_VAR ,
void *  var_ptr,
const void *  save 
)
static

Update function for mysqlbackup_backup_id.

◆ mysqlbackup_deinit()

mysql_service_status_t mysqlbackup_deinit ( )

Deinitialize the component when unloading the component.

Returns
Status
Return values
0success
non-zerofailure

◆ mysqlbackup_init()

mysql_service_status_t mysqlbackup_init ( )

Initialize the component when loading the component.

Returns
Status
Return values
0success
non-zerofailure

◆ register_status_variables()

static bool register_status_variables ( )
static

Register the server status variables defined by this component.

Returns
Status
Return values
falsesuccess
truefailure

◆ register_system_variables()

static bool register_system_variables ( )
static

Register the server system variables defined by this component.

Returns
Status
Return values
falsesuccess
truefailure

◆ register_udfs()

mysql_service_status_t register_udfs ( )

Register UDF(s)

Registers the plugin's UDFs.

Returns
Status
Return values
0success
non-zerofailure

◆ REQUIRES_SERVICE() [1/14]

REQUIRES_SERVICE ( component_sys_variable_register  )

◆ REQUIRES_SERVICE() [2/14]

REQUIRES_SERVICE ( component_sys_variable_unregister  )

◆ REQUIRES_SERVICE() [3/14]

REQUIRES_SERVICE ( global_grants_check  )

◆ REQUIRES_SERVICE() [4/14]

REQUIRES_SERVICE ( log_builtins  )

◆ REQUIRES_SERVICE() [5/14]

REQUIRES_SERVICE ( log_builtins_string  )

◆ REQUIRES_SERVICE() [6/14]

REQUIRES_SERVICE ( mysql_current_thread_reader  )

◆ REQUIRES_SERVICE() [7/14]

REQUIRES_SERVICE ( mysql_page_track  )

◆ REQUIRES_SERVICE() [8/14]

REQUIRES_SERVICE ( mysql_runtime_error  )

◆ REQUIRES_SERVICE() [9/14]

REQUIRES_SERVICE ( mysql_security_context_options  )

◆ REQUIRES_SERVICE() [10/14]

REQUIRES_SERVICE ( mysql_thd_security_context  )

◆ REQUIRES_SERVICE() [11/14]

REQUIRES_SERVICE ( psi_memory_v2  )

◆ REQUIRES_SERVICE() [12/14]

REQUIRES_SERVICE ( registry  )

A list of dependencies.

The dynamic_loader fetches the references for the below services at the component load time and disposes off them at unload.

◆ REQUIRES_SERVICE() [13/14]

REQUIRES_SERVICE ( status_variable_registration  )

◆ REQUIRES_SERVICE() [14/14]

REQUIRES_SERVICE ( udf_registration  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [1/13]

REQUIRES_SERVICE_PLACEHOLDER ( component_sys_variable_register  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [2/13]

REQUIRES_SERVICE_PLACEHOLDER ( component_sys_variable_unregister  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [3/13]

REQUIRES_SERVICE_PLACEHOLDER ( global_grants_check  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [4/13]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins  )

A block for specifying dependencies of this Component.

Note that for each dependency we need to have a placeholder, a extern to placeholder in header file of the Component, and an entry on requires list below.

◆ REQUIRES_SERVICE_PLACEHOLDER() [5/13]

REQUIRES_SERVICE_PLACEHOLDER ( log_builtins_string  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [6/13]

REQUIRES_SERVICE_PLACEHOLDER ( mysql_current_thread_reader  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [7/13]

REQUIRES_SERVICE_PLACEHOLDER ( mysql_page_track  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [8/13]

REQUIRES_SERVICE_PLACEHOLDER ( mysql_runtime_error  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [9/13]

REQUIRES_SERVICE_PLACEHOLDER ( mysql_security_context_options  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [10/13]

REQUIRES_SERVICE_PLACEHOLDER ( mysql_thd_security_context  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [11/13]

REQUIRES_SERVICE_PLACEHOLDER ( psi_memory_v2  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [12/13]

REQUIRES_SERVICE_PLACEHOLDER ( status_variable_registration  )

◆ REQUIRES_SERVICE_PLACEHOLDER() [13/13]

REQUIRES_SERVICE_PLACEHOLDER ( udf_registration  )

◆ unregister_status_variables()

static bool unregister_status_variables ( )
static

Unregister the server status variables defined by this component.

Returns
Status
Return values
falsesuccess
truefailure

◆ unregister_system_variables()

static bool unregister_system_variables ( )
static

Unregister the server system variables defined by this component.

Returns
Status
Return values
falsesuccess
truefailure

◆ unregister_udfs()

mysql_service_status_t unregister_udfs ( )

Unregister UDF(s)

Unregisters the plugin's UDFs.

Returns
Status
Return values
0success
non-zerofailure

Variable Documentation

◆ log_bi

Types for the logging service.

accessor built-ins

◆ log_bs

string built-ins

◆ mysql_component_mysqlbackup

mysql_component_t mysql_component_mysqlbackup
Initial value:
= { "mysql:mysqlbackup" , __mysqlbackup_provides, __mysqlbackup_requires, __mysqlbackup_metadata,
mysql_service_status_t mysqlbackup_deinit()
Deinitialize the component when unloading the component.
Definition: mysqlbackup.cc:359
mysql_service_status_t mysqlbackup_init()
Initialize the component when loading the component.
Definition: mysqlbackup.cc:323

Declaration of the Component.

◆ mysqlbackup_backup_id

char* mysqlbackup_backup_id = nullptr

◆ mysqlbackup_component_sys_var_registered

std::atomic<bool> mysqlbackup_component_sys_var_registered {false}
static

◆ mysqlbackup_component_version

char* mysqlbackup_component_version {nullptr}
static

This file contains a definition of the mysqlbackup component.

◆ mysqlbackup_status_variables

SHOW_VAR mysqlbackup_status_variables[]
static
Initial value:
= {
{nullptr, nullptr, SHOW_LONG, SHOW_SCOPE_GLOBAL}}
static char * mysqlbackup_component_version
This file contains a definition of the mysqlbackup component.
Definition: mysqlbackup.cc:38
constexpr const char * backup_component_version
Definition: backup_comp_constants.h:32
@ SHOW_LONG
shown as unsigned long
Definition: status_var.h:33
@ SHOW_CHAR_PTR
Definition: status_var.h:36
@ SHOW_SCOPE_GLOBAL
Definition: status_var.h:69