summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2014-08-14 15:38:08 +0300
committerMichael Widenius <monty@mariadb.org>2014-08-14 15:38:08 +0300
commit65ac881c8096cd069e622da6cd699ff1d4aaac57 (patch)
tree88e7903375aa61dd200753202a109cd4a8518294 /client
parent258ecf55385f2e6a707cf0d3ea70ab2f116f1527 (diff)
downloadmariadb-git-65ac881c8096cd069e622da6cd699ff1d4aaac57.tar.gz
If one uses 3 --verbose options to mysql_upgrade or mysqlcheck one will now get on stdout all ALTER, RENAME and CHECK commands that mysqlcheck executes.
If one uses 4 --verbose to mysql_upgrade it will also write out all mysqlcheck commands invoked. mysql-test/r/mysql_upgrade.result: Updated results from changing phases mysql-test/r/mysql_upgrade_no_innodb.result: dated results from changing phases mysql-test/r/mysql_upgrade_ssl.result: dated results from changing phases
Diffstat (limited to 'client')
-rw-r--r--client/mysql_upgrade.c42
-rw-r--r--client/mysqlcheck.c22
2 files changed, 40 insertions, 24 deletions
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index dedac4dafd6..c2b8f3ce790 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -22,7 +22,7 @@
#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */
-#define VER "1.3a"
+#define VER "1.4"
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
@@ -140,21 +140,21 @@ static struct my_option my_long_options[]=
#include <sslopt-longopts.h>
{"tmpdir", 't', "Directory for temporary files.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"upgrade-system-tables", 's', "Only upgrade the system tables "
- "do not try to upgrade the data.",
+ {"upgrade-system-tables", 's', "Only upgrade the system tables in the mysql database. Tables in other databases are not checked or touched.",
&opt_systables_only, &opt_systables_only, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"user", 'u', "User for login if not current user.", &opt_user,
&opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"verbose", 'v', "Display more output about the process.",
+ {"verbose", 'v', "Display more output about the process; Using it twice will print connection argument; Using it 3 times will print out all CHECK, RENAME and ALTER TABLE during the check phase.",
&opt_not_used, &opt_not_used, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"version-check", 'k', "Run this program only if its \'server version\' "
- "matches the version of the server to which it's connecting, (enabled by "
- "default); use --skip-version-check to avoid this check. Note: the \'server "
- "version\' of the program is the version of the MySQL server with which it "
- "was built/distributed.", &opt_version_check, &opt_version_check, 0,
+ {"version-check", 'k',
+ "Run this program only if its \'server version\' "
+ "matches the version of the server to which it's connecting. "
+ "Note: the \'server version\' of the program is the version of the MariaDB "
+ "server with which it was built/distributed.",
+ &opt_version_check, &opt_version_check, 0,
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"write-binlog", OPT_WRITE_BINLOG, "All commands including those, "
"issued by mysqlcheck, are written to the binary log.",
@@ -371,6 +371,9 @@ static int run_command(char* cmd,
FILE *res_file;
int error;
+ if (opt_verbose >= 4)
+ puts(cmd);
+
if (!(res_file= popen(cmd, "r")))
die("popen(\"%s\", \"r\") failed", cmd);
@@ -746,7 +749,9 @@ static int run_mysqlcheck_upgrade(const char *arg1, const char *arg2)
ds_args.str,
"--check-upgrade",
"--auto-repair",
- !opt_silent || opt_verbose ? "--verbose": "",
+ !opt_silent || opt_verbose >= 1 ? "--verbose" : "",
+ opt_verbose >= 2 ? "--verbose" : "",
+ opt_verbose >= 3 ? "--verbose" : "",
opt_silent ? "--silent": "",
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
arg1, arg2,
@@ -757,7 +762,7 @@ static int run_mysqlcheck_upgrade(const char *arg1, const char *arg2)
static int run_mysqlcheck_fixnames(void)
{
- verbose("Phase 2/3: Fixing table and database names");
+ verbose("Phase 3/4: Fixing table and database names");
print_conn_args("mysqlcheck");
return run_tool(mysqlcheck_path,
NULL, /* Send output from mysqlcheck directly to screen */
@@ -766,7 +771,9 @@ static int run_mysqlcheck_fixnames(void)
"--all-databases",
"--fix-db-names",
"--fix-table-names",
- opt_verbose ? "--verbose": "",
+ opt_verbose >= 1 ? "--verbose" : "",
+ opt_verbose >= 2 ? "--verbose" : "",
+ opt_verbose >= 3 ? "--verbose" : "",
opt_silent ? "--silent": "",
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
"2>&1",
@@ -1014,13 +1021,16 @@ int main(int argc, char **argv)
/*
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
*/
- verbose("Phase 1/3: Running 'mysql_fix_privilege_tables'...");
- if (run_mysqlcheck_upgrade("--databases", "mysql") ||
- run_sql_fix_privilege_tables())
+ verbose("Phase 1/4: Checking mysql database");
+ if (run_mysqlcheck_upgrade("--databases", "mysql"))
+ die("Upgrade failed" );
+ verbose("Phase 2/4: Running 'mysql_fix_privilege_tables'...");
+ if (run_sql_fix_privilege_tables())
die("Upgrade failed" );
+
if (!opt_systables_only &&
(run_mysqlcheck_fixnames() ||
- verbose("Phase 3/3: Checking and upgrading tables") ||
+ verbose("Phase 4/4: Checking and upgrading tables") ||
run_mysqlcheck_upgrade("--all-databases","--skip-database=mysql")))
die("Upgrade failed" );
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index bf2e55a6604..2f5ee4c82e6 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -18,7 +18,7 @@
/* By Jani Tolonen, 2001-04-20, MySQL Development Team */
-#define CHECK_VERSION "2.7.2-MariaDB"
+#define CHECK_VERSION "2.7.3-MariaDB"
#include "client_priv.h"
#include <m_ctype.h>
@@ -196,8 +196,8 @@ static struct my_option my_long_options[] =
{"user", 'u', "User for login if not current user.", &current_user,
&current_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
- {"verbose", 'v', "Print info about the various stages.", 0, 0, 0, GET_NO_ARG,
- NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"verbose", 'v', "Print info about the various stages; Using it 3 times will print out all CHECK, RENAME and ALTER TABLE during the check phase.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
@@ -632,8 +632,10 @@ static int process_all_tables_in_db(char *database)
} /* process_all_tables_in_db */
-static int run_query(const char *query)
+static int run_query(const char *query, my_bool log_query)
{
+ if (verbose >=3 && log_query)
+ puts(query);
if (mysql_query(sock, query))
{
fprintf(stderr, "Failed to %s\n", query);
@@ -653,7 +655,7 @@ static int fix_table_storage_name(const char *name)
if (strncmp(name, "#mysql50#", 9))
DBUG_RETURN(1);
sprintf(qbuf, "RENAME TABLE `%s` TO `%s`", name, name + 9);
- rc= run_query(qbuf);
+ rc= run_query(qbuf, 1);
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
DBUG_RETURN(rc);
@@ -668,7 +670,7 @@ static int fix_database_storage_name(const char *name)
if (strncmp(name, "#mysql50#", 9))
DBUG_RETURN(1);
sprintf(qbuf, "ALTER DATABASE `%s` UPGRADE DATA DIRECTORY NAME", name);
- rc= run_query(qbuf);
+ rc= run_query(qbuf, 1);
if (verbose)
printf("%-50s %s\n", name, rc ? "FAILED" : "OK");
DBUG_RETURN(rc);
@@ -687,6 +689,8 @@ static int rebuild_table(char *name)
ptr= strmov(query, "ALTER TABLE ");
ptr= fix_table_name(ptr, name);
ptr= strxmov(ptr, " FORCE", NullS);
+ if (verbose >= 3)
+ puts(query);
if (mysql_real_query(sock, query, (uint)(ptr - query)))
{
fprintf(stderr, "Failed to %s\n", query);
@@ -744,7 +748,7 @@ static int use_db(char *database)
static int disable_binlog()
{
const char *stmt= "SET SQL_LOG_BIN=0";
- return run_query(stmt);
+ return run_query(stmt, 0);
}
static int handle_request_for_tables(char *tables, uint length)
@@ -803,6 +807,8 @@ static int handle_request_for_tables(char *tables, uint length)
ptr= strxmov(ptr, " ", options, NullS);
query_length= (uint) (ptr - query);
}
+ if (verbose >= 3)
+ puts(query);
if (mysql_real_query(sock, query, query_length))
{
sprintf(message, "when executing '%s TABLE ... %s'", op, options);
@@ -1055,7 +1061,7 @@ int main(int argc, char **argv)
for (i = 0; i < tables4rebuild.elements ; i++)
rebuild_table((char*) dynamic_array_ptr(&tables4rebuild, i));
for (i = 0; i < alter_table_cmds.elements ; i++)
- run_query((char*) dynamic_array_ptr(&alter_table_cmds, i));
+ run_query((char*) dynamic_array_ptr(&alter_table_cmds, i), 1);
}
ret= MY_TEST(first_error);