summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-08-06 13:27:44 +0200
committerSergei Golubchik <sergii@pisem.net>2014-08-06 13:27:44 +0200
commit15a9103c480f272be794933fcd26f7f97da9d56b (patch)
tree5d2f4797ac760a55895624dab89951c4957e3a0b /client
parent3390291b95c51db46ba007129fb4878bc03e1e36 (diff)
downloadmariadb-git-15a9103c480f272be794933fcd26f7f97da9d56b.tar.gz
MDEV-6535 Ordering of mysql_upgrade tasks is not optimal
first update system tables, then the rest
Diffstat (limited to 'client')
-rw-r--r--client/mysql_upgrade.c45
-rw-r--r--client/mysqlcheck.c10
2 files changed, 30 insertions, 25 deletions
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 80d57ce9faa..dedac4dafd6 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -206,12 +206,12 @@ static void die(const char *fmt, ...)
}
-static void verbose(const char *fmt, ...)
+static int verbose(const char *fmt, ...)
{
va_list args;
if (opt_silent)
- return;
+ return 0;
/* Print the verbose message */
va_start(args, fmt);
@@ -222,6 +222,7 @@ static void verbose(const char *fmt, ...)
fflush(stdout);
}
va_end(args);
+ return 0;
}
@@ -736,20 +737,19 @@ static void print_conn_args(const char *tool_name)
in the server using "mysqlcheck --check-upgrade .."
*/
-static int run_mysqlcheck_upgrade(void)
+static int run_mysqlcheck_upgrade(const char *arg1, const char *arg2)
{
- verbose("Phase 2/3: Checking and upgrading tables");
print_conn_args("mysqlcheck");
return run_tool(mysqlcheck_path,
NULL, /* Send output from mysqlcheck directly to screen */
"--no-defaults",
ds_args.str,
"--check-upgrade",
- "--all-databases",
"--auto-repair",
!opt_silent || opt_verbose ? "--verbose": "",
opt_silent ? "--silent": "",
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
+ arg1, arg2,
"2>&1",
NULL);
}
@@ -757,7 +757,7 @@ static int run_mysqlcheck_upgrade(void)
static int run_mysqlcheck_fixnames(void)
{
- verbose("Phase 1/3: Fixing table and database names");
+ verbose("Phase 2/3: Fixing table and database names");
print_conn_args("mysqlcheck");
return run_tool(mysqlcheck_path,
NULL, /* Send output from mysqlcheck directly to screen */
@@ -843,7 +843,6 @@ static int run_sql_fix_privilege_tables(void)
if (init_dynamic_string(&ds_result, "", 512, 512))
die("Out of memory");
- verbose("Phase 3/3: Running 'mysql_fix_privilege_tables'...");
/*
Individual queries can not be executed independently by invoking
a forked mysql client, because the script uses session variables
@@ -990,16 +989,12 @@ int main(int argc, char **argv)
/* Find mysql */
find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"), self_name);
- if (!opt_systables_only)
- {
- /* Find mysqlcheck */
- find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
- }
- else
- {
- if (!opt_silent)
- printf("The --upgrade-system-tables option was used, databases won't be touched.\n");
- }
+ /* Find mysqlcheck */
+ find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);
+
+ if (opt_systables_only && !opt_silent)
+ printf("The --upgrade-system-tables option was used, user tables won't be touched.\n");
+
/*
Read the mysql_upgrade_info file to check if mysql_upgrade
@@ -1019,16 +1014,16 @@ int main(int argc, char **argv)
/*
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
*/
- if ((!opt_systables_only &&
- (run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) ||
+ verbose("Phase 1/3: Running 'mysql_fix_privilege_tables'...");
+ if (run_mysqlcheck_upgrade("--databases", "mysql") ||
run_sql_fix_privilege_tables())
- {
- /*
- The upgrade failed to complete in some way or another,
- significant error message should have been printed to the screen
- */
die("Upgrade failed" );
- }
+ if (!opt_systables_only &&
+ (run_mysqlcheck_fixnames() ||
+ verbose("Phase 3/3: Checking and upgrading tables") ||
+ run_mysqlcheck_upgrade("--all-databases","--skip-database=mysql")))
+ die("Upgrade failed" );
+
verbose("OK");
/* Create a file indicating upgrade has been performed */
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 57b7ce09ab5..bf2e55a6604 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -51,6 +51,7 @@ static char *opt_password = 0, *current_user = 0,
*default_charset= 0, *current_host= 0;
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
static int first_error = 0;
+static char *opt_skip_database;
DYNAMIC_ARRAY tables4repair, tables4rebuild, alter_table_cmds;
static char *shared_memory_base_name=0;
static uint opt_protocol=0;
@@ -178,6 +179,9 @@ static struct my_option my_long_options[] =
#endif
{"silent", 's', "Print only error messages.", &opt_silent,
&opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"skip_database", 0, "Don't process the database specified as argument",
+ &opt_skip_database, &opt_skip_database, 0, GET_STR, REQUIRED_ARG,
+ 0, 0, 0, 0, 0, 0},
{"socket", 'S', "The socket file to use for connection.",
&opt_mysql_unix_port, &opt_mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -246,6 +250,9 @@ static void usage(void)
puts("mysqlrepair: The default option will be -r");
puts("mysqlanalyze: The default option will be -a");
puts("mysqloptimize: The default option will be -o\n");
+ printf("Usage: %s [OPTIONS] database [tables]\n", my_progname);
+ printf("OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n",
+ my_progname);
puts("Please consult the MariaDB/MySQL knowledgebase at");
puts("http://kb.askmonty.org/v/mysqlcheck for latest information about");
puts("this program.");
@@ -696,6 +703,9 @@ static int process_one_db(char *database)
{
DBUG_ENTER("process_one_db");
+ if (opt_skip_database && !strcmp(database, opt_skip_database))
+ DBUG_RETURN(0);
+
if (verbose)
puts(database);
if (what_to_do == DO_UPGRADE)