diff options
author | Igor Babaev <igor@askmonty.org> | 2018-06-03 10:34:41 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2018-06-03 10:34:41 -0700 |
commit | cab1d6382623f0611335caf2cd056aa7ee04d7cd (patch) | |
tree | c33b8118a77a78d87d8fb01e908dbfa6a67ca9a2 /client | |
parent | ffe83e8e7bef32eb2a80aad2d382f0b023dd3a44 (diff) | |
parent | ee5124d714ea01f4e1bd6decf6da38b05c1009ad (diff) | |
download | mariadb-git-cab1d6382623f0611335caf2cd056aa7ee04d7cd.tar.gz |
Merge branch '10.3' into 10.4
Diffstat (limited to 'client')
-rw-r--r-- | client/client_priv.h | 1 | ||||
-rw-r--r-- | client/mysql.cc | 5 | ||||
-rw-r--r-- | client/mysql_plugin.c | 9 | ||||
-rw-r--r-- | client/mysql_upgrade.c | 7 | ||||
-rw-r--r-- | client/mysqlbinlog.cc | 2 | ||||
-rw-r--r-- | client/mysqldump.c | 50 | ||||
-rw-r--r-- | client/mysqltest.cc | 10 |
7 files changed, 61 insertions, 23 deletions
diff --git a/client/client_priv.h b/client/client_priv.h index 1d584efeea7..ada72187569 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -61,6 +61,7 @@ enum options_client OPT_USE_THREADS, OPT_IMPORT_USE_THREADS, OPT_MYSQL_NUMBER_OF_QUERY, + OPT_IGNORE_DATABASE, OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, OPT_TZ_UTC, OPT_CREATE_SLAP_SCHEMA, OPT_MYSQLDUMP_SLAVE_APPLY, diff --git a/client/mysql.cc b/client/mysql.cc index cb5c2318698..6a720c38ef1 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3130,7 +3130,7 @@ static int com_help(String *buffer __attribute__((unused)), char *line __attribute__((unused))) { - reg1 int i, j; + int i, j; char * help_arg= strchr(line,' '), buff[32], *end; if (help_arg) { @@ -4205,8 +4205,7 @@ com_edit(String *buffer,char *line __attribute__((unused))) const char *editor; MY_STAT stat_arg; - if ((fd=create_temp_file(filename,NullS,"sql", O_CREAT | O_WRONLY, - MYF(MY_WME))) < 0) + if ((fd= create_temp_file(filename,NullS,"sql", 0, MYF(MY_WME))) < 0) goto err; if (buffer->is_empty() && !old_buffer.is_empty()) (void) my_write(fd,(uchar*) old_buffer.ptr(),old_buffer.length(), diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c index 81677ad551f..40560613a89 100644 --- a/client/mysql_plugin.c +++ b/client/mysql_plugin.c @@ -159,8 +159,7 @@ static int make_tempfile(char *filename, const char *ext) { int fd= 0; - if ((fd=create_temp_file(filename, NullS, ext, O_CREAT | O_WRONLY, - MYF(MY_WME))) < 0) + if ((fd= create_temp_file(filename, NullS, ext, 0, MYF(MY_WME))) < 0) { fprintf(stderr, "ERROR: Cannot generate temporary file. Error code: %d.\n", fd); @@ -365,6 +364,12 @@ static int get_default_values() } /* Now open the file and read the defaults we want. */ file= fopen(defaults_file, "r"); + if (file == NULL) + { + fprintf(stderr, "ERROR: failed to open file %s: %s.\n", defaults_file, + strerror(errno)); + goto exit; + } while (fgets(line, FN_REFLEN, file) != NULL) { char *value= 0; diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 0e0695c9ebe..ef1630dd0e3 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -558,8 +558,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res, DBUG_PRINT("enter", ("query: %s", query)); if ((fd= create_temp_file(query_file_path, opt_tmpdir[0] ? opt_tmpdir : NULL, - "sql", O_CREAT | O_SHARE | O_RDWR, - MYF(MY_WME))) < 0) + "sql", O_SHARE, MYF(MY_WME))) < 0) die("Failed to create temporary file for defaults"); /* @@ -1144,7 +1143,7 @@ int main(int argc, char **argv) load_defaults_or_exit("my", load_default_groups, &argc, &argv); defaults_argv= argv; /* Must be freed by 'free_defaults' */ -#if __WIN__ +#if defined(__WIN__) if (GetModuleFileName(NULL, self_name, FN_REFLEN) == 0) #endif { @@ -1176,7 +1175,7 @@ int main(int argc, char **argv) cnf_file_path= strmov(defaults_file, "--defaults-file="); { int fd= create_temp_file(cnf_file_path, opt_tmpdir[0] ? opt_tmpdir : NULL, - "mysql_upgrade-", O_CREAT | O_WRONLY, MYF(MY_FAE)); + "mysql_upgrade-", 0, MYF(MY_FAE)); if (fd < 0) die(NULL); my_write(fd, USTRING_WITH_LEN( "[client]\n"), MYF(MY_FAE)); diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 44675ef7ed9..4c8709bfca6 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -2904,7 +2904,7 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info, stdin in binary mode. Errors on setting this mode result in halting the function and printing an error message to stderr. */ -#if defined (__WIN__) || (_WIN64) +#if defined (__WIN__) || defined(_WIN64) if (_setmode(fileno(stdin), O_BINARY) == -1) { error("Could not set binary mode on stdin."); diff --git a/client/mysqldump.c b/client/mysqldump.c index 3dbe8412f3c..dc87338aac2 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -212,7 +212,9 @@ TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1, #define MED_ENGINES "MRG_MyISAM, MRG_ISAM, CONNECT, OQGRAPH, SPIDER, VP, FEDERATED" -HASH ignore_table; +static HASH ignore_table; + +static HASH ignore_database; static struct my_option my_long_options[] = { @@ -376,6 +378,11 @@ static struct my_option my_long_options[] = &opt_hex_blob, &opt_hex_blob, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host.", ¤t_host, ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"ignore-database", OPT_IGNORE_DATABASE, + "Do not dump the specified database. To specify more than one database to ignore, " + "use the directive multiple times, once for each database. Only takes effect " + "when used together with --all-databases|-A", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ignore-table", OPT_IGNORE_TABLE, "Do not dump the specified table. To specify more than one table to ignore, " "use the directive multiple times, once for each table. Each table must " @@ -900,6 +907,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case (int) OPT_TABLES: opt_databases=0; break; + case (int) OPT_IGNORE_DATABASE: + if (my_hash_insert(&ignore_database, (uchar*) my_strdup(argument, MYF(0)))) + exit(EX_EOM); + break; case (int) OPT_IGNORE_TABLE: { if (!strchr(argument, '.')) @@ -984,6 +995,9 @@ static int get_options(int *argc, char ***argv) load_defaults_or_exit("my", load_default_groups, argc, argv); defaults_argv= *argv; + if (my_hash_init(&ignore_database, charset_info, 16, 0, 0, + (my_hash_get_key) get_table_key, my_free, 0)) + return(EX_EOM); if (my_hash_init(&ignore_table, charset_info, 16, 0, 0, (my_hash_get_key) get_table_key, my_free, 0)) return(EX_EOM); @@ -1056,6 +1070,13 @@ static int get_options(int *argc, char ***argv) my_progname_short); return(EX_USAGE); } + if (ignore_database.records && !opt_alldbs) + { + fprintf(stderr, + "%s: --ignore-database can only be used together with --all-databases.\n", + my_progname_short); + return(EX_USAGE); + } if (strcmp(default_charset, charset_info->csname) && !(charset_info= get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME)))) @@ -1642,6 +1663,8 @@ static void free_resources() my_free(opt_password); my_free(current_host); free_root(&glob_root, MYF(0)); + if (my_hash_inited(&ignore_database)) + my_hash_free(&ignore_database); if (my_hash_inited(&ignore_table)) my_hash_free(&ignore_table); dynstr_free(&extended_row); @@ -2491,7 +2514,7 @@ static uint dump_routines_for_db(char *db) "Create Package Body"}; char db_name_buff[NAME_LEN*2+3], name_buff[NAME_LEN*2+3]; char *routine_name; - int i; + uint i; FILE *sql_file= md_result_file; MYSQL_ROW row, routine_list_row; @@ -2527,7 +2550,7 @@ static uint dump_routines_for_db(char *db) fputs("\t<routines>\n", sql_file); /* 0, retrieve and dump functions, 1, procedures, etc. */ - for (i= 0; i < 4; i++) + for (i= 0; i < array_elements(routine_type); i++) { my_snprintf(query_buff, sizeof(query_buff), "SHOW %s STATUS WHERE Db = '%s'", @@ -4214,6 +4237,7 @@ static int dump_tablespaces_for_tables(char *db, char **table_names, int tables) return r; } + static int dump_tablespaces_for_databases(char** databases) { int r; @@ -4243,6 +4267,7 @@ static int dump_tablespaces_for_databases(char** databases) return r; } + static int dump_tablespaces(char* ts_where) { MYSQL_ROW row; @@ -4429,6 +4454,14 @@ static int dump_tablespaces(char* ts_where) DBUG_RETURN(0); } + +/* Return 1 if we should copy the database */ +static my_bool include_database(const char *hash_key) +{ + return !my_hash_search(&ignore_database, (uchar*) hash_key, strlen(hash_key)); +} + + static int dump_all_databases() { MYSQL_ROW row; @@ -4447,8 +4480,9 @@ static int dump_all_databases() !my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME)) continue; - if (dump_all_tables_in_db(row[0])) - result=1; + if (include_database(row[0])) + if (dump_all_tables_in_db(row[0])) + result=1; } mysql_free_result(tableres); if (seen_views) @@ -4470,8 +4504,9 @@ static int dump_all_databases() !my_strcasecmp(&my_charset_latin1, row[0], PERFORMANCE_SCHEMA_DB_NAME)) continue; - if (dump_all_views_in_db(row[0])) - result=1; + if (include_database(row[0])) + if (dump_all_views_in_db(row[0])) + result=1; } mysql_free_result(tableres); } @@ -6055,7 +6090,6 @@ int main(int argc, char **argv) sf_leaking_memory=1; /* don't report memory leaks on early exits */ compatible_mode_normal_str[0]= 0; default_charset= (char *)mysql_universal_client_charset; - bzero((char*) &ignore_table, sizeof(ignore_table)); exit_code= get_options(&argc, &argv); if (exit_code) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 12016d9b6c7..b9aac043017 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -949,6 +949,8 @@ pthread_handler_t connection_thread(void *arg) end_thread: cn->query_done= 1; + mysql_close(cn->mysql); + cn->mysql= 0; mysql_thread_end(); pthread_exit(0); return 0; @@ -1462,7 +1464,7 @@ void close_statements() for (con= connections; con < next_con; con++) { if (con->stmt) - mysql_stmt_close(con->stmt); + do_stmt_close(con); con->stmt= 0; } DBUG_VOID_RETURN; @@ -2209,8 +2211,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) DBUG_ENTER("dyn_string_cmp"); DBUG_PRINT("enter", ("fname: %s", fname)); - if ((fd= create_temp_file(temp_file_path, TMPDIR, - "tmp", O_CREAT | O_SHARE | O_RDWR, + if ((fd= create_temp_file(temp_file_path, TMPDIR, "tmp", O_SHARE, MYF(MY_WME))) < 0) die("Failed to create temporary file for ds"); @@ -4684,8 +4685,7 @@ void do_perl(struct st_command *command) /* Create temporary file name */ if ((fd= create_temp_file(temp_file_path, getenv("MYSQLTEST_VARDIR"), - "tmp", O_CREAT | O_SHARE | O_RDWR, - MYF(MY_WME))) < 0) + "tmp", O_SHARE, MYF(MY_WME))) < 0) die("Failed to create temporary file for perl command"); my_close(fd, MYF(0)); |