Commit 65ac881c authored by Michael Widenius's avatar Michael Widenius

If one uses 3 --verbose options to mysql_upgrade or mysqlcheck one will now...

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
parent 258ecf55
......@@ -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" );
......
......@@ -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);
......
Run mysql_upgrade once
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -30,8 +30,9 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/3: Fixing table and database names
Phase 3/3: Checking and upgrading tables
Phase 2/4: Running 'mysql_fix_privilege_tables'...
Phase 3/4: Fixing table and database names
Phase 4/4: Checking and upgrading tables
Processing databases
information_schema
mtr
......@@ -43,7 +44,7 @@ OK
Run it again - should say already completed
This installation of MySQL is already upgraded to VERSION, use --force if you still need to run mysql_upgrade
Force should run it regardless of wether it's been run before
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -74,8 +75,9 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/3: Fixing table and database names
Phase 3/3: Checking and upgrading tables
Phase 2/4: Running 'mysql_fix_privilege_tables'...
Phase 3/4: Fixing table and database names
Phase 4/4: Checking and upgrading tables
Processing databases
information_schema
mtr
......@@ -87,7 +89,7 @@ OK
CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila';
GRANT ALL ON *.* TO mysqltest1@'%';
Run mysql_upgrade with password protected account
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -118,8 +120,9 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/3: Fixing table and database names
Phase 3/3: Checking and upgrading tables
Phase 2/4: Running 'mysql_fix_privilege_tables'...
Phase 3/4: Fixing table and database names
Phase 4/4: Checking and upgrading tables
Processing databases
information_schema
mtr
......@@ -136,7 +139,7 @@ Run mysql_upgrade with a non existing server socket
mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errno) when trying to connect
FATAL ERROR: Upgrade failed
set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE';
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -167,8 +170,9 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/3: Fixing table and database names
Phase 3/3: Checking and upgrading tables
Phase 2/4: Running 'mysql_fix_privilege_tables'...
Phase 3/4: Fixing table and database names
Phase 4/4: Checking and upgrading tables
Processing databases
information_schema
mtr
......@@ -186,7 +190,7 @@ CREATE PROCEDURE testproc() BEGIN END;
UPDATE mysql.proc SET character_set_client = NULL WHERE name LIKE 'testproc';
UPDATE mysql.proc SET collation_connection = NULL WHERE name LIKE 'testproc';
UPDATE mysql.proc SET db_collation = NULL WHERE name LIKE 'testproc';
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -217,8 +221,9 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/3: Fixing table and database names
Phase 3/3: Checking and upgrading tables
Phase 2/4: Running 'mysql_fix_privilege_tables'...
Phase 3/4: Fixing table and database names
Phase 4/4: Checking and upgrading tables
Processing databases
information_schema
mtr
......@@ -239,7 +244,7 @@ WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been
GRANT USAGE ON *.* TO 'user3'@'%';
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%';
Run mysql_upgrade with all privileges on a user
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -270,8 +275,9 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/3: Fixing table and database names
Phase 3/3: Checking and upgrading tables
Phase 2/4: Running 'mysql_fix_privilege_tables'...
Phase 3/4: Fixing table and database names
Phase 4/4: Checking and upgrading tables
Processing databases
information_schema
mtr
......@@ -287,7 +293,7 @@ GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'
DROP USER 'user3'@'%';
End of 5.1 tests
The --upgrade-system-tables option was used, user tables won't be touched.
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -318,6 +324,7 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/4: Running 'mysql_fix_privilege_tables'...
OK
#
# Bug#11827359 60223: MYSQL_UPGRADE PROBLEM WITH OPTION
......@@ -325,7 +332,7 @@ OK
#
# Droping the previously created mysql_upgrade_info file..
# Running mysql_upgrade with --skip-write-binlog..
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -356,8 +363,9 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/3: Fixing table and database names
Phase 3/3: Checking and upgrading tables
Phase 2/4: Running 'mysql_fix_privilege_tables'...
Phase 3/4: Fixing table and database names
Phase 4/4: Checking and upgrading tables
Processing databases
information_schema
mtr
......@@ -378,7 +386,7 @@ GRANT INSERT ON mysql.user TO very_long_user_name_number_2;
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_1;
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_2;
CREATE PROCEDURE test.pr() BEGIN END;
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -409,8 +417,9 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/3: Fixing table and database names
Phase 3/3: Checking and upgrading tables
Phase 2/4: Running 'mysql_fix_privilege_tables'...
Phase 3/4: Fixing table and database names
Phase 4/4: Checking and upgrading tables
Processing databases
information_schema
mtr
......
The --upgrade-system-tables option was used, user tables won't be touched.
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -42,4 +42,5 @@ error : Corrupt
mysql.innodb_table_stats
Error : Unknown storage engine 'InnoDB'
error : Corrupt
Phase 2/4: Running 'mysql_fix_privilege_tables'...
OK
#
# Bug#55672 mysql_upgrade dies with internal error
#
Phase 1/3: Running 'mysql_fix_privilege_tables'...
Phase 1/4: Checking mysql database
Processing databases
mysql
mysql.column_stats OK
......@@ -32,8 +32,9 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/3: Fixing table and database names
Phase 3/3: Checking and upgrading tables
Phase 2/4: Running 'mysql_fix_privilege_tables'...
Phase 3/4: Fixing table and database names
Phase 4/4: Checking and upgrading tables
Processing databases
information_schema
mtr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment