diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-04-28 21:11:49 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-04-28 21:11:49 +0200 |
commit | f9c02d7c29e7ddc9fa274e7fe23e5800653660f4 (patch) | |
tree | 817db8c66d7feb63147fe24f8d7474a64660451a /client/mysql_upgrade.c | |
parent | fbab0685a7b7f39db0217823ad90dd47034eae29 (diff) | |
parent | 83ce3529b8b2ba5b8070d12aaecbb6c3e3fcaeca (diff) | |
download | mariadb-git-f9c02d7c29e7ddc9fa274e7fe23e5800653660f4.tar.gz |
Merge branch 'openquery/MDEV-6916-maria-5.5-check_view-r4408' into 5.5
Diffstat (limited to 'client/mysql_upgrade.c')
-rw-r--r-- | client/mysql_upgrade.c | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 5fb3b1317d9..97e2ad92239 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -36,6 +36,8 @@ # endif #endif +static int phase = 1; +static int phases_total = 4; static char mysql_path[FN_REFLEN]; static char mysqlcheck_path[FN_REFLEN]; @@ -738,9 +740,10 @@ static void print_conn_args(const char *tool_name) static int run_mysqlcheck_upgrade(void) { - verbose("Phase 2/3: Checking and upgrading tables"); + int retch; + verbose("Phase %d/%d: Checking and upgrading tables", phase++, phases_total); print_conn_args("mysqlcheck"); - return run_tool(mysqlcheck_path, + retch= run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", ds_args.str, @@ -752,12 +755,67 @@ static int run_mysqlcheck_upgrade(void) opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", "2>&1", NULL); + if (retch || opt_systables_only) + verbose("Phase %d/%d: Skipping 'mysql_fix_privilege_tables'... not needed", phase++, phases_total); + return retch; } +#define EVENTS_STRUCT_LEN 7000 + +static my_bool is_mysql() +{ + my_bool ret= TRUE; + DYNAMIC_STRING ds_events_struct; + + if (init_dynamic_string(&ds_events_struct, NULL, + EVENTS_STRUCT_LEN, EVENTS_STRUCT_LEN)) + die("Out of memory"); + + if (run_query("show create table mysql.event", + &ds_events_struct, FALSE) || + strstr(ds_events_struct.str, "IGNORE_BAD_TABLE_OPTIONS") != NULL) + ret= FALSE; + else + verbose("MySQL upgrade detected"); + + dynstr_free(&ds_events_struct); + return(ret); +} + +static int run_mysqlcheck_views(void) +{ + const char *upgrade_views="--upgrade-views=YES"; + if (is_mysql()) + { + upgrade_views="--upgrade-views=FROM_MYSQL"; + verbose("Phase %d/%d: Fixing views from mysql", phase++, phases_total); + } + else if (opt_systables_only) + { + verbose("Phase %d/%d: Fixing views - skipped - not required", phase++, phases_total); + return 0; + } + else + verbose("Phase %d/%d: Fixing views", phase++, phases_total); + + print_conn_args("mysqlcheck"); + return run_tool(mysqlcheck_path, + NULL, /* Send output from mysqlcheck directly to screen */ + "--no-defaults", + ds_args.str, + "--all-databases", + upgrade_views, + "--skip-fix-tables", + opt_verbose ? "--verbose": "", + opt_silent ? "--silent": "", + opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", + "2>&1", + NULL); +} static int run_mysqlcheck_fixnames(void) { - verbose("Phase 1/3: Fixing table and database names"); + verbose("Phase %d/%d: Fixing table and database names", phase++, phases_total); print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ @@ -838,7 +896,7 @@ static int run_sql_fix_privilege_tables(void) if (init_dynamic_string(&ds_result, "", 512, 512)) die("Out of memory"); - verbose("Phase 3/3: Running 'mysql_fix_privilege_tables'..."); + verbose("Phase %d/%d: Running 'mysql_fix_privilege_tables'...", phase++, phases_total); run_query(mysql_fix_privilege_tables, &ds_result, /* Collect result */ TRUE); @@ -1001,7 +1059,8 @@ 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_mysqlcheck_views() || + run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) || run_sql_fix_privilege_tables()) { /* |