Skip to content

Commit 9ecb4f4

Browse files
author
Shishir Jaiswal
committed
Merge branch 'mysql-5.5' into mysql-5.6
2 parents a67ec5f + 1942506 commit 9ecb4f4

3 files changed

Lines changed: 58 additions & 16 deletions

File tree

client/mysql_upgrade.c

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -763,7 +763,7 @@ static int run_mysqlcheck_mysql_db_upgrade(void)
763763
}
764764

765765

766-
/** performs the same operation as mysqlcheck_upgrade, but on the mysql db */
766+
/** performs the same operation as mysqlcheck_fixnames, but on the mysql db */
767767
static int run_mysqlcheck_mysql_db_fixnames(void)
768768
{
769769
print_conn_args("mysqlcheck");
@@ -929,10 +929,16 @@ static int check_version_match(void)
929929
if (init_dynamic_string(&ds_version, NULL, NAME_CHAR_LEN, NAME_CHAR_LEN))
930930
die("Out of memory");
931931

932-
if (run_query("show variables like 'version'",
933-
&ds_version, FALSE) ||
934-
extract_variable_from_show(&ds_version, version_str))
932+
if (run_query("show variables like 'version'", &ds_version, FALSE))
933+
{
934+
fprintf(stderr, "Error: Failed while fetching Server version! Could be"
935+
" due to unauthorized access.\n");
936+
dynstr_free(&ds_version);
937+
return 1; /* Query failed */
938+
}
939+
if (extract_variable_from_show(&ds_version, version_str))
935940
{
941+
fprintf(stderr, "Error: Failed while extracting Server version!\n");
936942
dynstr_free(&ds_version);
937943
return 1; /* Query failed */
938944
}
@@ -1027,17 +1033,37 @@ int main(int argc, char **argv)
10271033
Then do the upgrade.
10281034
And then run mysqlcheck on all tables.
10291035
*/
1030-
if ((!opt_systables_only &&
1031-
(run_mysqlcheck_mysql_db_fixnames() || run_mysqlcheck_mysql_db_upgrade())) ||
1032-
run_sql_fix_privilege_tables() ||
1033-
(!opt_systables_only &&
1034-
(run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())))
1036+
if (!opt_systables_only)
10351037
{
1036-
/*
1037-
The upgrade failed to complete in some way or another,
1038-
significant error message should have been printed to the screen
1039-
*/
1040-
die("Upgrade failed" );
1038+
if (run_mysqlcheck_mysql_db_fixnames())
1039+
{
1040+
die("Error during call to mysql_check for fixing the db/tables names on "
1041+
"mysql db");
1042+
}
1043+
if (run_mysqlcheck_mysql_db_upgrade())
1044+
{
1045+
die("Error during call to mysql_check for upgrading the tables names on "
1046+
"mysql db");
1047+
}
1048+
}
1049+
if (run_sql_fix_privilege_tables())
1050+
{
1051+
/* Specific error msg (if present) would be printed in the function call
1052+
* above */
1053+
die("Upgrade failed");
1054+
}
1055+
if (!opt_systables_only)
1056+
{
1057+
if (run_mysqlcheck_fixnames())
1058+
{
1059+
die("Error during call to mysql_check for fixing the db/tables names on "
1060+
"all db(s) except mysql");
1061+
}
1062+
if (run_mysqlcheck_upgrade())
1063+
{
1064+
die("Error during call to mysql_check for upgrading the tables names on "
1065+
"all db(s) except mysql");
1066+
}
10411067
}
10421068
verbose("OK");
10431069

mysql-test/r/mysql_upgrade.result

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ DROP USER mysqltest1@'%';
115115
Run mysql_upgrade with a non existing server socket
116116
Warning: Using a password on the command line interface can be insecure.
117117
mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errno) when trying to connect
118-
FATAL ERROR: Upgrade failed
118+
FATAL ERROR: Error during call to mysql_check for fixing the db/tables names on mysql db
119119
set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE';
120120
Warnings:
121121
Warning 1681 'NO_ZERO_DATE' is deprecated and will be removed in a future release.
@@ -502,5 +502,12 @@ DROP USER B20023823_empty@localhost;
502502
DROP USER B20023823_def@localhost;
503503
DROP USER B20023823_41hash@localhost;
504504
DROP USER B20023823_16hash@localhost;
505+
#
506+
# Bug #21489398: MYSQL_UPGRADE: FATAL ERROR: UPGRADE FAILED - IMPROVE ERROR
507+
#
508+
Run mysql_upgrade with unauthorized access
509+
Warning: Using a password on the command line interface can be insecure.
510+
Error: Failed while fetching Server version! Could be due to unauthorized access.
511+
FATAL ERROR: Upgrade failed
505512

506513
End of tests

mysql-test/t/mysql_upgrade.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,14 @@ DROP USER B20023823_def@localhost;
202202
DROP USER B20023823_41hash@localhost;
203203
DROP USER B20023823_16hash@localhost;
204204

205+
206+
--echo #
207+
--echo # Bug #21489398: MYSQL_UPGRADE: FATAL ERROR: UPGRADE FAILED - IMPROVE ERROR
208+
--echo #
209+
210+
--echo Run mysql_upgrade with unauthorized access
211+
--error 1
212+
--exec $MYSQL_UPGRADE --skip-verbose --user=root --password=wrong_password 2>&1
213+
205214
--echo
206215
--echo End of tests

0 commit comments

Comments
 (0)