Commit 1942506b authored by Shishir Jaiswal's avatar Shishir Jaiswal

DESCRIPTION

===========
When doing an upgrade, you execute mysql_upgrade. If
mysql_upgrade fails to connect or it connects with a user
without the proper privileges, it will return the error:

    FATAL ERROR: Upgrade failed

which is not very informative.

ANALYSIS
========

In main() and check_version_match(), the condition for
errors are clubbed together and throw the same error msg.
The functions need to be splitted up and the corresponding
error msgs have to be displayed.

FIX
===
Splitted the functions and added the specific error msg.
parent a6074060
/* /*
Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -862,10 +862,17 @@ static int check_version_match(void) ...@@ -862,10 +862,17 @@ static int check_version_match(void)
if (init_dynamic_string(&ds_version, NULL, NAME_CHAR_LEN, NAME_CHAR_LEN)) if (init_dynamic_string(&ds_version, NULL, NAME_CHAR_LEN, NAME_CHAR_LEN))
die("Out of memory"); die("Out of memory");
if (run_query("show variables like 'version'",
&ds_version, FALSE) || if (run_query("show variables like 'version'", &ds_version, FALSE))
extract_variable_from_show(&ds_version, version_str))
{ {
fprintf(stderr, "Error: Failed while fetching Server version! Could be"
" due to unauthorized access.\n");
dynstr_free(&ds_version);
return 1; /* Query failed */
}
if (extract_variable_from_show(&ds_version, version_str))
{
fprintf(stderr, "Error: Failed while extracting Server version!\n");
dynstr_free(&ds_version); dynstr_free(&ds_version);
return 1; /* Query failed */ return 1; /* Query failed */
} }
...@@ -955,15 +962,20 @@ int main(int argc, char **argv) ...@@ -955,15 +962,20 @@ int main(int argc, char **argv)
/* /*
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql" Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
*/ */
if ((!opt_systables_only && if (!opt_systables_only)
(run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) ||
run_sql_fix_privilege_tables())
{ {
/* if (run_mysqlcheck_fixnames())
The upgrade failed to complete in some way or another, die("Error during call to mysql_check for fixing the db/tables names.");
significant error message should have been printed to the screen
*/ if (run_mysqlcheck_upgrade())
die("Upgrade failed" ); die("Error during call to mysql_check for upgrading the tables names.");
}
if (run_sql_fix_privilege_tables())
{
/* Specific error msg (if present) would be printed in the function call
* above */
die("Upgrade failed");
} }
verbose("OK"); verbose("OK");
......
...@@ -86,7 +86,7 @@ mysql.user OK ...@@ -86,7 +86,7 @@ mysql.user OK
DROP USER mysqltest1@'%'; DROP USER mysqltest1@'%';
Run mysql_upgrade with a non existing server socket 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 mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errno) when trying to connect
FATAL ERROR: Upgrade failed FATAL ERROR: Error during call to mysql_check for fixing the db/tables names.
set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE'; set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE';
mtr.global_suppressions OK mtr.global_suppressions OK
mtr.test_suppressions OK mtr.test_suppressions OK
...@@ -226,4 +226,10 @@ mysql.time_zone_name OK ...@@ -226,4 +226,10 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK mysql.time_zone_transition OK
mysql.time_zone_transition_type OK mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
#
# Bug #21489398: MYSQL_UPGRADE: FATAL ERROR: UPGRADE FAILED - IMPROVE ERROR
#
Run mysql_upgrade with unauthorized access
Error: Failed while fetching Server version! Could be due to unauthorized access.
FATAL ERROR: Upgrade failed
End of tests End of tests
...@@ -124,4 +124,13 @@ let $MYSQLD_DATADIR= `select @@datadir`; ...@@ -124,4 +124,13 @@ let $MYSQLD_DATADIR= `select @@datadir`;
# so the following command should never fail. # so the following command should never fail.
--remove_file $MYSQLD_DATADIR/mysql_upgrade_info --remove_file $MYSQLD_DATADIR/mysql_upgrade_info
--echo #
--echo # Bug #21489398: MYSQL_UPGRADE: FATAL ERROR: UPGRADE FAILED - IMPROVE ERROR
--echo #
--echo Run mysql_upgrade with unauthorized access
--error 1
--exec $MYSQL_UPGRADE --skip-verbose --user=root --password=wrong_password 2>&1
--echo End of tests --echo End of tests
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