diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-04-25 21:57:52 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-04-25 21:57:52 +0300 |
commit | fbe2712705d464bf8488df249c36115e2c1f63f7 (patch) | |
tree | 274e728c719611769288afcb10f79549f6e11f8c /client | |
parent | 62903434eb009cb0bcd5003b0a45914bd4c09886 (diff) | |
parent | a19782522b1eac52d72f5e787b5d96f1fd1a2cb7 (diff) | |
download | mariadb-git-fbe2712705d464bf8488df249c36115e2c1f63f7.tar.gz |
Merge 10.4 into 10.5
The functional changes of commit 5836191c8f0658d5d75484766fdcc3d838b0a5c1
(MDEV-21168) are omitted due to MDEV-742 having addressed the issue.
Diffstat (limited to 'client')
-rw-r--r-- | client/client_priv.h | 3 | ||||
-rw-r--r-- | client/mysql_upgrade.c | 2 | ||||
-rw-r--r-- | client/mysqldump.c | 42 | ||||
-rw-r--r-- | client/mysqltest.cc | 108 |
4 files changed, 59 insertions, 96 deletions
diff --git a/client/client_priv.h b/client/client_priv.h index 9729fcf40fc..0f2cec47a08 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -1,6 +1,6 @@ /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. - Copyright (c) 2009, 2016, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -99,6 +99,7 @@ enum options_client OPT_REPORT_PROGRESS, OPT_SKIP_ANNOTATE_ROWS_EVENTS, OPT_SSL_CRL, OPT_SSL_CRLPATH, + OPT_IGNORE_DATA, OPT_PRINT_ROW_COUNT, OPT_PRINT_ROW_EVENT_POSITIONS, OPT_SHUTDOWN_WAIT_FOR_SLAVES, OPT_COPY_S3_TABLES, diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 7447a96aecf..9c68aad2746 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -507,7 +507,7 @@ static void find_tool(char *tool_executable_name, const char *tool_name, len= (int)(last_fn_libchar - self_name); - my_snprintf(tool_executable_name, FN_REFLEN, "%.*s%c%s", + my_snprintf(tool_executable_name, FN_REFLEN, "%.*b%c%s", len, self_name, FN_LIBCHAR, tool_name); } diff --git a/client/mysqldump.c b/client/mysqldump.c index dfaecf16015..12c2831ec30 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -91,6 +91,7 @@ /* Max length GTID position that we will output. */ #define MAX_GTID_LENGTH 1024 +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); static ulong find_set(TYPELIB *, const char *, size_t, char **, uint *); @@ -211,7 +212,7 @@ TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1, #define MED_ENGINES "MRG_MyISAM, MRG_ISAM, CONNECT, OQGRAPH, SPIDER, VP, FEDERATED" -static HASH ignore_table; +static HASH ignore_table, ignore_data; static HASH ignore_database; @@ -387,6 +388,12 @@ static struct my_option my_long_options[] = "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-data", OPT_IGNORE_DATA, + "Do not dump the specified table data. To specify more than one table " + "to ignore, use the directive multiple times, once for each table. " + "Each table must be specified with both database and table names, e.g., " + "--ignore-table-data=database.table.", + 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 " @@ -912,6 +919,19 @@ get_one_option(const struct my_option *opt, (uchar*) my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(0)))) exit(EX_EOM); break; + case (int) OPT_IGNORE_DATA: + { + if (!strchr(argument, '.')) + { + fprintf(stderr, + "Illegal use of option --ignore-table-data=<database>.<table>\n"); + exit(1); + } + if (my_hash_insert(&ignore_data, (uchar*)my_strdup(PSI_NOT_INSTRUMENTED, + argument, MYF(0)))) + exit(EX_EOM); + break; + } case (int) OPT_IGNORE_TABLE: { if (!strchr(argument, '.')) @@ -1020,6 +1040,10 @@ static int get_options(int *argc, char ***argv) "mysql.transaction_registry", MYF(MY_WME)))) return(EX_EOM); + if (my_hash_init(PSI_NOT_INSTRUMENTED, &ignore_data, charset_info, 16, 0, 0, + (my_hash_get_key) get_table_key, my_free, 0)) + return(EX_EOM); + if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option))) return(ho_error); @@ -1676,6 +1700,8 @@ static void free_resources() my_hash_free(&ignore_database); if (my_hash_inited(&ignore_table)) my_hash_free(&ignore_table); + if (my_hash_inited(&ignore_data)) + my_hash_free(&ignore_data); dynstr_free(&extended_row); dynstr_free(&dynamic_where); dynstr_free(&insert_pat); @@ -3702,7 +3728,7 @@ static char *alloc_query_str(size_t size) */ -static void dump_table(char *table, char *db) +static void dump_table(char *table, char *db, const uchar *hash_key, size_t len) { char ignore_flag; char buf[200], table_buff[NAME_LEN+3]; @@ -3740,7 +3766,7 @@ static void dump_table(char *table, char *db) } /* Check --no-data flag */ - if (opt_no_data) + if (opt_no_data || (hash_key && ignore_table_data(hash_key, len))) { verbose_msg("-- Skipping dump data for table '%s', --no-data was used\n", table); @@ -4694,10 +4720,14 @@ static int init_dumping(char *database, int init_func(char*)) /* Return 1 if we should copy the table */ -my_bool include_table(const uchar *hash_key, size_t len) +static my_bool include_table(const uchar *hash_key, size_t len) { return ! my_hash_search(&ignore_table, hash_key, len); } +static my_bool ignore_table_data(const uchar *hash_key, size_t len) +{ + return my_hash_search(&ignore_data, hash_key, len) != NULL; +} static int dump_all_tables_in_db(char *database) @@ -4763,7 +4793,7 @@ static int dump_all_tables_in_db(char *database) char *end= strmov(afterdot, table); if (include_table((uchar*) hash_key, end - hash_key)) { - dump_table(table,database); + dump_table(table, database, (uchar*) hash_key, end - hash_key); my_free(order_by); order_by= 0; if (opt_dump_triggers && mysql_get_server_version(mysql) >= 50009) @@ -5161,7 +5191,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) for (pos= dump_tables; pos < end; pos++) { DBUG_PRINT("info",("Dumping table %s", *pos)); - dump_table(*pos, db); + dump_table(*pos, db, NULL, 0); if (opt_dump_triggers && mysql_get_server_version(mysql) >= 50009) { diff --git a/client/mysqltest.cc b/client/mysqltest.cc index bc7247e09a1..150c99f80c4 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -588,8 +588,7 @@ static void cleanup_and_exit(int exit_code); ATTRIBUTE_NORETURN void really_die(const char *msg); -void report_or_die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); -ATTRIBUTE_NORETURN ATTRIBUTE_FORMAT(printf, 1, 2) +void report_or_die(const char *fmt, ...); void die(const char *fmt, ...); static void make_error_message(char *buf, size_t len, const char *fmt, va_list args); ATTRIBUTE_NORETURN ATTRIBUTE_FORMAT(printf, 1, 2) @@ -718,7 +717,7 @@ public: DBUG_ASSERT(ds->str); #ifdef EXTRA_DEBUG - DBUG_PRINT("extra", ("str: %*s", (int) ds->length, ds->str)); + DBUG_DUMP("extra", (uchar*) ds->str, ds->length); #endif if (fwrite(ds->str, 1, ds->length, m_file) != ds->length) @@ -1141,71 +1140,6 @@ void do_eval(DYNAMIC_STRING *query_eval, const char *query, /* - Run query and dump the result to stderr in vertical format - - NOTE! This function should be safe to call when an error - has occurred and thus any further errors will be ignored (although logged) - - SYNOPSIS - show_query - mysql - connection to use - query - query to run - -*/ - -static void show_query(MYSQL* mysql, const char* query) -{ - MYSQL_RES* res; - DBUG_ENTER("show_query"); - - if (!mysql) - DBUG_VOID_RETURN; - - if (mysql_query(mysql, query)) - { - log_msg("Error running query '%s': %d %s", - query, mysql_errno(mysql), mysql_error(mysql)); - DBUG_VOID_RETURN; - } - - if ((res= mysql_store_result(mysql)) == NULL) - { - /* No result set returned */ - DBUG_VOID_RETURN; - } - - { - MYSQL_ROW row; - unsigned int i; - unsigned int row_num= 0; - unsigned int num_fields= mysql_num_fields(res); - MYSQL_FIELD *fields= mysql_fetch_fields(res); - - fprintf(stderr, "=== %s ===\n", query); - while ((row= mysql_fetch_row(res))) - { - unsigned long *lengths= mysql_fetch_lengths(res); - row_num++; - - fprintf(stderr, "---- %d. ----\n", row_num); - for(i= 0; i < num_fields; i++) - { - fprintf(stderr, "%s\t%.*s\n", - fields[i].name, - (int)lengths[i], row[i] ? row[i] : "NULL"); - } - } - for (i= 0; i < strlen(query)+8; i++) - fprintf(stderr, "="); - fprintf(stderr, "\n\n"); - } - mysql_free_result(res); - - DBUG_VOID_RETURN; -} - - -/* Show any warnings just before the error. Since the last error is added to the warning stack, only print @@warning_count-1 warnings. @@ -1363,7 +1297,7 @@ void check_command_args(struct st_command *command, /* Check required arg */ if (arg->ds->length == 0 && arg->required) - die("Missing required argument '%s' to command '%.*s'", arg->argname, + die("Missing required argument '%s' to command '%.*b'", arg->argname, command->first_word_len, command->query); } @@ -1372,7 +1306,7 @@ void check_command_args(struct st_command *command, while(ptr <= command->end && *ptr != '#') { if (*ptr && *ptr != ' ') - die("Extra argument '%s' passed to '%.*s'", + die("Extra argument '%s' passed to '%.*b'", ptr, command->first_word_len, command->query); ptr++; } @@ -1392,7 +1326,7 @@ void handle_command_error(struct st_command *command, uint error, if (command->abort_on_error) { - report_or_die("command \"%.*s\" failed with error: %u my_errno: %d " + report_or_die("command \"%.*b\" failed with error: %u my_errno: %d " "errno: %d", command->first_word_len, command->query, error, my_errno, sys_errno); @@ -1410,7 +1344,7 @@ void handle_command_error(struct st_command *command, uint error, DBUG_VOID_RETURN; } if (command->expected_errors.count > 0) - report_or_die("command \"%.*s\" failed with wrong error: %u " + report_or_die("command \"%.*b\" failed with wrong error: %u " "my_errno: %d errno: %d", command->first_word_len, command->query, error, my_errno, sys_errno); @@ -1419,7 +1353,7 @@ void handle_command_error(struct st_command *command, uint error, command->expected_errors.err[0].code.errnum != 0) { /* Error code we wanted was != 0, i.e. not an expected success */ - report_or_die("command \"%.*s\" succeeded - should have failed with " + report_or_die("command \"%.*b\" succeeded - should have failed with " "errno %d...", command->first_word_len, command->query, command->expected_errors.err[0].code.errnum); @@ -2372,7 +2306,7 @@ static int strip_surrounding(char* str, char c1, char c2) static void strip_parentheses(struct st_command *command) { if (strip_surrounding(command->first_argument, '(', ')')) - die("%.*s - argument list started with '%c' must be ended with '%c'", + die("%.*b - argument list started with '%c' must be ended with '%c'", command->first_word_len, command->query, '(', ')'); } @@ -3028,7 +2962,7 @@ void eval_expr(VAR *v, const char *p, const char **p_end, /* Make sure there was just a $variable and nothing else */ const char* end= *p_end + 1; if (end < expected_end && !open_end) - die("Found junk '%.*s' after $variable in expression", + die("Found junk '%.*b' after $variable in expression", (int)(expected_end - end - 1), end); DBUG_VOID_RETURN; @@ -3522,10 +3456,10 @@ int do_modify_var(struct st_command *command, const char *p= command->first_argument; VAR* v; if (!*p) - die("Missing argument to %.*s", command->first_word_len, + die("Missing argument to %.*b", command->first_word_len, command->query); if (*p != '$') - die("The argument to %.*s must be a variable (start with $)", + die("The argument to %.*b must be a variable (start with $)", command->first_word_len, command->query); v= var_get(p, &p, 1, 0); if (! v->is_int) @@ -4792,9 +4726,6 @@ void do_sync_with_master2(struct st_command *command, long offset, if (!result_str || result < 0) { /* master_pos_wait returned NULL or < 0 */ - show_query(mysql, "SHOW MASTER STATUS"); - show_query(mysql, "SHOW SLAVE STATUS"); - show_query(mysql, "SHOW PROCESSLIST"); fprintf(stderr, "analyze: sync_with_master\n"); if (!result_str) @@ -4805,18 +4736,18 @@ void do_sync_with_master2(struct st_command *command, long offset, information is not initialized, the arguments are incorrect, or an error has occurred */ - die("%.*s failed: '%s' returned NULL " \ + die("%.*b failed: '%s' returned NULL " \ "indicating slave SQL thread failure", command->first_word_len, command->query, query_buf); } if (result == -1) - die("%.*s failed: '%s' returned -1 " \ + die("%.*b failed: '%s' returned -1 " \ "indicating timeout after %d seconds", command->first_word_len, command->query, query_buf, timeout); else - die("%.*s failed: '%s' returned unknown result :%d", + die("%.*b failed: '%s' returned unknown result :%d", command->first_word_len, command->query, query_buf, result); } @@ -4981,17 +4912,17 @@ int do_sleep(struct st_command *command, my_bool real_sleep) while (my_isspace(charset_info, *p)) p++; if (!*p) - die("Missing argument to %.*s", command->first_word_len, + die("Missing argument to %.*b", command->first_word_len, command->query); sleep_start= p; /* Check that arg starts with a digit, not handled by my_strtod */ if (!my_isdigit(charset_info, *sleep_start)) - die("Invalid argument to %.*s \"%s\"", command->first_word_len, + die("Invalid argument to %.*b \"%s\"", command->first_word_len, command->query, sleep_start); sleep_val= my_strtod(sleep_start, &sleep_end, &error); check_eol_junk_line(sleep_end); if (error) - die("Invalid argument to %.*s \"%s\"", command->first_word_len, + die("Invalid argument to %.*b \"%s\"", command->first_word_len, command->query, command->first_argument); dynstr_free(&ds_sleep); @@ -6042,7 +5973,7 @@ void do_connect(struct st_command *command) csname= strdup(con_options + sizeof("CHARSET=") - 1); } else - die("Illegal option to connect: %.*s", + die("Illegal option to connect: %.*b", (int) (end - con_options), con_options); /* Process next option */ con_options= end; @@ -6343,7 +6274,7 @@ void do_block(enum block_cmd cmd, struct st_command* command) enum block_op operand= find_operand(curr_ptr); if (operand == ILLEG_OP) - die("Found junk '%.*s' after $variable in condition", + die("Found junk '%.*b' after $variable in condition", (int)(expr_end - curr_ptr), curr_ptr); /* We could silently allow this, but may be confusing */ @@ -9543,6 +9474,7 @@ int main(int argc, char **argv) case Q_LET: do_let(command); break; case Q_EVAL_RESULT: die("'eval_result' command is deprecated"); + break; // never called but keep compiler calm case Q_EVAL: case Q_EVALP: case Q_QUERY_VERTICAL: |