MySQL  8.0.16
Source Code Documentation
mysqldump.cc File Reference
#include "my_config.h"
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string>
#include "client/client_priv.h"
#include "m_ctype.h"
#include "m_string.h"
#include "map_helpers.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_default.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_macros.h"
#include "my_sys.h"
#include "my_systime.h"
#include "my_user.h"
#include "mysql.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql_version.h"
#include "mysqld_error.h"
#include "prealloced_array.h"
#include "print_version.h"
#include "template_utils.h"
#include "typelib.h"
#include "welcome_copyright_notice.h"
#include "caching_sha2_passwordopt-vars.h"
#include "sslopt-vars.h"
#include "caching_sha2_passwordopt-longopts.h"
#include "sslopt-longopts.h"
#include "sslopt-case.h"

Macros

#define DUMP_VERSION   "10.13"
 
#define EX_USAGE   1
 
#define EX_MYSQLERR   2
 
#define EX_CONSCHECK   3
 
#define EX_EOM   4
 
#define EX_EOF   5 /* ferror for output file was got */
 
#define EX_ILLEGAL_TABLE   6
 
#define SHOW_FIELDNAME   0
 
#define SHOW_TYPE   1
 
#define SHOW_NULL   2
 
#define SHOW_DEFAULT   4
 
#define SHOW_EXTRA   5
 
#define QUERY_LENGTH   1536
 
#define COMMENT_LENGTH   2048
 
#define IGNORE_NONE   0x00 /* no ignore */
 
#define IGNORE_DATA   0x01 /* don't dump data for this table */
 
#define MYSQL_UNIVERSAL_CLIENT_CHARSET   "utf8mb4"
 
#define MAX_FIELDS   4000
 
#define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL   1
 
#define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL   2
 
#define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL   1
 
#define MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL   2
 
#define DYNAMIC_STR_ERROR_MSG   "Couldn't perform DYNAMIC_STRING operation"
 

Enumerations

enum  enum_set_gtid_purged_mode { SET_GTID_PURGED_OFF = 0, SET_GTID_PURGED_AUTO = 1, SET_GTID_PURGED_ON = 2 }
 

Functions

static void add_load_option (DYNAMIC_STRING *str, const char *option, const char *option_value)
 
static char * alloc_query_str (size_t size)
 
static void field_escape (DYNAMIC_STRING *in, const char *from)
 
static int parse_ignore_error ()
 Parse the list of error numbers to be ignored and store into a dynamic array. More...
 
static void init_dynamic_string_checked (DYNAMIC_STRING *str, const char *init_str, size_t init_alloc, size_t alloc_increment)
 
static void dynstr_append_checked (DYNAMIC_STRING *dest, const char *src)
 
static void dynstr_set_checked (DYNAMIC_STRING *str, const char *init_str)
 
static void dynstr_append_mem_checked (DYNAMIC_STRING *str, const char *append, size_t length)
 
static void dynstr_realloc_checked (DYNAMIC_STRING *str, size_t additional_size)
 
static void maybe_exit (int error)
 
static void die (int error, const char *reason,...)
 
static void maybe_die (int error, const char *reason,...)
 
static void write_header (FILE *sql_file, char *db_name)
 
static void print_value (FILE *file, MYSQL_RES *result, MYSQL_ROW row, const char *prefix, const char *name, int string_value)
 
static int dump_selected_tables (char *db, char **table_names, int tables)
 
static int dump_all_tables_in_db (char *db)
 
static int init_dumping_views (char *)
 
static int init_dumping_tables (char *)
 
static int init_dumping (char *, int init_func(char *))
 
static int dump_databases (char **)
 
static int dump_all_databases ()
 
static char * quote_name (const char *name, char *buff, bool force)
 
char check_if_ignore_table (const char *table_name, char *table_type)
 
bool is_infoschema_db (const char *db)
 Check if the database is 'information_schema' and write a verbose message stating that dumping the database is not supported. More...
 
static char * primary_key_fields (const char *table_name)
 
static bool get_view_structure (char *table, char *db)
 
static bool dump_all_views_in_db (char *database)
 
static int dump_all_tablespaces ()
 
static int dump_tablespaces_for_tables (char *db, char **table_names, int tables)
 
static int dump_tablespaces_for_databases (char **databases)
 
static int dump_tablespaces (char *ts_where)
 
static void print_comment (FILE *sql_file, bool is_error, const char *format,...)
 
static void verbose_msg (const char *fmt,...)
 
static char const * fix_identifier_with_newline (char const *object_name, bool *freemem)
 Accepts object names and prefixes them with "-- " wherever end-of-line character ('
') is found. More...
 
static void check_io (FILE *file)
 
static void short_usage_sub (void)
 
static void usage (void)
 
static void short_usage (void)
 
static void write_footer (FILE *sql_file)
 
static int get_options (int *argc, char ***argv)
 
static void DB_error (MYSQL *mysql_arg, const char *when)
 
static int mysql_query_with_error_report (MYSQL *mysql_con, MYSQL_RES **res, const char *query)
 
static int fetch_db_collation (const char *db_name, char *db_cl_name, int db_cl_size)
 
static char * my_case_str (const char *str, size_t str_len, const char *token, size_t token_len)
 
static int switch_db_collation (FILE *sql_file, const char *db_name, const char *delimiter, const char *current_db_cl_name, const char *required_db_cl_name, int *db_cl_altered)
 
static int restore_db_collation (FILE *sql_file, const char *db_name, const char *delimiter, const char *db_cl_name)
 
static void switch_cs_variables (FILE *sql_file, const char *delimiter, const char *character_set_client, const char *character_set_results, const char *collation_connection)
 
static void restore_cs_variables (FILE *sql_file, const char *delimiter)
 
static void switch_sql_mode (FILE *sql_file, const char *delimiter, const char *sql_mode)
 
static void restore_sql_mode (FILE *sql_file, const char *delimiter)
 
static void switch_time_zone (FILE *sql_file, const char *delimiter, const char *time_zone)
 
static void restore_time_zone (FILE *sql_file, const char *delimiter)
 
static int switch_character_set_results (MYSQL *mysql, const char *cs_name)
 Switch charset for results to some specified charset. More...
 
static char * cover_definer_clause (const char *stmt_str, size_t stmt_length, const char *definer_version_str, size_t definer_version_length, const char *stmt_version_str, size_t stmt_version_length, const char *keyword_str, size_t keyword_length)
 Rewrite statement, enclosing DEFINER clause in version-specific comment. More...
 
static FILE * open_sql_file_for_table (const char *table, int flags)
 
static void free_resources ()
 
static bool do_ignore_error ()
 Check if the last error should be ignored. More...
 
static int connect_to_db (char *host, char *user, char *passwd)
 
static void dbDisconnect (char *host)
 
static void unescape (FILE *file, char *pos, size_t length)
 
static bool test_if_special_chars (const char *str)
 
static char * quote_for_like (const char *name, char *buff)
 
static void print_quoted_xml (FILE *xml_file, const char *str, size_t len, bool is_attribute_name)
 Quote and print a string. More...
 
static void print_xml_tag (FILE *xml_file, const char *sbeg, const char *line_end, const char *tag_name, const char *first_attribute_name,...)
 
static void print_xml_null_tag (FILE *xml_file, const char *sbeg, const char *stag_atr, const char *sval, const char *line_end)
 
static void print_xml_cdata (FILE *xml_file, const char *str, ulong len)
 Print xml CDATA section. More...
 
static void print_xml_row (FILE *xml_file, const char *row_name, MYSQL_RES *tableRes, MYSQL_ROW *row, const char *str_create)
 
static void print_xml_comment (FILE *xml_file, size_t len, const char *comment_string)
 Print xml comments. More...
 
static char * create_delimiter (char *query, char *delimiter_buff, int delimiter_max_size)
 
static uint dump_events_for_db (char *db)
 
static void print_blob_as_hex (FILE *output_file, const char *str, ulong len)
 
static uint dump_routines_for_db (char *db)
 
static bool general_log_or_slow_log_tables (const char *db, const char *table)
 
static bool replication_metadata_tables (const char *db, const char *table)
 
static bool innodb_stats_tables (const char *db, const char *table)
 Check if the table is innodb stats table in mysql database. More...
 
static bool is_innodb_stats_tables_included (int argc, char **argv)
 Check if the command line option includes innodb stats table or in any way mysql database. More...
 
static uint get_table_structure (char *table, char *db, char *table_type, char *ignore_flag, bool real_columns[])
 
static void dump_trigger_old (FILE *sql_file, MYSQL_RES *show_triggers_rs, MYSQL_ROW *show_trigger_row, const char *table_name)
 
static int dump_trigger (FILE *sql_file, MYSQL_RES *show_create_trigger_rs, const char *db_name, const char *db_cl_name)
 
static int dump_triggers_for_table (char *table_name, char *db_name)
 Dump the triggers for a given table. More...
 
static bool dump_column_statistics_for_table (char *table_name, char *db_name)
 
static void dump_table (char *table, char *db)
 
static char * getTableName (int reset)
 
static int is_ndbinfo (MYSQL *mysql, const char *dbname)
 
static bool include_table (const char *hash_key, size_t len)
 
static char * get_actual_table_name (const char *old_table_name, MEM_ROOT *root)
 
static int do_show_master_status (MYSQL *mysql_con)
 
static int do_stop_slave_sql (MYSQL *mysql_con)
 
static int add_stop_slave (void)
 
static int add_slave_statements (void)
 
static int do_show_slave_status (MYSQL *mysql_con)
 
static int do_start_slave_sql (MYSQL *mysql_con)
 
static int do_flush_tables_read_lock (MYSQL *mysql_con)
 
static int do_unlock_tables (MYSQL *mysql_con)
 
static int get_bin_log_name (MYSQL *mysql_con, char *buff_log_name, uint buff_len)
 
static int purge_bin_logs_to (MYSQL *mysql_con, char *log_name)
 
static int start_transaction (MYSQL *mysql_con)
 
static int replace (DYNAMIC_STRING *ds_str, const char *search_str, size_t search_len, const char *replace_str, size_t replace_len)
 
static void set_session_binlog (bool flag)
 This function sets the session binlog in the dump file. More...
 
static bool add_set_gtid_purged (MYSQL *mysql_con)
 This function gets the GTID_EXECUTED sets from the server and assigns those sets to GTID_PURGED in the dump file. More...
 
static bool process_set_gtid_purged (MYSQL *mysql_con)
 This function processes the opt_set_gtid_purged option. More...
 
int main (int argc, char **argv)
 

Variables

static bool verbose = 0
 
static bool opt_no_create_info = 0
 
static bool opt_no_data = 0
 
static bool quick = 1
 
static bool extended_insert = 1
 
static bool lock_tables = 1
 
static bool opt_force = 0
 
static bool flush_logs = 0
 
static bool flush_privileges = 0
 
static bool opt_drop = 1
 
static bool opt_keywords = 0
 
static bool opt_lock = 1
 
static bool opt_compress = 0
 
static bool create_options = 1
 
static bool opt_quoted = 0
 
static bool opt_databases = 0
 
static bool opt_alldbs = 0
 
static bool opt_create_db = 0
 
static bool opt_lock_all_tables = 0
 
static bool opt_set_charset = 0
 
static bool opt_dump_date = 1
 
static bool opt_autocommit = 0
 
static bool opt_disable_keys = 1
 
static bool opt_xml = 0
 
static bool opt_delete_master_logs = 0
 
static bool tty_password = 0
 
static bool opt_single_transaction = 0
 
static bool opt_comments = 0
 
static bool opt_compact = 0
 
static bool opt_hex_blob = 0
 
static bool opt_order_by_primary = 0
 
static bool opt_ignore = 0
 
static bool opt_complete_insert = 0
 
static bool opt_drop_database = 0
 
static bool opt_replace_into = 0
 
static bool opt_dump_triggers = 0
 
static bool opt_routines = 0
 
static bool opt_tz_utc = 1
 
static bool opt_slave_apply = 0
 
static bool opt_include_master_host_port = 0
 
static bool opt_events = 0
 
static bool opt_comments_used = 0
 
static bool opt_alltspcs = 0
 
static bool opt_notspcs = 0
 
static bool opt_drop_trigger = 0
 
static bool opt_network_timeout = 0
 
static bool stats_tables_included = 0
 
static bool column_statistics = false
 
static bool insert_pat_inited = 0
 
static bool debug_info_flag = 0
 
static bool debug_check_flag = 0
 
static ulong opt_max_allowed_packet
 
static ulong opt_net_buffer_length
 
static MYSQL mysql_connection
 
static MYSQLmysql = 0
 
static DYNAMIC_STRING insert_pat
 
static char * opt_password = 0
 
static char * current_user = 0
 
static char * current_host = 0
 
static char * path = 0
 
static char * fields_terminated = 0
 
static char * lines_terminated = 0
 
static char * enclosed = 0
 
static char * opt_enclosed = 0
 
static char * escaped = 0
 
static char * where = 0
 
static char * order_by = 0
 
static char * opt_compatible_mode_str = 0
 
static char * opt_ignore_error = 0
 
static char * log_error_file = NULL
 
static MEM_ROOT argv_alloc {PSI_NOT_INSTRUMENTED, 512}
 
static bool ansi_mode = false
 Force the "ANSI" SQL_MODE. More...
 
static bool server_supports_switching_charsets = true
 
static bool ansi_quotes_mode = false
 Use double quotes ("") like in the standard to quote identifiers if true, otherwise backticks (``, non-standard MySQL feature). More...
 
static uint opt_enable_cleartext_plugin = 0
 
static bool using_opt_enable_cleartext_plugin = 0
 
static uint opt_mysql_port = 0
 
static uint opt_master_data
 
static uint opt_slave_data
 
static uint my_end_arg
 
static char * opt_mysql_unix_port = 0
 
static char * opt_bind_addr = NULL
 
static int first_error = 0
 
FILE * md_result_file = 0
 
FILE * stderror_file = 0
 
const char * set_gtid_purged_mode_names [] = {"OFF", "AUTO", "ON", NullS}
 
static TYPELIB set_gtid_purged_mode_typelib
 
static enum enum_set_gtid_purged_mode opt_set_gtid_purged_mode = SET_GTID_PURGED_AUTO
 
static uint opt_protocol = 0
 
static char * opt_plugin_dir = 0
 
static char * opt_default_auth = 0
 
Prealloced_array< uint, 12 > ignore_error (PSI_NOT_INSTRUMENTED)
 
static const char * mysql_universal_client_charset
 
static char * default_charset
 
static CHARSET_INFOcharset_info = &my_charset_latin1
 
const char * default_dbug_option = "d:t:o,/tmp/mysqldump.trace"
 
bool seen_views = 0
 
collation_unordered_set< string > * ignore_table
 
static struct my_option my_long_options []
 
static const char * load_default_groups [] = {"mysqldump", "client", 0}
 

Macro Definition Documentation

◆ COMMENT_LENGTH

#define COMMENT_LENGTH   2048

◆ DUMP_VERSION

#define DUMP_VERSION   "10.13"

◆ DYNAMIC_STR_ERROR_MSG

#define DYNAMIC_STR_ERROR_MSG   "Couldn't perform DYNAMIC_STRING operation"

◆ EX_CONSCHECK

#define EX_CONSCHECK   3

◆ EX_EOF

#define EX_EOF   5 /* ferror for output file was got */

◆ EX_EOM

#define EX_EOM   4

◆ EX_ILLEGAL_TABLE

#define EX_ILLEGAL_TABLE   6

◆ EX_MYSQLERR

#define EX_MYSQLERR   2

◆ EX_USAGE

#define EX_USAGE   1

◆ IGNORE_DATA

#define IGNORE_DATA   0x01 /* don't dump data for this table */

◆ IGNORE_NONE

#define IGNORE_NONE   0x00 /* no ignore */

◆ MAX_FIELDS

#define MAX_FIELDS   4000

◆ MYSQL_OPT_MASTER_DATA_COMMENTED_SQL

#define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL   2

◆ MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL

#define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL   1

◆ MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL

#define MYSQL_OPT_SLAVE_DATA_COMMENTED_SQL   2

◆ MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL

#define MYSQL_OPT_SLAVE_DATA_EFFECTIVE_SQL   1

◆ MYSQL_UNIVERSAL_CLIENT_CHARSET

#define MYSQL_UNIVERSAL_CLIENT_CHARSET   "utf8mb4"

◆ QUERY_LENGTH

#define QUERY_LENGTH   1536

◆ SHOW_DEFAULT

#define SHOW_DEFAULT   4

◆ SHOW_EXTRA

#define SHOW_EXTRA   5

◆ SHOW_FIELDNAME

#define SHOW_FIELDNAME   0

◆ SHOW_NULL

#define SHOW_NULL   2

◆ SHOW_TYPE

#define SHOW_TYPE   1

Enumeration Type Documentation

◆ enum_set_gtid_purged_mode

Enumerator
SET_GTID_PURGED_OFF 
SET_GTID_PURGED_AUTO 
SET_GTID_PURGED_ON 

Function Documentation

◆ add_load_option()

static void add_load_option ( DYNAMIC_STRING str,
const char *  option,
const char *  option_value 
)
static

◆ add_set_gtid_purged()

static bool add_set_gtid_purged ( MYSQL mysql_con)
static

This function gets the GTID_EXECUTED sets from the server and assigns those sets to GTID_PURGED in the dump file.

Parameters
[in]mysql_conconnection to the server
Return values
falsesuccesfully printed GTID_PURGED sets in the dump file.
truefailed.

◆ add_slave_statements()

static int add_slave_statements ( void  )
static

◆ add_stop_slave()

static int add_stop_slave ( void  )
static

◆ alloc_query_str()

static char * alloc_query_str ( size_t  size)
static

◆ check_if_ignore_table()

char check_if_ignore_table ( const char *  table_name,
char *  table_type 
)

◆ check_io()

static void check_io ( FILE *  file)
static

◆ connect_to_db()

static int connect_to_db ( char *  host,
char *  user,
char *  passwd 
)
static

◆ cover_definer_clause()

static char* cover_definer_clause ( const char *  stmt_str,
size_t  stmt_length,
const char *  definer_version_str,
size_t  definer_version_length,
const char *  stmt_version_str,
size_t  stmt_version_length,
const char *  keyword_str,
size_t  keyword_length 
)
static

Rewrite statement, enclosing DEFINER clause in version-specific comment.

This function parses any CREATE statement and encloses DEFINER-clause in version-specific comment: input query: CREATE DEFINER=aFUNCTION ... rewritten query: CREATE * / / *!50020 DEFINER=a* / / *!50003 FUNCTION ...

Note
This function will go away when WL#3995 is implemented.
Parameters
[in]stmt_strCREATE statement string.
[in]stmt_lengthLength of the stmt_str.
[in]definer_version_strMinimal MySQL version number when DEFINER clause is supported in the given statement.
[in]definer_version_lengthLength of definer_version_str.
[in]stmt_version_strMinimal MySQL version number when the given statement is supported.
[in]stmt_version_lengthLength of stmt_version_str.
[in]keyword_strKeyword to look for after CREATE.
[in]keyword_lengthLength of keyword_str.
Returns
pointer to the new allocated query string.

◆ create_delimiter()

static char* create_delimiter ( char *  query,
char *  delimiter_buff,
int  delimiter_max_size 
)
static

◆ DB_error()

static void DB_error ( MYSQL mysql_arg,
const char *  when 
)
static

◆ dbDisconnect()

static void dbDisconnect ( char *  host)
static

◆ die()

static void die ( int  error,
const char *  reason,
  ... 
)
static

◆ do_flush_tables_read_lock()

static int do_flush_tables_read_lock ( MYSQL mysql_con)
static

◆ do_ignore_error()

static bool do_ignore_error ( )
static

Check if the last error should be ignored.

Return values
1yes 0 no

◆ do_show_master_status()

static int do_show_master_status ( MYSQL mysql_con)
static

◆ do_show_slave_status()

static int do_show_slave_status ( MYSQL mysql_con)
static

◆ do_start_slave_sql()

static int do_start_slave_sql ( MYSQL mysql_con)
static

◆ do_stop_slave_sql()

static int do_stop_slave_sql ( MYSQL mysql_con)
static

◆ do_unlock_tables()

static int do_unlock_tables ( MYSQL mysql_con)
static

◆ dump_all_databases()

static int dump_all_databases ( )
static

◆ dump_all_tables_in_db()

static int dump_all_tables_in_db ( char *  db)
static

ROLLBACK TO SAVEPOINT in –single-transaction mode to release metadata lock on table which was already dumped. This allows to avoid blocking concurrent DDL on this table without sacrificing correctness, as we won't access table second time and dumps created by –single-transaction mode have validity point at the start of transaction anyway. Note that this doesn't make –single-transaction mode with concurrent DDL safe in general case. It just improves situation for people for whom it might be working.

◆ dump_all_tablespaces()

static int dump_all_tablespaces ( )
static

◆ dump_all_views_in_db()

static bool dump_all_views_in_db ( char *  database)
static

◆ dump_column_statistics_for_table()

static bool dump_column_statistics_for_table ( char *  table_name,
char *  db_name 
)
static

◆ dump_databases()

static int dump_databases ( char **  db_names)
static

◆ dump_events_for_db()

static uint dump_events_for_db ( char *  db)
static

◆ dump_routines_for_db()

static uint dump_routines_for_db ( char *  db)
static

◆ dump_selected_tables()

static int dump_selected_tables ( char *  db,
char **  table_names,
int  tables 
)
static

ROLLBACK TO SAVEPOINT in –single-transaction mode to release metadata lock on table which was already dumped. This allows to avoid blocking concurrent DDL on this table without sacrificing correctness, as we won't access table second time and dumps created by –single-transaction mode have validity point at the start of transaction anyway. Note that this doesn't make –single-transaction mode with concurrent DDL safe in general case. It just improves situation for people for whom it might be working.

◆ dump_table()

static void dump_table ( char *  table,
char *  db 
)
static

◆ dump_tablespaces()

static int dump_tablespaces ( char *  ts_where)
static

◆ dump_tablespaces_for_databases()

static int dump_tablespaces_for_databases ( char **  databases)
static

◆ dump_tablespaces_for_tables()

static int dump_tablespaces_for_tables ( char *  db,
char **  table_names,
int  tables 
)
static

◆ dump_trigger()

static int dump_trigger ( FILE *  sql_file,
MYSQL_RES show_create_trigger_rs,
const char *  db_name,
const char *  db_cl_name 
)
static

◆ dump_trigger_old()

static void dump_trigger_old ( FILE *  sql_file,
MYSQL_RES show_triggers_rs,
MYSQL_ROW show_trigger_row,
const char *  table_name 
)
static

◆ dump_triggers_for_table()

static int dump_triggers_for_table ( char *  table_name,
char *  db_name 
)
static

Dump the triggers for a given table.

This should be called after the tables have been dumped in case a trigger depends on the existence of a table.

Parameters
[in]table_name
[in]db_name
Returns
Error status.
Return values
trueerror has occurred.
falseoperation succeed.

◆ dynstr_append_checked()

static void dynstr_append_checked ( DYNAMIC_STRING dest,
const char *  src 
)
static

◆ dynstr_append_mem_checked()

static void dynstr_append_mem_checked ( DYNAMIC_STRING str,
const char *  append,
size_t  length 
)
static

◆ dynstr_realloc_checked()

static void dynstr_realloc_checked ( DYNAMIC_STRING str,
size_t  additional_size 
)
static

◆ dynstr_set_checked()

static void dynstr_set_checked ( DYNAMIC_STRING str,
const char *  init_str 
)
static

◆ fetch_db_collation()

static int fetch_db_collation ( const char *  db_name,
char *  db_cl_name,
int  db_cl_size 
)
static

◆ field_escape()

static void field_escape ( DYNAMIC_STRING in,
const char *  from 
)
static

◆ fix_identifier_with_newline()

static char const * fix_identifier_with_newline ( char const *  object_name,
bool freemem 
)
static

Accepts object names and prefixes them with "-- " wherever end-of-line character ('
') is found.

Parameters
[in]object_nameobject name list (concatenated string)
[out]freememshould buffer be released after usage
Returns
Return values
pointerto a string with prefixed objects

◆ free_resources()

static void free_resources ( )
static

◆ general_log_or_slow_log_tables()

static bool general_log_or_slow_log_tables ( const char *  db,
const char *  table 
)
inlinestatic

◆ get_actual_table_name()

static char* get_actual_table_name ( const char *  old_table_name,
MEM_ROOT root 
)
static

◆ get_bin_log_name()

static int get_bin_log_name ( MYSQL mysql_con,
char *  buff_log_name,
uint  buff_len 
)
static

◆ get_options()

static int get_options ( int *  argc,
char ***  argv 
)
static

◆ get_table_structure()

static uint get_table_structure ( char *  table,
char *  db,
char *  table_type,
char *  ignore_flag,
bool  real_columns[] 
)
static

◆ get_view_structure()

static bool get_view_structure ( char *  table,
char *  db 
)
static

◆ getTableName()

static char* getTableName ( int  reset)
static

◆ include_table()

static bool include_table ( const char *  hash_key,
size_t  len 
)
static

◆ init_dumping()

static int init_dumping ( char *  database,
int   init_funcchar * 
)
static

◆ init_dumping_tables()

int init_dumping_tables ( char *  qdatabase)
static

◆ init_dumping_views()

int init_dumping_views ( char *  qdatabase)
static

◆ init_dynamic_string_checked()

static void init_dynamic_string_checked ( DYNAMIC_STRING str,
const char *  init_str,
size_t  init_alloc,
size_t  alloc_increment 
)
static

◆ innodb_stats_tables()

static bool innodb_stats_tables ( const char *  db,
const char *  table 
)
inlinestatic

Check if the table is innodb stats table in mysql database.

Parameters
[in]dbDatabase name
[in]tableTable name
Returns
Return values
trueif it is innodb stats table else false

◆ is_infoschema_db()

bool is_infoschema_db ( const char *  db)

Check if the database is 'information_schema' and write a verbose message stating that dumping the database is not supported.

Parameters
dbDatabase Name.
Return values
trueIf database should be ignored.
falseIf database shouldn't be ignored.

◆ is_innodb_stats_tables_included()

static bool is_innodb_stats_tables_included ( int  argc,
char **  argv 
)
inlinestatic

Check if the command line option includes innodb stats table or in any way mysql database.

Parameters
[in]argcTotal count of positional arguments
[in]argvPointer to positional arguments
Returns
Return values
trueif dump contains innodb stats table or else false

◆ is_ndbinfo()

static int is_ndbinfo ( MYSQL mysql,
const char *  dbname 
)
static

◆ main()

int main ( int  argc,
char **  argv 
)

◆ maybe_die()

static void maybe_die ( int  error,
const char *  reason,
  ... 
)
static

◆ maybe_exit()

static void maybe_exit ( int  error)
static

◆ my_case_str()

static char* my_case_str ( const char *  str,
size_t  str_len,
const char *  token,
size_t  token_len 
)
static

◆ mysql_query_with_error_report()

static int mysql_query_with_error_report ( MYSQL mysql_con,
MYSQL_RES **  res,
const char *  query 
)
static

◆ open_sql_file_for_table()

static FILE* open_sql_file_for_table ( const char *  table,
int  flags 
)
static

◆ parse_ignore_error()

static int parse_ignore_error ( )
static

Parse the list of error numbers to be ignored and store into a dynamic array.

Returns
Operation status
Return values
0Success
>0Failure

◆ primary_key_fields()

static char * primary_key_fields ( const char *  table_name)
static

◆ print_blob_as_hex()

static void print_blob_as_hex ( FILE *  output_file,
const char *  str,
ulong  len 
)
static

◆ print_comment()

static void print_comment ( FILE *  sql_file,
bool  is_error,
const char *  format,
  ... 
)
static

◆ print_quoted_xml()

static void print_quoted_xml ( FILE *  xml_file,
const char *  str,
size_t  len,
bool  is_attribute_name 
)
static

Quote and print a string.

Quote '<' '>' '&' '"' chars and print a string to the xml_file.

Parameters
xml_fileOutput file.
strString to print.
lenIts length.
is_attribute_nameA check for attribute name or value.

◆ print_value()

static void print_value ( FILE *  file,
MYSQL_RES result,
MYSQL_ROW  row,
const char *  prefix,
const char *  name,
int  string_value 
)
static

◆ print_xml_cdata()

static void print_xml_cdata ( FILE *  xml_file,
const char *  str,
ulong  len 
)
static

Print xml CDATA section.

Parameters
xml_file- output file
str- string to print
len- length of the string
Note
This function also takes care of the presence of '[[>' string in the str. If found, the CDATA section is broken into two CDATA sections, <![CDATA[]]]]> and <![CDATA[>]].

◆ print_xml_comment()

static void print_xml_comment ( FILE *  xml_file,
size_t  len,
const char *  comment_string 
)
static

Print xml comments.

Print the comment message in the format: "<!-- \n comment string \n -->\n"

Parameters
xml_fileoutput file
lenlength of comment message
comment_stringcomment message
Note
Any occurrence of continuous hyphens will be squeezed to a single hyphen.

◆ print_xml_null_tag()

static void print_xml_null_tag ( FILE *  xml_file,
const char *  sbeg,
const char *  stag_atr,
const char *  sval,
const char *  line_end 
)
static

◆ print_xml_row()

static void print_xml_row ( FILE *  xml_file,
const char *  row_name,
MYSQL_RES tableRes,
MYSQL_ROW row,
const char *  str_create 
)
static

◆ print_xml_tag()

static void print_xml_tag ( FILE *  xml_file,
const char *  sbeg,
const char *  line_end,
const char *  tag_name,
const char *  first_attribute_name,
  ... 
)
static

◆ process_set_gtid_purged()

static bool process_set_gtid_purged ( MYSQL mysql_con)
static

This function processes the opt_set_gtid_purged option.

This function also calls set_session_binlog() function before setting the SET @GLOBAL.GTID_PURGED in the output.

Parameters
[in]mysql_conthe connection to the server
Return values
falsesuccessful according to the value of opt_set_gtid_purged.
truefail.

◆ purge_bin_logs_to()

static int purge_bin_logs_to ( MYSQL mysql_con,
char *  log_name 
)
static

◆ quote_for_like()

static char* quote_for_like ( const char *  name,
char *  buff 
)
static

◆ quote_name()

static char * quote_name ( const char *  name,
char *  buff,
bool  force 
)
static

◆ replace()

static int replace ( DYNAMIC_STRING ds_str,
const char *  search_str,
size_t  search_len,
const char *  replace_str,
size_t  replace_len 
)
static

◆ replication_metadata_tables()

static bool replication_metadata_tables ( const char *  db,
const char *  table 
)
inlinestatic

◆ restore_cs_variables()

static void restore_cs_variables ( FILE *  sql_file,
const char *  delimiter 
)
static

◆ restore_db_collation()

static int restore_db_collation ( FILE *  sql_file,
const char *  db_name,
const char *  delimiter,
const char *  db_cl_name 
)
static

◆ restore_sql_mode()

static void restore_sql_mode ( FILE *  sql_file,
const char *  delimiter 
)
static

◆ restore_time_zone()

static void restore_time_zone ( FILE *  sql_file,
const char *  delimiter 
)
static

◆ set_session_binlog()

static void set_session_binlog ( bool  flag)
static

This function sets the session binlog in the dump file.

When –set-gtid-purged is used, this function is called to disable the session binlog and at the end of the dump, to restore the session binlog.

Note
: md_result_file should have been opened, before this function is called.
Parameters
[in]flagIf false, disable binlog. If true and binlog disabled previously, restore the session binlog.

◆ short_usage()

static void short_usage ( void  )
static

◆ short_usage_sub()

static void short_usage_sub ( void  )
static

◆ start_transaction()

static int start_transaction ( MYSQL mysql_con)
static

◆ switch_character_set_results()

static int switch_character_set_results ( MYSQL mysql,
const char *  cs_name 
)
static

Switch charset for results to some specified charset.

If the server does not support character_set_results variable, nothing can be done here. As for whether something should be done here, future new callers of this function should be aware that the server lacking the facility of switching charsets is treated as success.

Note
If the server lacks support, then nothing is changed and no error condition is returned.
Returns
whether there was an error or not

◆ switch_cs_variables()

static void switch_cs_variables ( FILE *  sql_file,
const char *  delimiter,
const char *  character_set_client,
const char *  character_set_results,
const char *  collation_connection 
)
static

◆ switch_db_collation()

static int switch_db_collation ( FILE *  sql_file,
const char *  db_name,
const char *  delimiter,
const char *  current_db_cl_name,
const char *  required_db_cl_name,
int *  db_cl_altered 
)
static

◆ switch_sql_mode()

static void switch_sql_mode ( FILE *  sql_file,
const char *  delimiter,
const char *  sql_mode 
)
static

◆ switch_time_zone()

static void switch_time_zone ( FILE *  sql_file,
const char *  delimiter,
const char *  time_zone 
)
static

◆ test_if_special_chars()

static bool test_if_special_chars ( const char *  str)
static

◆ unescape()

static void unescape ( FILE *  file,
char *  pos,
size_t  length 
)
static

◆ usage()

static void usage ( void  )
static

◆ verbose_msg()

static void verbose_msg ( const char *  fmt,
  ... 
)
static

◆ write_footer()

static void write_footer ( FILE *  sql_file)
static

◆ write_header()

static void write_header ( FILE *  sql_file,
char *  db_name 
)
static

Variable Documentation

◆ ansi_mode

bool ansi_mode = false
static

Force the "ANSI" SQL_MODE.

◆ ansi_quotes_mode

bool ansi_quotes_mode = false
static

Use double quotes ("") like in the standard to quote identifiers if true, otherwise backticks (``, non-standard MySQL feature).

◆ argv_alloc

MEM_ROOT argv_alloc {PSI_NOT_INSTRUMENTED, 512}
static

◆ charset_info

CHARSET_INFO* charset_info = &my_charset_latin1
static

◆ column_statistics

bool column_statistics = false
static

◆ create_options

bool create_options = 1
static

◆ current_host

char * current_host = 0
static

◆ current_user

char * current_user = 0
static

◆ debug_check_flag

bool debug_check_flag = 0
static

◆ debug_info_flag

bool debug_info_flag = 0
static

◆ default_charset

char* default_charset
static

◆ default_dbug_option

const char* default_dbug_option = "d:t:o,/tmp/mysqldump.trace"

◆ enclosed

char * enclosed = 0
static

◆ escaped

char * escaped = 0
static

◆ extended_insert

bool extended_insert = 1
static

◆ fields_terminated

char * fields_terminated = 0
static

◆ first_error

int first_error = 0
static

◆ flush_logs

bool flush_logs = 0
static

◆ flush_privileges

bool flush_privileges = 0
static

◆ ignore_error

◆ ignore_table

collation_unordered_set<string>* ignore_table

◆ insert_pat

DYNAMIC_STRING insert_pat
static

◆ insert_pat_inited

bool insert_pat_inited = 0
static

◆ lines_terminated

char * lines_terminated = 0
static

◆ load_default_groups

const char* load_default_groups[] = {"mysqldump", "client", 0}
static

◆ lock_tables

bool lock_tables = 1
static

◆ log_error_file

char * log_error_file = NULL
static

◆ md_result_file

FILE* md_result_file = 0

◆ my_end_arg

uint my_end_arg
static

◆ my_long_options

struct my_option my_long_options[]
static

◆ mysql

MYSQL * mysql = 0
static

◆ mysql_connection

MYSQL mysql_connection
static

◆ mysql_universal_client_charset

const char* mysql_universal_client_charset
static
Initial value:
=
#define MYSQL_UNIVERSAL_CLIENT_CHARSET
Definition: mysqldump.cc:89

◆ opt_alldbs

bool opt_alldbs = 0
static

◆ opt_alltspcs

bool opt_alltspcs = 0
static

◆ opt_autocommit

bool opt_autocommit = 0
static

◆ opt_bind_addr

char* opt_bind_addr = NULL
static

◆ opt_comments

bool opt_comments = 0
static

◆ opt_comments_used

bool opt_comments_used = 0
static

◆ opt_compact

bool opt_compact = 0
static

◆ opt_compatible_mode_str

char * opt_compatible_mode_str = 0
static

◆ opt_complete_insert

bool opt_complete_insert = 0
static

◆ opt_compress

bool opt_compress = 0
static

◆ opt_create_db

bool opt_create_db = 0
static

◆ opt_databases

bool opt_databases = 0
static

◆ opt_default_auth

char * opt_default_auth = 0
static

◆ opt_delete_master_logs

bool opt_delete_master_logs = 0
static

◆ opt_disable_keys

bool opt_disable_keys = 1
static

◆ opt_drop

bool opt_drop = 1
static

◆ opt_drop_database

bool opt_drop_database = 0
static

◆ opt_drop_trigger

bool opt_drop_trigger = 0
static

◆ opt_dump_date

bool opt_dump_date = 1
static

◆ opt_dump_triggers

bool opt_dump_triggers = 0
static

◆ opt_enable_cleartext_plugin

uint opt_enable_cleartext_plugin = 0
static

◆ opt_enclosed

char * opt_enclosed = 0
static

◆ opt_events

bool opt_events = 0
static

◆ opt_force

bool opt_force = 0
static

◆ opt_hex_blob

bool opt_hex_blob = 0
static

◆ opt_ignore

bool opt_ignore = 0
static

◆ opt_ignore_error

char * opt_ignore_error = 0
static

◆ opt_include_master_host_port

bool opt_include_master_host_port = 0
static

◆ opt_keywords

bool opt_keywords = 0
static

◆ opt_lock

bool opt_lock = 1
static

◆ opt_lock_all_tables

bool opt_lock_all_tables = 0
static

◆ opt_master_data

uint opt_master_data
static

◆ opt_max_allowed_packet

ulong opt_max_allowed_packet
static

◆ opt_mysql_port

uint opt_mysql_port = 0
static

◆ opt_mysql_unix_port

char* opt_mysql_unix_port = 0
static

◆ opt_net_buffer_length

ulong opt_net_buffer_length
static

◆ opt_network_timeout

bool opt_network_timeout = 0
static

◆ opt_no_create_info

bool opt_no_create_info = 0
static

◆ opt_no_data

bool opt_no_data = 0
static

◆ opt_notspcs

bool opt_notspcs = 0
static

◆ opt_order_by_primary

bool opt_order_by_primary = 0
static

◆ opt_password

char* opt_password = 0
static

◆ opt_plugin_dir

char* opt_plugin_dir = 0
static

◆ opt_protocol

uint opt_protocol = 0
static

◆ opt_quoted

bool opt_quoted = 0
static

◆ opt_replace_into

bool opt_replace_into = 0
static

◆ opt_routines

bool opt_routines = 0
static

◆ opt_set_charset

bool opt_set_charset = 0
static

◆ opt_set_gtid_purged_mode

enum enum_set_gtid_purged_mode opt_set_gtid_purged_mode = SET_GTID_PURGED_AUTO
static

◆ opt_single_transaction

bool opt_single_transaction = 0
static

◆ opt_slave_apply

bool opt_slave_apply = 0
static

◆ opt_slave_data

uint opt_slave_data
static

◆ opt_tz_utc

bool opt_tz_utc = 1
static

◆ opt_xml

bool opt_xml = 0
static

◆ order_by

char * order_by = 0
static

◆ path

char * path = 0
static

◆ quick

bool quick = 1
static

◆ seen_views

bool seen_views = 0

◆ server_supports_switching_charsets

bool server_supports_switching_charsets = true
static

◆ set_gtid_purged_mode_names

const char* set_gtid_purged_mode_names[] = {"OFF", "AUTO", "ON", NullS}

◆ set_gtid_purged_mode_typelib

TYPELIB set_gtid_purged_mode_typelib
static
Initial value:
= {
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352
constexpr size_t array_elements(T(&)[N]) noexcept
Definition: my_macros.h:77
const char * set_gtid_purged_mode_names[]
Definition: mysqldump.cc:154

◆ stats_tables_included

bool stats_tables_included = 0
static

◆ stderror_file

FILE* stderror_file = 0

◆ tty_password

bool tty_password = 0
static

◆ using_opt_enable_cleartext_plugin

bool using_opt_enable_cleartext_plugin = 0
static

◆ verbose

bool verbose = 0
static

◆ where

char * where = 0
static