summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-04-15 09:56:03 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-04-15 09:56:03 +0300
commit84db10f27bdb4c8d9edf7f554afdcd2a24e3285a (patch)
tree5f9d5b22cdfee6f147274d85b279d98f8a1bb46b /client
parent9aacda409db8606b985a93f675487943846cbc86 (diff)
parentccaec18b3934ee384296b4597bdf462fac66c5a4 (diff)
downloadmariadb-git-84db10f27bdb4c8d9edf7f554afdcd2a24e3285a.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'client')
-rw-r--r--client/client_priv.h3
-rw-r--r--client/mysql_upgrade.c2
-rw-r--r--client/mysqldump.c43
-rw-r--r--client/mysqltest.cc109
4 files changed, 60 insertions, 97 deletions
diff --git a/client/client_priv.h b/client/client_priv.h
index 9fe3b6300f2..d709da0ec40 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_MAX_CLIENT_OPTION /* should be always the last */
};
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index ea2108875e9..68785ccff8e 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -503,7 +503,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 d4932094dac..1b5f3b09f79 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2019, MariaDB Corporation.
+ Copyright (c) 2010, 2020, MariaDB Corporation.
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
@@ -90,6 +90,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 *);
@@ -212,7 +213,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;
@@ -383,6 +384,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 "
@@ -911,6 +918,18 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (my_hash_insert(&ignore_database, (uchar*) my_strdup(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(argument, MYF(0))))
+ exit(EX_EOM);
+ break;
+ }
case (int) OPT_IGNORE_TABLE:
{
if (!strchr(argument, '.'))
@@ -1018,6 +1037,10 @@ static int get_options(int *argc, char ***argv)
(uchar*) my_strdup("mysql.transaction_registry", MYF(MY_WME))))
return(EX_EOM);
+ if (my_hash_init(&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);
@@ -1674,6 +1697,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);
@@ -3678,7 +3703,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];
@@ -3708,7 +3733,7 @@ static void dump_table(char *table, char *db)
DBUG_VOID_RETURN;
/* 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);
@@ -4653,10 +4678,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)
@@ -4722,7 +4751,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)
@@ -5120,7 +5149,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 696872ee32c..9b23ebec245 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_PRINT("extra", ("str: %*b", (int) ds->length, ds->str));
#endif
if (fwrite(ds->str, 1, ds->length, m_file) != ds->length)
@@ -1156,71 +1155,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.
@@ -1378,7 +1312,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);
}
@@ -1387,7 +1321,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++;
}
@@ -1407,7 +1341,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);
@@ -1425,7 +1359,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);
@@ -1434,7 +1368,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);
@@ -2387,7 +2321,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, '(', ')');
}
@@ -3043,7 +2977,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;
@@ -3537,10 +3471,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)
@@ -4807,9 +4741,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)
@@ -4820,18 +4751,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);
}
@@ -4996,17 +4927,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);
@@ -6038,7 +5969,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;
@@ -6365,7 +6296,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 */
@@ -9563,6 +9494,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:
@@ -10285,6 +10217,7 @@ void append_replace_regex(char* expr, char *expr_end, struct st_replace_regex* r
return;
err:
+ my_free(res->regex_arr.buffer);
my_free(res);
die("Error parsing replace_regex \"%s\"", expr);
}