diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 6 | ||||
-rw-r--r-- | client/mysqldump.c | 103 | ||||
-rw-r--r-- | client/mysqlslap.c | 3 | ||||
-rw-r--r-- | client/mysqltest.cc | 2 |
4 files changed, 90 insertions, 24 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 3cae7241969..b7a2d6c5e72 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -4704,7 +4704,11 @@ sql_real_connect(char *host,char *database,char *user,char *password, return -1; // Retryable } - charset_info= get_charset_by_name(mysql.charset->name, MYF(0)); + if (!(charset_info= get_charset_by_name(mysql.charset->name, MYF(0)))) + { + put_info("Unknown default character set", INFO_ERROR); + return 1; + } connected=1; diff --git a/client/mysqldump.c b/client/mysqldump.c index d6ff2dd275f..fc5b3bfabaf 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -42,6 +42,11 @@ /* on merge conflict, bump to a higher version again */ #define DUMP_VERSION "10.19" +/** + First mysql version supporting sequences. +*/ +#define FIRST_SEQUENCE_VERSION 100300 + #include <my_global.h> #include <my_sys.h> #include <my_user.h> @@ -92,6 +97,11 @@ /* Max length GTID position that we will output. */ #define MAX_GTID_LENGTH 1024 +/* Dump sequence/tables control */ +#define DUMP_TABLE_ALL -1 +#define DUMP_TABLE_TABLE 0 +#define DUMP_TABLE_SEQUENCE 1 + static my_bool ignore_table_data(const uchar *hash_key, size_t len); static void add_load_option(DYNAMIC_STRING *str, const char *option, const char *option_value); @@ -1063,6 +1073,20 @@ static int get_options(int *argc, char ***argv) if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option))) return(ho_error); + /* + Dumping under --system=stats with --replace or --inser-ignore is safe and will not + retult into race condition. Otherwise dump only structure and ignore data by default + while dumping. + */ + if (!(opt_system & OPT_SYSTEM_STATS) && !(opt_ignore || opt_replace_into)) + { + if (my_hash_insert(&ignore_data, + (uchar*) my_strdup("mysql.innodb_index_stats", MYF(MY_WME))) || + my_hash_insert(&ignore_data, + (uchar*) my_strdup("mysql.innodb_table_stats", MYF(MY_WME)))) + return(EX_EOM); + } + if (opt_system & OPT_SYSTEM_ALL) opt_system|= ~0; @@ -3867,14 +3891,6 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key, DBUG_ENTER("dump_table"); /* - Check does table has a sequence structure and if has apply different sql queries - */ - if (check_if_ignore_table(table, table_type) & IGNORE_SEQUENCE_TABLE) - { - get_sequence_structure(table, db); - DBUG_VOID_RETURN; - } - /* Make sure you get the create table info before the following check for --no-data flag below. Otherwise, the create table info won't be printed. */ @@ -4358,18 +4374,36 @@ err: } /* dump_table */ -static char *getTableName(int reset) +static char *getTableName(int reset, int want_sequences) { MYSQL_ROW row; if (!get_table_name_result) { - if (!(get_table_name_result= mysql_list_tables(mysql,NullS))) - return(NULL); + if (mysql_get_server_version(mysql) >= FIRST_SEQUENCE_VERSION) + { + const char *query= "SHOW FULL TABLES"; + if (mysql_query_with_error_report(mysql, 0, query)) + return (NULL); + + if (!(get_table_name_result= mysql_store_result(mysql))) + return (NULL); + } + else + { + if (!(get_table_name_result= mysql_list_tables(mysql,NullS))) + return(NULL); + } } if ((row= mysql_fetch_row(get_table_name_result))) - return((char*) row[0]); + { + if (want_sequences != DUMP_TABLE_ALL) + while (row && MY_TEST(strcmp(row[1], "SEQUENCE")) == want_sequences) + row= mysql_fetch_row(get_table_name_result); + if (row) + return((char*) row[0]); + } if (reset) mysql_data_seek(get_table_name_result,0); /* We want to read again */ else @@ -4762,7 +4796,7 @@ static int dump_all_servers() static int dump_all_stats() { - my_bool prev_no_create_info; + my_bool prev_no_create_info, prev_opt_replace_into; if (mysql_select_db(mysql, "mysql")) { @@ -4770,6 +4804,8 @@ static int dump_all_stats() return 1; /* If --force */ } fprintf(md_result_file,"\nUSE mysql;\n"); + prev_opt_replace_into= opt_replace_into; + opt_replace_into|= !opt_ignore; prev_no_create_info= opt_no_create_info; opt_no_create_info= 1; /* don't overwrite recreate tables */ /* EITS added in 10.0.1 */ @@ -4788,6 +4824,7 @@ static int dump_all_stats() dump_table("innodb_table_stats", "mysql", NULL, 0); } opt_no_create_info= prev_no_create_info; + opt_replace_into= prev_opt_replace_into; return 0; } @@ -4798,12 +4835,14 @@ static int dump_all_stats() static int dump_all_timezones() { - my_bool opt_prev_no_create_info; + my_bool opt_prev_no_create_info, opt_prev_replace_into; if (mysql_select_db(mysql, "mysql")) { DB_error(mysql, "when selecting the database"); return 1; /* If --force */ } + opt_prev_replace_into= opt_replace_into; + opt_replace_into|= !opt_ignore; opt_prev_no_create_info= opt_no_create_info; opt_no_create_info= 1; fprintf(md_result_file,"\nUSE mysql;\n"); @@ -4813,6 +4852,7 @@ static int dump_all_timezones() dump_table("time_zone_transition", "mysql", NULL, 0); dump_table("time_zone_transition_type", "mysql", NULL, 0); opt_no_create_info= opt_prev_no_create_info; + opt_replace_into= opt_prev_replace_into; return 0; } @@ -5302,7 +5342,7 @@ static int dump_all_tables_in_db(char *database) { DYNAMIC_STRING query; init_dynamic_string_checked(&query, "LOCK TABLES ", 256, 1024); - for (numrows= 0 ; (table= getTableName(1)) ; ) + for (numrows= 0 ; (table= getTableName(1, DUMP_TABLE_ALL)) ; ) { char *end= strmov(afterdot, table); if (include_table((uchar*) hash_key,end - hash_key)) @@ -5336,7 +5376,19 @@ static int dump_all_tables_in_db(char *database) DBUG_RETURN(1); } } - while ((table= getTableName(0))) + + if (mysql_get_server_version(mysql) >= FIRST_SEQUENCE_VERSION && + !opt_no_create_info) + { + // First process sequences + while ((table= getTableName(1, DUMP_TABLE_SEQUENCE))) + { + char *end= strmov(afterdot, table); + if (include_table((uchar*) hash_key, end - hash_key)) + get_sequence_structure(table, database); + } + } + while ((table= getTableName(0, DUMP_TABLE_TABLE))) { char *end= strmov(afterdot, table); if (include_table((uchar*) hash_key, end - hash_key)) @@ -5485,7 +5537,7 @@ static my_bool dump_all_views_in_db(char *database) { DYNAMIC_STRING query; init_dynamic_string_checked(&query, "LOCK TABLES ", 256, 1024); - for (numrows= 0 ; (table= getTableName(1)); ) + for (numrows= 0 ; (table= getTableName(1, DUMP_TABLE_TABLE)); ) { char *end= strmov(afterdot, table); if (include_table((uchar*) hash_key,end - hash_key)) @@ -5508,7 +5560,7 @@ static my_bool dump_all_views_in_db(char *database) else verbose_msg("-- dump_all_views_in_db : logs flushed successfully!\n"); } - while ((table= getTableName(0))) + while ((table= getTableName(0, DUMP_TABLE_TABLE))) { char *end= strmov(afterdot, table); if (include_table((uchar*) hash_key, end - hash_key)) @@ -5638,7 +5690,7 @@ static int get_sys_var_lower_case_table_names() static int dump_selected_tables(char *db, char **table_names, int tables) { - char table_buff[NAME_LEN*2+3]; + char table_buff[NAME_LEN*2+3], table_type[NAME_LEN]; DYNAMIC_STRING lock_tables_query; char **dump_tables, **pos, **end; int lower_case_table_names; @@ -5735,9 +5787,22 @@ static int dump_selected_tables(char *db, char **table_names, int tables) DBUG_RETURN(1); } } + + if (mysql_get_server_version(mysql) >= FIRST_SEQUENCE_VERSION) + { + /* Dump Sequence first */ + for (pos= dump_tables; pos < end; pos++) + { + DBUG_PRINT("info",("Dumping sequence(?) %s", *pos)); + if (check_if_ignore_table(*pos, table_type) & IGNORE_SEQUENCE_TABLE) + get_sequence_structure(*pos, db); + } + } /* Dump each selected table */ for (pos= dump_tables; pos < end; pos++) { + if (check_if_ignore_table(*pos, table_type) & IGNORE_SEQUENCE_TABLE) + continue; DBUG_PRINT("info",("Dumping table %s", *pos)); dump_table(*pos, db, NULL, 0); if (opt_dump_triggers && diff --git a/client/mysqlslap.c b/client/mysqlslap.c index ed5e20ca18c..c44bf8446f9 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -1177,9 +1177,6 @@ get_options(int *argc,char ***argv) if (debug_check_flag) my_end_arg= MY_CHECK_ERROR; - if (!user) - user= (char *)"root"; - /* If something is created and --no-drop is not specified, we drop the schema. diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 73a6f03d889..5dfcce53e83 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -10905,7 +10905,7 @@ int get_next_bit(REP_SET *set,uint lastpos) start=set->bits+ ((lastpos+1) / WORD_BIT); end=set->bits + set->size_of_bits; - bits=start[0] & ~((1 << ((lastpos+1) % WORD_BIT)) -1); + bits=start[0] & ~((1U << ((lastpos+1) % WORD_BIT)) -1); while (! bits && ++start < end) bits=start[0]; |