diff options
author | Daniel Black <grooverdan@users.sourceforge.net> | 2015-04-14 12:43:50 +1000 |
---|---|---|
committer | Daniel Black <grooverdan@users.sourceforge.net> | 2015-04-14 12:43:50 +1000 |
commit | 97e0aeaf72cde117b8d9551f68d407fa13aafbe1 (patch) | |
tree | 8ca6fd60518a70aebeb24ba5dd32368c760ced54 /client | |
parent | 808608cb3f4e10ba81679c94b2a299a32cf5e448 (diff) | |
download | mariadb-git-97e0aeaf72cde117b8d9551f68d407fa13aafbe1.tar.gz |
mysqlcheck fix-view-algorithm -> upgrade-views
Change mysqlcheck option to upgrade-views={NO,YES,FROM_MYSQL}
mysql_upgrade now runs upgrade-views=yes to perform a checksum of all
views and add mariadb-version by default. upgrade-views=from_mysql if
MySQL is detected as teh origin version.
Diffstat (limited to 'client')
-rw-r--r-- | client/client_priv.h | 1 | ||||
-rw-r--r-- | client/mysql_upgrade.c | 13 | ||||
-rw-r--r-- | client/mysqlcheck.c | 51 |
3 files changed, 48 insertions, 17 deletions
diff --git a/client/client_priv.h b/client/client_priv.h index e206804d057..a66c3883654 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -79,6 +79,7 @@ enum options_client OPT_SLAP_COMMIT, OPT_SLAP_DETACH, OPT_SLAP_NO_DROP, + OPT_UPGRADE_VIEWS, OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID, OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT, OPT_AUTO_VERTICAL_OUTPUT, diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 8fd28f2ab41..98021dda377 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -784,19 +784,22 @@ static my_bool is_mysql() static int run_mysqlcheck_views(void) { - if (!is_mysql()) + const char *upgrade_views="--upgrade-views=YES"; + if (is_mysql()) { - verbose("Phase %d/%d: Fixing views - skipped - not required", phase++, phases_total); - return 0; + upgrade_views="--upgrade-views=FROM_MYSQL"; + verbose("Phase %d/%d: Fixing views from mysql", phase++, phases_total); } - verbose("Phase %d/%d: Fixing views", phase++, phases_total); + 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", - "--fix-view-algorithm", + upgrade_views, "--skip-fix-tables", opt_verbose ? "--verbose": "", opt_silent ? "--silent": "", diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 2f67452a2d5..dfc743d5493 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -43,7 +43,7 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0, opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0, tty_password= 0, opt_frm= 0, debug_info_flag= 0, debug_check_flag= 0, opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0, - opt_fix_view_algorithm= 0, opt_fix_tables= 1; + opt_fix_tables= 1; static my_bool opt_write_binlog= 1, opt_flush_tables= 0; static uint verbose = 0, opt_mysql_port=0; static int my_end_arg; @@ -58,6 +58,20 @@ static uint opt_protocol=0; enum operations { DO_CHECK=1, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE }; +typedef enum { + UPGRADE_VIEWS_NO=0, + UPGRADE_VIEWS_YES=1, + UPGRADE_VIEWS_FROM_MYSQL=2, + UPGRADE_VIEWS_COUNT +} enum_upgrade_views; +const char *upgrade_views_opts[]= +{"NO", "YES", "FROM_MYSQL", NullS}; +TYPELIB upgrade_views_typelib= + { array_elements(upgrade_views_opts) - 1, "", + upgrade_views_opts, NULL }; +static enum_upgrade_views opt_upgrade_views= UPGRADE_VIEWS_NO; +static char *opt_upgrade_views_str= NullS; + static struct my_option my_long_options[] = { {"all-databases", 'A', @@ -197,9 +211,12 @@ static struct my_option my_long_options[] = NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"fix-view-algorithm", 'y', - "Fix view algorithm view field if it is not new MariaDB view.", - &opt_fix_view_algorithm, &opt_fix_view_algorithm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"upgrade-views", OPT_UPGRADE_VIEWS, + "Repairs/Upgrades views. 'No' (default) doesn't do anything to views. " + "'Yes' repairs the checksum and adds a MariaDB version to the frm table defination (if missing)." + "Using 'from_mysql' will, when upgrading from MySQL, and ensure the view algorithms are the" + "same as what they where previously.", + &opt_upgrade_views_str, &opt_upgrade_views_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"fix-tables", 'Y', "Fix tables. Usually the default however mysql_upgrade will run with --skip-fix-tables.", &opt_fix_tables, &opt_fix_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, @@ -342,6 +359,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case 'V': print_version(); exit(0); break; + case OPT_UPGRADE_VIEWS: + if (argument == NULL) + opt_upgrade_views= UPGRADE_VIEWS_NO; + else + { + opt_upgrade_views= (enum_upgrade_views) + (find_type_or_exit(argument, &upgrade_views_typelib, opt->name)-1); + } + break; case OPT_MYSQL_PROTOCOL: opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, opt->name); @@ -372,19 +398,19 @@ static int get_options(int *argc, char ***argv) if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option))) exit(ho_error); - if (what_to_do==DO_REPAIR && !(opt_fix_view_algorithm || opt_fix_tables)) + if (what_to_do==DO_REPAIR && !(opt_upgrade_views || opt_fix_tables)) { - fprintf(stderr, "Error: %s doesn't support repair command without either fix-view-algorithm or fix-tables specified.\n", + fprintf(stderr, "Error: %s doesn't support repair command without either upgrade-views or fix-tables specified.\n", my_progname); exit(1); } - if (opt_fix_view_algorithm && what_to_do!=DO_REPAIR) + if (opt_upgrade_views && what_to_do!=DO_REPAIR) { if (!what_to_do) what_to_do= DO_REPAIR; else { - fprintf(stderr, "Error: %s doesn't support non-repair command with option fix-view-algorithm.\n", + fprintf(stderr, "Error: %s doesn't support non-repair command with option upgrade-views.\n", my_progname); exit(1); } @@ -651,7 +677,7 @@ static int process_all_tables_in_db(char *database) while ((row = mysql_fetch_row(res))) { if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0) && - opt_fix_view_algorithm) + opt_upgrade_views) tot_views_length+= fixed_name_length(row[0]) + 2; else if (opt_fix_tables) tot_length+= fixed_name_length(row[0]) + 2; @@ -674,7 +700,7 @@ static int process_all_tables_in_db(char *database) { if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0)) { - if (!opt_fix_view_algorithm) + if (!opt_upgrade_views) continue; views_end= fix_table_name(views_end, row[0]); *views_end++= ','; @@ -703,7 +729,7 @@ static int process_all_tables_in_db(char *database) /* Skip views if we don't perform renaming. */ if ((what_to_do != DO_UPGRADE) && (num_columns == 2) && (strcmp(row[1], "VIEW") == 0)) { - if (!opt_fix_view_algorithm) + if (!opt_upgrade_views) continue; view= TRUE; } @@ -864,7 +890,8 @@ static int handle_request_for_tables(char *tables, uint length, my_bool view) if (opt_quick) end = strmov(end, " QUICK"); if (opt_extended) end = strmov(end, " EXTENDED"); if (opt_frm) end = strmov(end, " USE_FRM"); - if (opt_fix_view_algorithm && view) end = strmov(end, " FROM MYSQL"); + if (opt_upgrade_views==UPGRADE_VIEWS_FROM_MYSQL && view) + end = strmov(end, " FROM MYSQL"); break; case DO_ANALYZE: op= (opt_write_binlog) ? "ANALYZE" : "ANALYZE NO_WRITE_TO_BINLOG"; |