mirror of
https://github.com/MariaDB/server.git
synced 2026-05-14 19:07:15 +02:00
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.
This commit is contained in:
parent
808608cb3f
commit
97e0aeaf72
6 changed files with 65 additions and 30 deletions
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue