Skip to content
Permalink
Browse files

Add --fix-tables option to mysql-check

Mainly so that mysql_upgrade.c can use --skip-fix-tables

Correct mysql_upgrade_view test output based on phases and
previous error message changes.
  • Loading branch information...
grooverdan committed Apr 13, 2015
1 parent 28b1731 commit fc277cd4ba6c506a6f6c71e04c462b24a3fcfb26
Showing with 27 additions and 10 deletions.
  1. +1 −0 client/mysql_upgrade.c
  2. +19 −3 client/mysqlcheck.c
  3. +7 −7 mysql-test/r/mysql_upgrade_view.result
@@ -793,6 +793,7 @@ static int run_mysqlcheck_views(void)
ds_args.str,
"--all-databases",
"--fix-view-algorithm",
"--skip-fix-tables",
opt_verbose ? "--verbose": "",
opt_silent ? "--silent": "",
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
@@ -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_view_algorithm= 0, 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;
@@ -200,6 +200,9 @@ static struct my_option my_long_options[] =
{"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},
{"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},
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};

@@ -369,6 +372,12 @@ 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))
{
fprintf(stderr, "Error: %s doesn't support repair command without either fix-view-algorithm or fix-tables specified.\n",
my_progname);
exit(1);
}
if (opt_fix_view_algorithm && what_to_do!=DO_REPAIR)
{
if (!what_to_do)
@@ -641,9 +650,10 @@ static int process_all_tables_in_db(char *database)

while ((row = mysql_fetch_row(res)))
{
if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0))
if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0) &&
opt_fix_view_algorithm)
tot_views_length+= fixed_name_length(row[0]) + 2;
else
else if (opt_fix_tables)
tot_length+= fixed_name_length(row[0]) + 2;
}
mysql_data_seek(res, 0);
@@ -671,6 +681,8 @@ static int process_all_tables_in_db(char *database)
}
else
{
if (!opt_fix_tables)
continue;
end= fix_table_name(end, row[0]);
*end++= ',';
}
@@ -696,7 +708,11 @@ static int process_all_tables_in_db(char *database)
view= TRUE;
}
else
{
if (!opt_fix_tables)
continue;
view= FALSE;
}
if (system_database &&
(!strcmp(row[0], "general_log") ||
!strcmp(row[0], "slow_log")))
@@ -16,13 +16,13 @@ show create view v4;
View Create View character_set_client collation_connection
v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci
MySQL upgrade detected
Phase 0: Fixing views
test.v1 view is repaired
test.v2 view is repaired
test.v3 view is repaired
Phase 1/4: Fixing views
test.v1 OK
test.v2 OK
test.v3 OK
test.v4 OK
Phase 1/3: Fixing table and database names
Phase 2/3: Checking and upgrading tables
Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -55,7 +55,7 @@ mysql.user OK
performance_schema
test
test.t1 OK
Phase 3/3: Running 'mysql_fix_privilege_tables'...
Phase 4/4: Running 'mysql_fix_privilege_tables'...
OK
show create view v1;
View Create View character_set_client collation_connection

0 comments on commit fc277cd

Please sign in to comment.
You can’t perform that action at this time.