Skip to content

Commit 49c853f

Browse files
committed
Merge branch '5.5' into 10.0
2 parents ae18a28 + 4c87f72 commit 49c853f

File tree

179 files changed

+5739
-1214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+5739
-1214
lines changed

client/mysql_upgrade.c

Lines changed: 99 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2006, 2013, Oracle and/or its affiliates.
3-
Copyright (c) 2010, 2013, Monty Program Ab.
3+
Copyright (c) 2010, 2015, MariaDB
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -36,6 +36,8 @@
3636
# endif
3737
#endif
3838

39+
static int phase = 0;
40+
static int phases_total = 6;
3941
static char mysql_path[FN_REFLEN];
4042
static char mysqlcheck_path[FN_REFLEN];
4143

@@ -45,6 +47,8 @@ static my_bool opt_not_used, opt_silent;
4547
static uint my_end_arg= 0;
4648
static char *opt_user= (char*)"root";
4749

50+
static my_bool upgrade_from_mysql;
51+
4852
static DYNAMIC_STRING ds_args;
4953
static DYNAMIC_STRING conn_args;
5054

@@ -206,12 +210,12 @@ static void die(const char *fmt, ...)
206210
}
207211

208212

209-
static int verbose(const char *fmt, ...)
213+
static void verbose(const char *fmt, ...)
210214
{
211215
va_list args;
212216

213217
if (opt_silent)
214-
return 0;
218+
return;
215219

216220
/* Print the verbose message */
217221
va_start(args, fmt);
@@ -222,7 +226,6 @@ static int verbose(const char *fmt, ...)
222226
fflush(stdout);
223227
}
224228
va_end(args);
225-
return 0;
226229
}
227230

228231

@@ -740,10 +743,21 @@ static void print_conn_args(const char *tool_name)
740743
in the server using "mysqlcheck --check-upgrade .."
741744
*/
742745

743-
static int run_mysqlcheck_upgrade(const char *arg1, const char *arg2)
746+
static int run_mysqlcheck_upgrade(my_bool mysql_db_only)
744747
{
748+
const char *what= mysql_db_only ? "mysql database" : "tables";
749+
const char *arg1= mysql_db_only ? "--databases" : "--all-databases";
750+
const char *arg2= mysql_db_only ? "mysql" : "--skip-database=mysql";
751+
int retch;
752+
if (opt_systables_only && !mysql_db_only)
753+
{
754+
verbose("Phase %d/%d: Checking and upgrading %s... Skipped",
755+
++phase, phases_total, what);
756+
return 0;
757+
}
758+
verbose("Phase %d/%d: Checking and upgrading %s", ++phase, phases_total, what);
745759
print_conn_args("mysqlcheck");
746-
return run_tool(mysqlcheck_path,
760+
retch= run_tool(mysqlcheck_path,
747761
NULL, /* Send output from mysqlcheck directly to screen */
748762
"--no-defaults",
749763
ds_args.str,
@@ -757,12 +771,77 @@ static int run_mysqlcheck_upgrade(const char *arg1, const char *arg2)
757771
arg1, arg2,
758772
"2>&1",
759773
NULL);
774+
return retch;
760775
}
761776

777+
#define EVENTS_STRUCT_LEN 7000
778+
779+
static my_bool is_mysql()
780+
{
781+
my_bool ret= TRUE;
782+
DYNAMIC_STRING ds_events_struct;
783+
784+
if (init_dynamic_string(&ds_events_struct, NULL,
785+
EVENTS_STRUCT_LEN, EVENTS_STRUCT_LEN))
786+
die("Out of memory");
787+
788+
if (run_query("show create table mysql.event",
789+
&ds_events_struct, FALSE) ||
790+
strstr(ds_events_struct.str, "IGNORE_BAD_TABLE_OPTIONS") != NULL)
791+
ret= FALSE;
792+
else
793+
verbose("MySQL upgrade detected");
794+
795+
dynstr_free(&ds_events_struct);
796+
return(ret);
797+
}
798+
799+
static int run_mysqlcheck_views(void)
800+
{
801+
const char *upgrade_views="--process-views=YES";
802+
if (upgrade_from_mysql)
803+
{
804+
/*
805+
this has to ignore opt_systables_only, because upgrade_from_mysql
806+
is determined by analyzing systables. if we honor opt_systables_only
807+
here, views won't be fixed by subsequent mysql_upgrade runs
808+
*/
809+
upgrade_views="--process-views=UPGRADE_FROM_MYSQL";
810+
verbose("Phase %d/%d: Fixing views from mysql", ++phase, phases_total);
811+
}
812+
else if (opt_systables_only)
813+
{
814+
verbose("Phase %d/%d: Fixing views... Skipped", ++phase, phases_total);
815+
return 0;
816+
}
817+
else
818+
verbose("Phase %d/%d: Fixing views", ++phase, phases_total);
819+
820+
print_conn_args("mysqlcheck");
821+
return run_tool(mysqlcheck_path,
822+
NULL, /* Send output from mysqlcheck directly to screen */
823+
"--no-defaults",
824+
ds_args.str,
825+
"--all-databases", "--repair",
826+
upgrade_views,
827+
"--skip-process-tables",
828+
opt_verbose ? "--verbose": "",
829+
opt_silent ? "--silent": "",
830+
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
831+
"2>&1",
832+
NULL);
833+
}
762834

763835
static int run_mysqlcheck_fixnames(void)
764836
{
765-
verbose("Phase 3/5: Fixing table and database names");
837+
if (opt_systables_only)
838+
{
839+
verbose("Phase %d/%d: Fixing table and database names ... Skipped",
840+
++phase, phases_total);
841+
return 0;
842+
}
843+
verbose("Phase %d/%d: Fixing table and database names",
844+
++phase, phases_total);
766845
print_conn_args("mysqlcheck");
767846
return run_tool(mysqlcheck_path,
768847
NULL, /* Send output from mysqlcheck directly to screen */
@@ -850,6 +929,9 @@ static int run_sql_fix_privilege_tables(void)
850929
if (init_dynamic_string(&ds_result, "", 512, 512))
851930
die("Out of memory");
852931

932+
verbose("Phase %d/%d: Running 'mysql_fix_privilege_tables'",
933+
++phase, phases_total);
934+
853935
/*
854936
Individual queries can not be executed independently by invoking
855937
a forked mysql client, because the script uses session variables
@@ -1019,23 +1101,19 @@ int main(int argc, char **argv)
10191101
if (opt_version_check && check_version_match())
10201102
die("Upgrade failed");
10211103

1104+
upgrade_from_mysql= is_mysql();
1105+
10221106
/*
10231107
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
10241108
*/
1025-
verbose("Phase 1/5: Checking mysql database");
1026-
if (run_mysqlcheck_upgrade("--databases", "mysql"))
1027-
die("Upgrade failed" );
1028-
verbose("Phase 2/5: Running 'mysql_fix_privilege_tables'...");
1029-
if (run_sql_fix_privilege_tables())
1109+
if (run_mysqlcheck_upgrade(TRUE) ||
1110+
run_mysqlcheck_views() ||
1111+
run_sql_fix_privilege_tables() ||
1112+
run_mysqlcheck_fixnames() ||
1113+
run_mysqlcheck_upgrade(FALSE))
10301114
die("Upgrade failed" );
10311115

1032-
if (!opt_systables_only &&
1033-
(run_mysqlcheck_fixnames() ||
1034-
verbose("Phase 4/5: Checking and upgrading tables") ||
1035-
run_mysqlcheck_upgrade("--all-databases","--skip-database=mysql")))
1036-
die("Upgrade failed" );
1037-
1038-
verbose("Phase 5/5: Running 'FLUSH PRIVILEGES'...");
1116+
verbose("Phase %d/%d: Running 'FLUSH PRIVILEGES'", ++phase, phases_total);
10391117
if (run_query("FLUSH PRIVILEGES", NULL, TRUE))
10401118
die("Upgrade failed" );
10411119

@@ -1044,6 +1122,8 @@ int main(int argc, char **argv)
10441122
/* Create a file indicating upgrade has been performed */
10451123
create_mysql_upgrade_info_file();
10461124

1125+
DBUG_ASSERT(phase == phases_total);
1126+
10471127
free_used_memory();
10481128
my_end(my_end_arg);
10491129
exit(0);

client/mysqladmin.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2000, 2014, Oracle and/or its affiliates.
3-
Copyright (c) 2010, 2014, Monty Program Ab.
3+
Copyright (c) 2010, 2015, MariaDB
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -1249,6 +1249,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
12491249
static char **mask_password(int argc, char ***argv)
12501250
{
12511251
char **temp_argv;
1252+
if (!argc)
1253+
return NULL;
1254+
12521255
temp_argv= (char **)(my_malloc(sizeof(char *) * argc, MYF(MY_WME)));
12531256
argc--;
12541257
while (argc > 0)

0 commit comments

Comments
 (0)