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.
This commit is contained in:
parent
28b173134e
commit
fc277cd4ba
@ -793,6 +793,7 @@ static int run_mysqlcheck_views(void)
|
|||||||
ds_args.str,
|
ds_args.str,
|
||||||
"--all-databases",
|
"--all-databases",
|
||||||
"--fix-view-algorithm",
|
"--fix-view-algorithm",
|
||||||
|
"--skip-fix-tables",
|
||||||
opt_verbose ? "--verbose": "",
|
opt_verbose ? "--verbose": "",
|
||||||
opt_silent ? "--silent": "",
|
opt_silent ? "--silent": "",
|
||||||
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
|
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,
|
opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0,
|
||||||
tty_password= 0, opt_frm= 0, debug_info_flag= 0, debug_check_flag= 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_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 my_bool opt_write_binlog= 1, opt_flush_tables= 0;
|
||||||
static uint verbose = 0, opt_mysql_port=0;
|
static uint verbose = 0, opt_mysql_port=0;
|
||||||
static int my_end_arg;
|
static int my_end_arg;
|
||||||
@ -200,6 +200,9 @@ static struct my_option my_long_options[] =
|
|||||||
{"fix-view-algorithm", 'y',
|
{"fix-view-algorithm", 'y',
|
||||||
"Fix view algorithm view field if it is not new MariaDB view.",
|
"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},
|
&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}
|
{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)))
|
if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
|
||||||
exit(ho_error);
|
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 (opt_fix_view_algorithm && what_to_do!=DO_REPAIR)
|
||||||
{
|
{
|
||||||
if (!what_to_do)
|
if (!what_to_do)
|
||||||
@ -641,9 +650,10 @@ static int process_all_tables_in_db(char *database)
|
|||||||
|
|
||||||
while ((row = mysql_fetch_row(res)))
|
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;
|
tot_views_length+= fixed_name_length(row[0]) + 2;
|
||||||
else
|
else if (opt_fix_tables)
|
||||||
tot_length+= fixed_name_length(row[0]) + 2;
|
tot_length+= fixed_name_length(row[0]) + 2;
|
||||||
}
|
}
|
||||||
mysql_data_seek(res, 0);
|
mysql_data_seek(res, 0);
|
||||||
@ -671,6 +681,8 @@ static int process_all_tables_in_db(char *database)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!opt_fix_tables)
|
||||||
|
continue;
|
||||||
end= fix_table_name(end, row[0]);
|
end= fix_table_name(end, row[0]);
|
||||||
*end++= ',';
|
*end++= ',';
|
||||||
}
|
}
|
||||||
@ -696,7 +708,11 @@ static int process_all_tables_in_db(char *database)
|
|||||||
view= TRUE;
|
view= TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (!opt_fix_tables)
|
||||||
|
continue;
|
||||||
view= FALSE;
|
view= FALSE;
|
||||||
|
}
|
||||||
if (system_database &&
|
if (system_database &&
|
||||||
(!strcmp(row[0], "general_log") ||
|
(!strcmp(row[0], "general_log") ||
|
||||||
!strcmp(row[0], "slow_log")))
|
!strcmp(row[0], "slow_log")))
|
||||||
|
@ -16,13 +16,13 @@ show create view v4;
|
|||||||
View Create View character_set_client collation_connection
|
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
|
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
|
MySQL upgrade detected
|
||||||
Phase 0: Fixing views
|
Phase 1/4: Fixing views
|
||||||
test.v1 view is repaired
|
test.v1 OK
|
||||||
test.v2 view is repaired
|
test.v2 OK
|
||||||
test.v3 view is repaired
|
test.v3 OK
|
||||||
test.v4 OK
|
test.v4 OK
|
||||||
Phase 1/3: Fixing table and database names
|
Phase 2/4: Fixing table and database names
|
||||||
Phase 2/3: Checking and upgrading tables
|
Phase 3/4: Checking and upgrading tables
|
||||||
Processing databases
|
Processing databases
|
||||||
information_schema
|
information_schema
|
||||||
mtr
|
mtr
|
||||||
@ -55,7 +55,7 @@ mysql.user OK
|
|||||||
performance_schema
|
performance_schema
|
||||||
test
|
test
|
||||||
test.t1 OK
|
test.t1 OK
|
||||||
Phase 3/3: Running 'mysql_fix_privilege_tables'...
|
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||||
OK
|
OK
|
||||||
show create view v1;
|
show create view v1;
|
||||||
View Create View character_set_client collation_connection
|
View Create View character_set_client collation_connection
|
||||||
|
Loading…
x
Reference in New Issue
Block a user