Commit 6f17e233 authored by Sergei Golubchik's avatar Sergei Golubchik

post-merge fixes

parent f9c02d7c
...@@ -79,7 +79,6 @@ enum options_client ...@@ -79,7 +79,6 @@ enum options_client
OPT_SLAP_COMMIT, OPT_SLAP_COMMIT,
OPT_SLAP_DETACH, OPT_SLAP_DETACH,
OPT_SLAP_NO_DROP, OPT_SLAP_NO_DROP,
OPT_UPGRADE_VIEWS,
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT_MODE, OPT_SERVER_ID, 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_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
OPT_AUTO_VERTICAL_OUTPUT, OPT_AUTO_VERTICAL_OUTPUT,
......
...@@ -741,6 +741,12 @@ static void print_conn_args(const char *tool_name) ...@@ -741,6 +741,12 @@ static void print_conn_args(const char *tool_name)
static int run_mysqlcheck_upgrade(void) static int run_mysqlcheck_upgrade(void)
{ {
int retch; int retch;
if (opt_systables_only)
{
verbose("Phase %d/%d: Checking and upgrading tables... Skipped",
phase++, phases_total);
return 0;
}
verbose("Phase %d/%d: Checking and upgrading tables", phase++, phases_total); verbose("Phase %d/%d: Checking and upgrading tables", phase++, phases_total);
print_conn_args("mysqlcheck"); print_conn_args("mysqlcheck");
retch= run_tool(mysqlcheck_path, retch= run_tool(mysqlcheck_path,
...@@ -755,8 +761,6 @@ static int run_mysqlcheck_upgrade(void) ...@@ -755,8 +761,6 @@ static int run_mysqlcheck_upgrade(void)
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog", opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
"2>&1", "2>&1",
NULL); NULL);
if (retch || opt_systables_only)
verbose("Phase %d/%d: Skipping 'mysql_fix_privilege_tables'... not needed", phase++, phases_total);
return retch; return retch;
} }
...@@ -784,15 +788,15 @@ static my_bool is_mysql() ...@@ -784,15 +788,15 @@ static my_bool is_mysql()
static int run_mysqlcheck_views(void) static int run_mysqlcheck_views(void)
{ {
const char *upgrade_views="--upgrade-views=YES"; const char *upgrade_views="--process-views=YES";
if (is_mysql()) if (is_mysql())
{ {
upgrade_views="--upgrade-views=FROM_MYSQL"; upgrade_views="--process-views=UPGRADE_FROM_MYSQL";
verbose("Phase %d/%d: Fixing views from mysql", phase++, phases_total); verbose("Phase %d/%d: Fixing views from mysql", phase++, phases_total);
} }
else if (opt_systables_only) else if (opt_systables_only)
{ {
verbose("Phase %d/%d: Fixing views - skipped - not required", phase++, phases_total); verbose("Phase %d/%d: Fixing views... Skipped", phase++, phases_total);
return 0; return 0;
} }
else else
...@@ -803,9 +807,9 @@ static int run_mysqlcheck_views(void) ...@@ -803,9 +807,9 @@ static int run_mysqlcheck_views(void)
NULL, /* Send output from mysqlcheck directly to screen */ NULL, /* Send output from mysqlcheck directly to screen */
"--no-defaults", "--no-defaults",
ds_args.str, ds_args.str,
"--all-databases", "--all-databases", "--repair",
upgrade_views, upgrade_views,
"--skip-fix-tables", "--skip-process-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",
...@@ -815,7 +819,14 @@ static int run_mysqlcheck_views(void) ...@@ -815,7 +819,14 @@ static int run_mysqlcheck_views(void)
static int run_mysqlcheck_fixnames(void) static int run_mysqlcheck_fixnames(void)
{ {
verbose("Phase %d/%d: Fixing table and database names", phase++, phases_total); if (opt_systables_only)
{
verbose("Phase %d/%d: Fixing table and database names ... Skipped",
phase++, phases_total);
return 0;
}
verbose("Phase %d/%d: Fixing table and database names",
phase++, phases_total);
print_conn_args("mysqlcheck"); print_conn_args("mysqlcheck");
return run_tool(mysqlcheck_path, return run_tool(mysqlcheck_path,
NULL, /* Send output from mysqlcheck directly to screen */ NULL, /* Send output from mysqlcheck directly to screen */
...@@ -896,7 +907,8 @@ static int run_sql_fix_privilege_tables(void) ...@@ -896,7 +907,8 @@ static int run_sql_fix_privilege_tables(void)
if (init_dynamic_string(&ds_result, "", 512, 512)) if (init_dynamic_string(&ds_result, "", 512, 512))
die("Out of memory"); die("Out of memory");
verbose("Phase %d/%d: Running 'mysql_fix_privilege_tables'...", phase++, phases_total); verbose("Phase %d/%d: Running 'mysql_fix_privilege_tables'",
phase++, phases_total);
run_query(mysql_fix_privilege_tables, run_query(mysql_fix_privilege_tables,
&ds_result, /* Collect result */ &ds_result, /* Collect result */
TRUE); TRUE);
...@@ -1058,10 +1070,8 @@ int main(int argc, char **argv) ...@@ -1058,10 +1070,8 @@ int main(int argc, char **argv)
/* /*
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql" Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
*/ */
if ((!opt_systables_only && if (run_mysqlcheck_views() || run_mysqlcheck_fixnames() ||
(run_mysqlcheck_views() || run_mysqlcheck_upgrade() || run_sql_fix_privilege_tables())
run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) ||
run_sql_fix_privilege_tables())
{ {
/* /*
The upgrade failed to complete in some way or another, The upgrade failed to complete in some way or another,
......
...@@ -43,7 +43,7 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0, ...@@ -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_tables= 1; opt_do_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;
...@@ -56,21 +56,17 @@ DYNAMIC_ARRAY tables4repair, tables4rebuild, alter_table_cmds; ...@@ -56,21 +56,17 @@ DYNAMIC_ARRAY tables4repair, tables4rebuild, alter_table_cmds;
static char *shared_memory_base_name=0; static char *shared_memory_base_name=0;
static uint opt_protocol=0; static uint opt_protocol=0;
enum operations { DO_CHECK=1, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE }; enum operations { DO_CHECK=1, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_FIX_NAMES };
const char *operation_name[]=
typedef enum { {
UPGRADE_VIEWS_NO=0, "???", "check", "repair", "analyze", "optimize", "fix names"
UPGRADE_VIEWS_YES=1, };
UPGRADE_VIEWS_FROM_MYSQL=2,
UPGRADE_VIEWS_COUNT typedef enum { DO_VIEWS_NO, DO_VIEWS_YES, DO_VIEWS_FROM_MYSQL } enum_do_views;
} enum_upgrade_views; const char *do_views_opts[]= {"NO", "YES", "UPGRADE_FROM_MYSQL", NullS};
const char *upgrade_views_opts[]= TYPELIB do_views_typelib= { array_elements(do_views_opts) - 1, "",
{"NO", "YES", "FROM_MYSQL", NullS}; do_views_opts, NULL };
TYPELIB upgrade_views_typelib= static ulong opt_do_views= DO_VIEWS_NO;
{ 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[] = static struct my_option my_long_options[] =
{ {
...@@ -211,15 +207,14 @@ static struct my_option my_long_options[] = ...@@ -211,15 +207,14 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0}, NO_ARG, 0, 0, 0, 0, 0, 0},
{"upgrade-views", OPT_UPGRADE_VIEWS, {"process-views", 0,
"Repairs/Upgrades views. 'No' (default) doesn't do anything to views. " "Perform the requested operation (check or repair) on views. "
"'Yes' repairs the checksum and adds a MariaDB version to the frm table defination (if missing)." "One of: NO, YES (correct the checksum, if necessary, add the "
"Using 'from_mysql' will, when upgrading from MySQL, and ensure the view algorithms are the" "mariadb-version field), UPGRADE_FROM_MYSQL (same as YES and toggle "
"same as what they where previously.", "the algorithm MERGE<->TEMPTABLE.", &opt_do_views, &opt_do_views,
&opt_upgrade_views_str, &opt_upgrade_views_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, &do_views_typelib, GET_ENUM, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"fix-tables", 'Y', {"process-tables", 0, "Perform the requested operation on tables.",
"Fix tables. Usually the default however mysql_upgrade will run with --skip-fix-tables.", &opt_do_tables, &opt_do_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
&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}
}; };
...@@ -236,7 +231,7 @@ static int process_selected_tables(char *db, char **table_names, int tables); ...@@ -236,7 +231,7 @@ static int process_selected_tables(char *db, char **table_names, int tables);
static int process_all_tables_in_db(char *database); static int process_all_tables_in_db(char *database);
static int process_one_db(char *database); static int process_one_db(char *database);
static int use_db(char *database); static int use_db(char *database);
static int handle_request_for_tables(char *tables, uint length, my_bool view); static int handle_request_for_tables(char *tables, size_t length, my_bool view);
static int dbConnect(char *host, char *user,char *passwd); static int dbConnect(char *host, char *user,char *passwd);
static void dbDisconnect(char *host); static void dbDisconnect(char *host);
static void DBerror(MYSQL *mysql, const char *when); static void DBerror(MYSQL *mysql, const char *when);
...@@ -311,11 +306,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -311,11 +306,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
what_to_do = DO_OPTIMIZE; what_to_do = DO_OPTIMIZE;
break; break;
case OPT_FIX_DB_NAMES: case OPT_FIX_DB_NAMES:
what_to_do= DO_UPGRADE; what_to_do= DO_FIX_NAMES;
opt_databases= 1; opt_databases= 1;
break; break;
case OPT_FIX_TABLE_NAMES: case OPT_FIX_TABLE_NAMES:
what_to_do= DO_UPGRADE; what_to_do= DO_FIX_NAMES;
break; break;
case 'p': case 'p':
if (argument == disabled_my_option) if (argument == disabled_my_option)
...@@ -359,15 +354,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -359,15 +354,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'V': case 'V':
print_version(); exit(0); print_version(); exit(0);
break; 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: case OPT_MYSQL_PROTOCOL:
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
opt->name); opt->name);
...@@ -398,23 +384,12 @@ static int get_options(int *argc, char ***argv) ...@@ -398,23 +384,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_upgrade_views || opt_fix_tables)) if (what_to_do == DO_REPAIR && !opt_do_views && !opt_do_tables)
{
fprintf(stderr, "Error: %s doesn't support repair command without either upgrade-views or fix-tables specified.\n",
my_progname);
exit(1);
}
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 upgrade-views.\n", fprintf(stderr, "Error: Nothing to repair when both "
my_progname); "--process-tables=NO and --process-views=NO\n");
exit(1); exit(1);
} }
}
if (!what_to_do) if (!what_to_do)
{ {
size_t pnlen= strlen(my_progname); size_t pnlen= strlen(my_progname);
...@@ -431,6 +406,13 @@ static int get_options(int *argc, char ***argv) ...@@ -431,6 +406,13 @@ static int get_options(int *argc, char ***argv)
what_to_do = DO_CHECK; what_to_do = DO_CHECK;
} }
if (opt_do_views && what_to_do != DO_REPAIR && what_to_do != DO_CHECK)
{
fprintf(stderr, "Error: %s doesn't support %s for views.\n",
my_progname, operation_name[what_to_do]);
exit(1);
}
/* /*
If there's no --default-character-set option given with If there's no --default-character-set option given with
--fix-table-name or --fix-db-name set the default character set to "utf8". --fix-table-name or --fix-db-name set the default character set to "utf8".
...@@ -516,19 +498,15 @@ static int process_databases(char **db_names) ...@@ -516,19 +498,15 @@ static int process_databases(char **db_names)
/* returns: -1 for error, 1 for view, 0 for table */ /* returns: -1 for error, 1 for view, 0 for table */
static int is_view(const char *table, uint length) static int is_view(const char *table)
{ {
char *query, *ptr; char query[1024];
MYSQL_RES *res; MYSQL_RES *res;
MYSQL_FIELD *field; MYSQL_FIELD *field;
int view; int view;
DBUG_ENTER("is_view"); DBUG_ENTER("is_view");
if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME)))) my_snprintf(query, sizeof(query), "SHOW CREATE TABLE %`s", table);
DBUG_RETURN(-1);
ptr= strmov(query, "SHOW CREATE TABLE `");
ptr= strxmov(ptr, table, NullS);
ptr= strxmov(ptr, "`", NullS);
if (mysql_query(sock, query)) if (mysql_query(sock, query))
{ {
fprintf(stderr, "Failed to %s\n", query); fprintf(stderr, "Failed to %s\n", query);
...@@ -538,9 +516,8 @@ static int is_view(const char *table, uint length) ...@@ -538,9 +516,8 @@ static int is_view(const char *table, uint length)
} }
res= mysql_store_result(sock); res= mysql_store_result(sock);
field= mysql_fetch_field(res); field= mysql_fetch_field(res);
view= (strcmp(field->name,"View")==0) ? 1 : 0; view= (strcmp(field->name,"View") == 0) ? 1 : 0;
mysql_free_result(res); mysql_free_result(res);
my_free(query);
DBUG_RETURN(view); DBUG_RETURN(view);
} }
...@@ -554,7 +531,7 @@ static int process_selected_tables(char *db, char **table_names, int tables) ...@@ -554,7 +531,7 @@ static int process_selected_tables(char *db, char **table_names, int tables)
if (use_db(db)) if (use_db(db))
DBUG_RETURN(1); DBUG_RETURN(1);
if (opt_all_in_1 && what_to_do != DO_UPGRADE) if (opt_all_in_1 && what_to_do != DO_FIX_NAMES)
{ {
/* /*
We need table list in form `a`, `b`, `c` We need table list in form `a`, `b`, `c`
...@@ -565,6 +542,15 @@ static int process_selected_tables(char *db, char **table_names, int tables) ...@@ -565,6 +542,15 @@ static int process_selected_tables(char *db, char **table_names, int tables)
size_t tot_length= 0; size_t tot_length= 0;
int i= 0; int i= 0;
if (opt_do_tables && opt_do_views)
{
fprintf(stderr, "Error: %s cannot process both tables and views "
"in one command (--process-tables=YES "
"--process-views=YES --all-in-1).\n",
my_progname);
DBUG_RETURN(1);
}
for (i = 0; i < tables; i++) for (i = 0; i < tables; i++)
tot_length+= fixed_name_length(*(table_names + i)) + 2; tot_length+= fixed_name_length(*(table_names + i)) + 2;
...@@ -579,12 +565,8 @@ static int process_selected_tables(char *db, char **table_names, int tables) ...@@ -579,12 +565,8 @@ static int process_selected_tables(char *db, char **table_names, int tables)
*end++= ','; *end++= ',';
} }
*--end = 0; *--end = 0;
table= table_names_comma_sep + 1; handle_request_for_tables(table_names_comma_sep + 1, tot_length - 1,
table_len= tot_length - 1; opt_do_views != 0);
view= is_view(table, table_len);
if (view < 0)
DBUG_RETURN(1);
handle_request_for_tables(table, table_len, (view==1));
my_free(table_names_comma_sep); my_free(table_names_comma_sep);
} }
else else
...@@ -592,10 +574,10 @@ static int process_selected_tables(char *db, char **table_names, int tables) ...@@ -592,10 +574,10 @@ static int process_selected_tables(char *db, char **table_names, int tables)
{ {
table= *table_names; table= *table_names;
table_len= fixed_name_length(*table_names); table_len= fixed_name_length(*table_names);
view= is_view(table, table_len); view= is_view(table);
if (view < 0) if (view < 0)
continue; continue;
handle_request_for_tables(table, table_len, (view==1)); handle_request_for_tables(table, table_len, (view == 1));
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} /* process_selected_tables */ } /* process_selected_tables */
...@@ -662,7 +644,7 @@ static int process_all_tables_in_db(char *database) ...@@ -662,7 +644,7 @@ static int process_all_tables_in_db(char *database)
num_columns= mysql_num_fields(res); num_columns= mysql_num_fields(res);
if (opt_all_in_1 && what_to_do != DO_UPGRADE) if (opt_all_in_1 && what_to_do != DO_FIX_NAMES)
{ {
/* /*
We need table list in form `a`, `b`, `c` We need table list in form `a`, `b`, `c`
...@@ -679,9 +661,9 @@ static int process_all_tables_in_db(char *database) ...@@ -679,9 +661,9 @@ 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_upgrade_views) opt_do_views)
tot_views_length+= fixed_name_length(row[0]) + 2; tot_views_length+= fixed_name_length(row[0]) + 2;
else if (opt_fix_tables) else if (opt_do_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);
...@@ -702,14 +684,14 @@ static int process_all_tables_in_db(char *database) ...@@ -702,14 +684,14 @@ static int process_all_tables_in_db(char *database)
{ {
if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0)) if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0))
{ {
if (!opt_upgrade_views) if (!opt_do_views)
continue; continue;
views_end= fix_table_name(views_end, row[0]); views_end= fix_table_name(views_end, row[0]);
*views_end++= ','; *views_end++= ',';
} }
else else
{ {
if (!opt_fix_tables) if (!opt_do_tables)
continue; continue;
end= fix_table_name(end, row[0]); end= fix_table_name(end, row[0]);
*end++= ','; *end++= ',';
...@@ -729,15 +711,15 @@ static int process_all_tables_in_db(char *database) ...@@ -729,15 +711,15 @@ static int process_all_tables_in_db(char *database)
while ((row = mysql_fetch_row(res))) while ((row = mysql_fetch_row(res)))
{ {
/* Skip views if we don't perform renaming. */ /* Skip views if we don't perform renaming. */
if ((what_to_do != DO_UPGRADE) && (num_columns == 2) && (strcmp(row[1], "VIEW") == 0)) if ((what_to_do != DO_FIX_NAMES) && (num_columns == 2) && (strcmp(row[1], "VIEW") == 0))
{ {
if (!opt_upgrade_views) if (!opt_do_views)
continue; continue;
view= TRUE; view= TRUE;
} }
else else
{ {
if (!opt_fix_tables) if (!opt_do_tables)
continue; continue;
view= FALSE; view= FALSE;
} }
...@@ -825,7 +807,7 @@ static int process_one_db(char *database) ...@@ -825,7 +807,7 @@ static int process_one_db(char *database)
if (verbose) if (verbose)
puts(database); puts(database);
if (what_to_do == DO_UPGRADE) if (what_to_do == DO_FIX_NAMES)
{ {
int rc= 0; int rc= 0;
if (opt_fix_db_names && !strncmp(database,"#mysql50#", 9)) if (opt_fix_db_names && !strncmp(database,"#mysql50#", 9))
...@@ -864,7 +846,7 @@ static int disable_binlog() ...@@ -864,7 +846,7 @@ static int disable_binlog()
return run_query(stmt); return run_query(stmt);
} }
static int handle_request_for_tables(char *tables, uint length, my_bool view) static int handle_request_for_tables(char *tables, size_t length, my_bool view)
{ {
char *query, *end, options[100], message[100]; char *query, *end, options[100], message[100];
char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name; char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name;
...@@ -887,21 +869,28 @@ static int handle_request_for_tables(char *tables, uint length, my_bool view) ...@@ -887,21 +869,28 @@ static int handle_request_for_tables(char *tables, uint length, my_bool view)
if (opt_upgrade) end = strmov(end, " FOR UPGRADE"); if (opt_upgrade) end = strmov(end, " FOR UPGRADE");
break; break;
case DO_REPAIR: case DO_REPAIR:
op= (opt_write_binlog) ? op= opt_write_binlog ? "REPAIR" : "REPAIR NO_WRITE_TO_BINLOG";
"REPAIR" : "REPAIR NO_WRITE_TO_BINLOG"; if (view)
{
if (opt_do_views == DO_VIEWS_FROM_MYSQL) end = strmov(end, " FROM MYSQL");
}
else
{
if (opt_quick) end = strmov(end, " QUICK"); if (opt_quick) end = strmov(end, " QUICK");
if (opt_extended) end = strmov(end, " EXTENDED"); if (opt_extended) end = strmov(end, " EXTENDED");
if (opt_frm) end = strmov(end, " USE_FRM"); if (opt_frm) end = strmov(end, " USE_FRM");
if (opt_upgrade_views==UPGRADE_VIEWS_FROM_MYSQL && view) }
end = strmov(end, " FROM MYSQL");
break; break;
case DO_ANALYZE: case DO_ANALYZE:
DBUG_ASSERT(!view);
op= (opt_write_binlog) ? "ANALYZE" : "ANALYZE NO_WRITE_TO_BINLOG"; op= (opt_write_binlog) ? "ANALYZE" : "ANALYZE NO_WRITE_TO_BINLOG";
break; break;
case DO_OPTIMIZE: case DO_OPTIMIZE:
DBUG_ASSERT(!view);
op= (opt_write_binlog) ? "OPTIMIZE" : "OPTIMIZE NO_WRITE_TO_BINLOG"; op= (opt_write_binlog) ? "OPTIMIZE" : "OPTIMIZE NO_WRITE_TO_BINLOG";
break; break;
case DO_UPGRADE: case DO_FIX_NAMES:
DBUG_ASSERT(!view);
DBUG_RETURN(fix_table_storage_name(tables)); DBUG_RETURN(fix_table_storage_name(tables));
} }
...@@ -929,7 +918,6 @@ static int handle_request_for_tables(char *tables, uint length, my_bool view) ...@@ -929,7 +918,6 @@ static int handle_request_for_tables(char *tables, uint length, my_bool view)
if (mysql_real_query(sock, query, query_length)) if (mysql_real_query(sock, query, query_length))
{ {
sprintf(message, "when executing '%s%s... %s'", op, tab_view, options); sprintf(message, "when executing '%s%s... %s'", op, tab_view, options);
/* sprintf(message, "when executing '%s'", query); */
DBerror(sock, message); DBerror(sock, message);
my_free(query); my_free(query);
DBUG_RETURN(1); DBUG_RETURN(1);
......
...@@ -11,8 +11,9 @@ Table Op Msg_type Msg_text ...@@ -11,8 +11,9 @@ Table Op Msg_type Msg_text
test.bug49823 repair status OK test.bug49823 repair status OK
RENAME TABLE general_log TO renamed_general_log; RENAME TABLE general_log TO renamed_general_log;
RENAME TABLE test.bug49823 TO general_log; RENAME TABLE test.bug49823 TO general_log;
Phase 1/3: Fixing table and database names Phase 1/4: Fixing views
Phase 2/3: Checking and upgrading tables Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases Processing databases
information_schema information_schema
mtr mtr
...@@ -44,7 +45,7 @@ mysql.time_zone_transition_type OK ...@@ -44,7 +45,7 @@ mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
performance_schema performance_schema
test test
Phase 3/3: Running 'mysql_fix_privilege_tables'... Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
DROP TABLE general_log; DROP TABLE general_log;
RENAME TABLE renamed_general_log TO general_log; RENAME TABLE renamed_general_log TO general_log;
......
...@@ -32,7 +32,7 @@ mysql.time_zone_transition_type OK ...@@ -32,7 +32,7 @@ mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
performance_schema performance_schema
test test
Phase 4/4: Running 'mysql_fix_privilege_tables'... Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
Run it again - should say already completed Run it again - should say already completed
This installation of MySQL is already upgraded to VERSION, use --force if you still need to run mysql_upgrade This installation of MySQL is already upgraded to VERSION, use --force if you still need to run mysql_upgrade
...@@ -70,7 +70,7 @@ mysql.time_zone_transition_type OK ...@@ -70,7 +70,7 @@ mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
performance_schema performance_schema
test test
Phase 4/4: Running 'mysql_fix_privilege_tables'... Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila'; CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila';
GRANT ALL ON *.* TO mysqltest1@'%'; GRANT ALL ON *.* TO mysqltest1@'%';
...@@ -108,7 +108,7 @@ mysql.time_zone_transition_type OK ...@@ -108,7 +108,7 @@ mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
performance_schema performance_schema
test test
Phase 4/4: Running 'mysql_fix_privilege_tables'... Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
DROP USER mysqltest1@'%'; DROP USER mysqltest1@'%';
Version check failed. Got the following error when calling the 'mysql' command line client Version check failed. Got the following error when calling the 'mysql' command line client
...@@ -151,7 +151,7 @@ mysql.time_zone_transition_type OK ...@@ -151,7 +151,7 @@ mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
performance_schema performance_schema
test test
Phase 4/4: Running 'mysql_fix_privilege_tables'... Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
set GLOBAL sql_mode=default; set GLOBAL sql_mode=default;
# #
...@@ -195,7 +195,7 @@ mysql.time_zone_transition_type OK ...@@ -195,7 +195,7 @@ mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
performance_schema performance_schema
test test
Phase 4/4: Running 'mysql_fix_privilege_tables'... Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
CALL testproc(); CALL testproc();
DROP PROCEDURE testproc; DROP PROCEDURE testproc;
...@@ -242,7 +242,7 @@ mysql.time_zone_transition_type OK ...@@ -242,7 +242,7 @@ mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
performance_schema performance_schema
test test
Phase 4/4: Running 'mysql_fix_privilege_tables'... Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
SHOW GRANTS FOR 'user3'@'%'; SHOW GRANTS FOR 'user3'@'%';
Grants for user3@% Grants for user3@%
...@@ -251,7 +251,10 @@ GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%' ...@@ -251,7 +251,10 @@ GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'
DROP USER 'user3'@'%'; DROP USER 'user3'@'%';
End of 5.1 tests End of 5.1 tests
The --upgrade-system-tables option was used, databases won't be touched. The --upgrade-system-tables option was used, databases won't be touched.
Phase 1/4: Running 'mysql_fix_privilege_tables'... Phase 1/4: Fixing views... Skipped
Phase 2/4: Fixing table and database names ... Skipped
Phase 3/4: Checking and upgrading tables... Skipped
Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
# #
# Bug#11827359 60223: MYSQL_UPGRADE PROBLEM WITH OPTION # Bug#11827359 60223: MYSQL_UPGRADE PROBLEM WITH OPTION
...@@ -292,7 +295,7 @@ mysql.time_zone_transition_type OK ...@@ -292,7 +295,7 @@ mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
performance_schema performance_schema
test test
Phase 4/4: Running 'mysql_fix_privilege_tables'... Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
# #
# MDEV-4332 Increase username length from 16 characters # MDEV-4332 Increase username length from 16 characters
...@@ -353,7 +356,7 @@ mysql.time_zone_transition_type OK ...@@ -353,7 +356,7 @@ mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
performance_schema performance_schema
test test
Phase 4/4: Running 'mysql_fix_privilege_tables'... Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
SELECT definer FROM mysql.proc WHERE db = 'test' AND name = 'pr'; SELECT definer FROM mysql.proc WHERE db = 'test' AND name = 'pr';
definer definer
......
# #
# Bug#55672 mysql_upgrade dies with internal error # Bug#55672 mysql_upgrade dies with internal error
# #
Phase 1/3: Fixing table and database names Phase 1/4: Fixing views
Phase 2/3: Checking and upgrading tables Phase 2/4: Fixing table and database names
Phase 3/4: Checking and upgrading tables
Processing databases Processing databases
information_schema information_schema
mtr mtr
...@@ -33,5 +34,5 @@ mysql.time_zone_transition_type OK ...@@ -33,5 +34,5 @@ mysql.time_zone_transition_type OK
mysql.user OK mysql.user OK
performance_schema performance_schema
test test
Phase 3/3: Running 'mysql_fix_privilege_tables'... Phase 4/4: Running 'mysql_fix_privilege_tables'
OK OK
...@@ -4,6 +4,30 @@ drop view if exists t1,v1,v2,v3,v4,v1badcheck; ...@@ -4,6 +4,30 @@ drop view if exists t1,v1,v2,v3,v4,v1badcheck;
create table t1(a int); create table t1(a int);
create table kv(k varchar(30) NOT NULL PRIMARY KEY,v varchar(50)); create table kv(k varchar(30) NOT NULL PRIMARY KEY,v varchar(50));
flush tables; flush tables;
check view v1;
Table Op Msg_type Msg_text
test.v1 check status OK
check view v1badcheck;
Table Op Msg_type Msg_text
test.v1badcheck check note View text checksum failed
check view v2;
Table Op Msg_type Msg_text
test.v2 check status OK
check view v3;
Table Op Msg_type Msg_text
test.v3 check status OK
check view v1 for upgrade;
Table Op Msg_type Msg_text
test.v1 check error Upgrade required. Please do "REPAIR VIEW `v1`" or dump/reload to fix it!
check view v1badcheck for upgrade;
Table Op Msg_type Msg_text
test.v1badcheck check note View text checksum failed
check view v2 for upgrade;
Table Op Msg_type Msg_text
test.v2 check error Upgrade required. Please do "REPAIR VIEW `v2`" or dump/reload to fix it!
check view v3 for upgrade;
Table Op Msg_type Msg_text
test.v3 check error Upgrade required. Please do "REPAIR VIEW `v3`" or dump/reload to fix it!
Phase 1/4: Fixing views Phase 1/4: Fixing views
test.v1 OK test.v1 OK
test.v1badcheck OK test.v1badcheck OK
...@@ -43,7 +67,7 @@ performance_schema ...@@ -43,7 +67,7 @@ performance_schema
test test
test.kv OK test.kv OK
test.t1 OK test.t1 OK
Phase 4/4: 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
...@@ -107,6 +131,7 @@ k ...@@ -107,6 +131,7 @@ k
mariadb-version mariadb-version
truncate table kv; truncate table kv;
drop view if exists v1,v2,v3,v1badcheck; drop view if exists v1,v2,v3,v1badcheck;
rename table mysql.event to mysql.ev_bk;
flush tables; flush tables;
create algorithm=temptable view v4 as select a from t1; create algorithm=temptable view v4 as select a from t1;
show create view v1; show create view v1;
...@@ -162,7 +187,7 @@ performance_schema ...@@ -162,7 +187,7 @@ performance_schema
test test
test.kv OK test.kv OK
test.t1 OK test.t1 OK
Phase 4/4: 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
...@@ -186,7 +211,10 @@ k ...@@ -186,7 +211,10 @@ k
mariadb-version mariadb-version
truncate table kv; truncate table kv;
drop view if exists v1,v2,v3; drop view if exists v1,v2,v3;
flush tables; drop table mysql.event;
rename table mysql.ev_bk to mysql.event;
test.kv OK
test.t1 OK
test.v1 OK test.v1 OK
test.v2 OK test.v2 OK
test.v3 OK test.v3 OK
...@@ -195,11 +223,12 @@ show binlog events from <binlog_start>; ...@@ -195,11 +223,12 @@ show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; REPAIR VIEW v1,v2 master-bin.000001 # Query # # use `test`; REPAIR VIEW v1,v2
master-bin.000001 # Query # # use `test`; REPAIR VIEW v1badcheck master-bin.000001 # Query # # use `test`; REPAIR VIEW v1badcheck
master-bin.000001 # Query # # use `test`; REPAIR TABLE `kv` USE_FRM
master-bin.000001 # Query # # use `test`; REPAIR TABLE `t1` USE_FRM
master-bin.000001 # Query # # use `test`; REPAIR VIEW `v1` FROM MYSQL master-bin.000001 # Query # # use `test`; REPAIR VIEW `v1` FROM MYSQL
master-bin.000001 # Query # # use `test`; REPAIR VIEW `v2` FROM MYSQL master-bin.000001 # Query # # use `test`; REPAIR VIEW `v2` FROM MYSQL
master-bin.000001 # Query # # use `test`; REPAIR VIEW `v3` FROM MYSQL master-bin.000001 # Query # # use `test`; REPAIR VIEW `v3` FROM MYSQL
master-bin.000001 # Query # # use `test`; REPAIR VIEW `v4` FROM MYSQL master-bin.000001 # Query # # use `test`; REPAIR VIEW `v4` FROM MYSQL
flush tables;
drop table if exists kv; drop table if exists kv;
drop view v1,v2,v3,v4; drop view v1,v2,v3,v4;
drop table t1; drop table t1;
...@@ -18,6 +18,16 @@ let $MYSQLD_DATADIR= `select @@datadir`; ...@@ -18,6 +18,16 @@ let $MYSQLD_DATADIR= `select @@datadir`;
flush tables; flush tables;
check view v1;
check view v1badcheck;
check view v2;
check view v3;
check view v1 for upgrade;
check view v1badcheck for upgrade;
check view v2 for upgrade;
check view v3 for upgrade;
--replace_result $MYSQLTEST_VARDIR var --replace_result $MYSQLTEST_VARDIR var
--exec $MYSQL_UPGRADE --force 2>&1 --exec $MYSQL_UPGRADE --force 2>&1
...@@ -67,12 +77,7 @@ drop view if exists v1,v2,v3,v1badcheck; ...@@ -67,12 +77,7 @@ drop view if exists v1,v2,v3,v1badcheck;
# Make it look like a MySQL directory now # Make it look like a MySQL directory now
--copy_file $MYSQLD_DATADIR/mysql/event.MYI $MYSQLD_DATADIR/mysql/ev_bk.MYI rename table mysql.event to mysql.ev_bk;
--copy_file $MYSQLD_DATADIR/mysql/event.MYD $MYSQLD_DATADIR/mysql/ev_bk.MYD
--copy_file $MYSQLD_DATADIR/mysql/event.frm $MYSQLD_DATADIR/mysql/ev_bk.frm
--remove_file $MYSQLD_DATADIR/mysql/event.MYI
--remove_file $MYSQLD_DATADIR/mysql/event.MYD
--remove_file $MYSQLD_DATADIR/mysql/event.frm
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.MYI $MYSQLD_DATADIR/mysql/event.MYI --copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.MYI $MYSQLD_DATADIR/mysql/event.MYI
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.MYD $MYSQLD_DATADIR/mysql/event.MYD --copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.MYD $MYSQLD_DATADIR/mysql/event.MYD
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.frm $MYSQLD_DATADIR/mysql/event.frm --copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.frm $MYSQLD_DATADIR/mysql/event.frm
...@@ -108,38 +113,19 @@ truncate table kv; ...@@ -108,38 +113,19 @@ truncate table kv;
drop view if exists v1,v2,v3; drop view if exists v1,v2,v3;
--enable_warnings --enable_warnings
# back to mariadb default
--remove_file $MYSQLD_DATADIR/mysql/event.MYI drop table mysql.event;
--remove_file $MYSQLD_DATADIR/mysql/event.MYD rename table mysql.ev_bk to mysql.event;
--remove_file $MYSQLD_DATADIR/mysql/event.frm
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.MYI $MYSQLD_DATADIR/mysql/event.MYI
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.MYD $MYSQLD_DATADIR/mysql/event.MYD
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/event.frm $MYSQLD_DATADIR/mysql/event.frm
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v1.frm $MYSQLD_DATADIR/test/v1.frm --copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v1.frm $MYSQLD_DATADIR/test/v1.frm
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v2.frm $MYSQLD_DATADIR/test/v2.frm --copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v2.frm $MYSQLD_DATADIR/test/v2.frm
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v3.frm $MYSQLD_DATADIR/test/v3.frm --copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v3.frm $MYSQLD_DATADIR/test/v3.frm
flush tables;
# check of binlog # check of binlog and mixing tables (with table specific options) and views
--exec $MYSQL_CHECK --write-binlog --upgrade-views=FROM_MYSQL --skip-fix-tables --all-databases 2>&1 --exec $MYSQL_CHECK --repair --write-binlog --process-tables --use-frm --process-views=UPGRADE_FROM_MYSQL test 2>&1
--source include/show_binlog_events.inc --source include/show_binlog_events.inc
# back to mariadb default
--remove_file $MYSQLD_DATADIR/mysql/event.MYI
--remove_file $MYSQLD_DATADIR/mysql/event.MYD
--remove_file $MYSQLD_DATADIR/mysql/event.frm
--copy_file $MYSQLD_DATADIR/mysql/ev_bk.MYI $MYSQLD_DATADIR/mysql/event.MYI
--copy_file $MYSQLD_DATADIR/mysql/ev_bk.MYD $MYSQLD_DATADIR/mysql/event.MYD
--copy_file $MYSQLD_DATADIR/mysql/ev_bk.frm $MYSQLD_DATADIR/mysql/event.frm
--remove_file $MYSQLD_DATADIR/mysql/ev_bk.MYI
--remove_file $MYSQLD_DATADIR/mysql/ev_bk.MYD
--remove_file $MYSQLD_DATADIR/mysql/ev_bk.frm
flush tables;
drop table if exists kv; drop table if exists kv;
drop view v1,v2,v3,v4; drop view v1,v2,v3,v4;
drop table t1; drop table t1;
......
...@@ -869,7 +869,16 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -869,7 +869,16 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
size_t length; size_t length;
protocol->store(STRING_WITH_LEN("error"), system_charset_info); protocol->store(STRING_WITH_LEN("error"), system_charset_info);
if (table->table->file->ha_table_flags() & HA_CAN_REPAIR) #if MYSQL_VERSION_ID > 100104
#error fix the error message to take TABLE or VIEW as an argument
#else
if (table->view)
length= my_snprintf(buf, sizeof(buf),
"Upgrade required. Please do \"REPAIR VIEW %`s\" or dump/reload to fix it!",
table->table_name);
else
#endif
if (table->table->file->ha_table_flags() & HA_CAN_REPAIR || table->view)
length= my_snprintf(buf, sizeof(buf), ER(ER_TABLE_NEEDS_UPGRADE), length= my_snprintf(buf, sizeof(buf), ER(ER_TABLE_NEEDS_UPGRADE),
table->table_name); table->table_name);
else else
......
...@@ -828,25 +828,6 @@ int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum, ...@@ -828,25 +828,6 @@ int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum,
if (!view->timestamp.str) if (!view->timestamp.str)
view->timestamp.str= view->timestamp_buffer; view->timestamp.str= view->timestamp_buffer;
/* check old .frm */
{
char path_buff[FN_REFLEN];
LEX_STRING path;
File_parser *parser;
path.str= path_buff;
fn_format(path_buff, file.str, dir.str, "", MY_UNPACK_FILENAME);
path.length= strlen(path_buff);
if (access(path.str, F_OK))
DBUG_RETURN(HA_ADMIN_INVALID);
if (!(parser= sql_parse_prepare(&path, thd->mem_root, 0)))
DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
if (!parser->ok() || !is_equal(&view_type, parser->type()))
DBUG_RETURN(HA_ADMIN_INVALID);
}
if (swap_alg && view->algorithm != VIEW_ALGORITHM_UNDEFINED) if (swap_alg && view->algorithm != VIEW_ALGORITHM_UNDEFINED)
{ {
DBUG_ASSERT(view->algorithm == VIEW_ALGORITHM_MERGE || DBUG_ASSERT(view->algorithm == VIEW_ALGORITHM_MERGE ||
...@@ -877,13 +858,13 @@ int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum, ...@@ -877,13 +858,13 @@ int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum,
view->db, view->table_name); view->db, view->table_name);
DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
} }
sql_print_information("View '%-.192s'.'%-.192s': versioned to %llu%s%s", sql_print_information("View %`s.%`s: the version is set to %llu%s%s",
view->db, view->table_name, view->mariadb_version, view->db, view->table_name, view->mariadb_version,
(wrong_checksum ? ", and checksum corrected" : ""), (wrong_checksum ? ", checksum corrected" : ""),
(swap_alg ? (swap_alg ?
((view->algorithm == VIEW_ALGORITHM_MERGE) ? ((view->algorithm == VIEW_ALGORITHM_MERGE) ?
", and algorithm swapped to 'MERGE'" ", algorithm restored to be MERGE"
: ", and algorithm swapped to 'TEMPTABLE'") : ", algorithm restored to be TEMPTABLE")
: "")); : ""));
...@@ -2046,20 +2027,15 @@ int view_checksum(THD *thd, TABLE_LIST *view) ...@@ -2046,20 +2027,15 @@ int view_checksum(THD *thd, TABLE_LIST *view)
*/ */
int view_check(THD *thd, TABLE_LIST *view, HA_CHECK_OPT *check_opt) int view_check(THD *thd, TABLE_LIST *view, HA_CHECK_OPT *check_opt)
{ {
int res;
DBUG_ENTER("view_check"); DBUG_ENTER("view_check");
if ((res= view_checksum(thd, view)) != HA_ADMIN_OK)
int res= view_checksum(thd, view);
if (res != HA_ADMIN_OK)
DBUG_RETURN(res); DBUG_RETURN(res);
if (((check_opt->sql_flags & TT_FOR_UPGRADE) &&
!view->mariadb_version)) if (((check_opt->sql_flags & TT_FOR_UPGRADE) && !view->mariadb_version))
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_TABLE_NEEDS_UPGRADE,
ER(ER_TABLE_NEEDS_UPGRADE),
view->db,
view->table_name);
DBUG_RETURN(HA_ADMIN_NEEDS_UPGRADE); DBUG_RETURN(HA_ADMIN_NEEDS_UPGRADE);
}
DBUG_RETURN(HA_ADMIN_OK); DBUG_RETURN(HA_ADMIN_OK);
} }
...@@ -2080,7 +2056,7 @@ int view_repair(THD *thd, TABLE_LIST *view, HA_CHECK_OPT *check_opt) ...@@ -2080,7 +2056,7 @@ int view_repair(THD *thd, TABLE_LIST *view, HA_CHECK_OPT *check_opt)
{ {
DBUG_ENTER("view_repair"); DBUG_ENTER("view_repair");
bool swap_alg= (check_opt->sql_flags & TT_FROM_MYSQL); bool swap_alg= (check_opt->sql_flags & TT_FROM_MYSQL);
bool wrong_checksum= view_checksum(thd, view); bool wrong_checksum= view_checksum(thd, view) != HA_ADMIN_OK;
int ret; int ret;
if (wrong_checksum || swap_alg || (!view->mariadb_version)) if (wrong_checksum || swap_alg || (!view->mariadb_version))
{ {
......
...@@ -13806,19 +13806,13 @@ lock: ...@@ -13806,19 +13806,13 @@ lock:
; ;
table_or_tables: table_or_tables:
TABLE_SYM TABLE_SYM { Lex->only_view= FALSE; }
{ Lex->only_view= FALSE; } | TABLES { Lex->only_view= FALSE; }
| TABLES
{ Lex->only_view= FALSE; }
; ;
table_or_view: table_or_view:
TABLE_SYM table_or_tables
{ Lex->only_view= FALSE; } | VIEW_SYM { Lex->only_view= TRUE; }
| TABLES
{ Lex->only_view= FALSE; }
| VIEW_SYM
{ Lex->only_view= TRUE; }
; ;
table_lock_list: table_lock_list:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment