summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShishir Jaiswal <shishir.j.jaiswal@oracle.com>2015-10-29 13:35:32 +0530
committerShishir Jaiswal <shishir.j.jaiswal@oracle.com>2015-10-29 13:35:32 +0530
commit1942506b82897e498493cc3ec274a2b402c4d105 (patch)
treefe010c575f6c436a997c5076ac36c0e151a62faa
parenta60740607c9581ed2bf92bdd087139ea8d872484 (diff)
downloadmariadb-git-1942506b82897e498493cc3ec274a2b402c4d105.tar.gz
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.
-rw-r--r--client/mysql_upgrade.c36
-rw-r--r--mysql-test/r/mysql_upgrade.result8
-rw-r--r--mysql-test/t/mysql_upgrade.test9
3 files changed, 40 insertions, 13 deletions
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 33f9f030c1e..fcbde2653e8 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -1,5 +1,5 @@
/*
- 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
it under the terms of the GNU General Public License as published by
@@ -862,10 +862,17 @@ static int check_version_match(void)
if (init_dynamic_string(&ds_version, NULL, NAME_CHAR_LEN, NAME_CHAR_LEN))
die("Out of memory");
- if (run_query("show variables like 'version'",
- &ds_version, FALSE) ||
- extract_variable_from_show(&ds_version, version_str))
+
+ if (run_query("show variables like 'version'", &ds_version, FALSE))
{
+ 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);
return 1; /* Query failed */
}
@@ -955,15 +962,20 @@ int main(int argc, char **argv)
/*
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
*/
- if ((!opt_systables_only &&
- (run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) ||
- run_sql_fix_privilege_tables())
+ if (!opt_systables_only)
{
- /*
- The upgrade failed to complete in some way or another,
- significant error message should have been printed to the screen
- */
- die("Upgrade failed" );
+ if (run_mysqlcheck_fixnames())
+ die("Error during call to mysql_check for fixing the db/tables names.");
+
+ if (run_mysqlcheck_upgrade())
+ 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");
diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result
index 8ce3f426375..6ba874f327a 100644
--- a/mysql-test/r/mysql_upgrade.result
+++ b/mysql-test/r/mysql_upgrade.result
@@ -86,7 +86,7 @@ mysql.user OK
DROP USER mysqltest1@'%';
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
+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';
mtr.global_suppressions OK
mtr.test_suppressions OK
@@ -226,4 +226,10 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type 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
diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test
index c52a328c28b..faf7ed21a28 100644
--- a/mysql-test/t/mysql_upgrade.test
+++ b/mysql-test/t/mysql_upgrade.test
@@ -124,4 +124,13 @@ let $MYSQLD_DATADIR= `select @@datadir`;
# so the following command should never fail.
--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