Merge branch 'openquery/MDEV-6916-maria-5.5-check_view-r4408' into 5.5
This commit is contained in:
commit
f9c02d7c29
@ -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,
|
||||
|
@ -36,6 +36,8 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static int phase = 1;
|
||||
static int phases_total = 4;
|
||||
static char mysql_path[FN_REFLEN];
|
||||
static char mysqlcheck_path[FN_REFLEN];
|
||||
|
||||
@ -738,9 +740,10 @@ static void print_conn_args(const char *tool_name)
|
||||
|
||||
static int run_mysqlcheck_upgrade(void)
|
||||
{
|
||||
verbose("Phase 2/3: Checking and upgrading tables");
|
||||
int retch;
|
||||
verbose("Phase %d/%d: Checking and upgrading tables", phase++, phases_total);
|
||||
print_conn_args("mysqlcheck");
|
||||
return run_tool(mysqlcheck_path,
|
||||
retch= run_tool(mysqlcheck_path,
|
||||
NULL, /* Send output from mysqlcheck directly to screen */
|
||||
"--no-defaults",
|
||||
ds_args.str,
|
||||
@ -752,12 +755,67 @@ static int run_mysqlcheck_upgrade(void)
|
||||
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
|
||||
"2>&1",
|
||||
NULL);
|
||||
if (retch || opt_systables_only)
|
||||
verbose("Phase %d/%d: Skipping 'mysql_fix_privilege_tables'... not needed", phase++, phases_total);
|
||||
return retch;
|
||||
}
|
||||
|
||||
#define EVENTS_STRUCT_LEN 7000
|
||||
|
||||
static my_bool is_mysql()
|
||||
{
|
||||
my_bool ret= TRUE;
|
||||
DYNAMIC_STRING ds_events_struct;
|
||||
|
||||
if (init_dynamic_string(&ds_events_struct, NULL,
|
||||
EVENTS_STRUCT_LEN, EVENTS_STRUCT_LEN))
|
||||
die("Out of memory");
|
||||
|
||||
if (run_query("show create table mysql.event",
|
||||
&ds_events_struct, FALSE) ||
|
||||
strstr(ds_events_struct.str, "IGNORE_BAD_TABLE_OPTIONS") != NULL)
|
||||
ret= FALSE;
|
||||
else
|
||||
verbose("MySQL upgrade detected");
|
||||
|
||||
dynstr_free(&ds_events_struct);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int run_mysqlcheck_views(void)
|
||||
{
|
||||
const char *upgrade_views="--upgrade-views=YES";
|
||||
if (is_mysql())
|
||||
{
|
||||
upgrade_views="--upgrade-views=FROM_MYSQL";
|
||||
verbose("Phase %d/%d: Fixing views from mysql", phase++, phases_total);
|
||||
}
|
||||
else if (opt_systables_only)
|
||||
{
|
||||
verbose("Phase %d/%d: Fixing views - skipped - not required", phase++, phases_total);
|
||||
return 0;
|
||||
}
|
||||
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",
|
||||
upgrade_views,
|
||||
"--skip-fix-tables",
|
||||
opt_verbose ? "--verbose": "",
|
||||
opt_silent ? "--silent": "",
|
||||
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
|
||||
"2>&1",
|
||||
NULL);
|
||||
}
|
||||
|
||||
static int run_mysqlcheck_fixnames(void)
|
||||
{
|
||||
verbose("Phase 1/3: Fixing table and database names");
|
||||
verbose("Phase %d/%d: Fixing table and database names", phase++, phases_total);
|
||||
print_conn_args("mysqlcheck");
|
||||
return run_tool(mysqlcheck_path,
|
||||
NULL, /* Send output from mysqlcheck directly to screen */
|
||||
@ -838,7 +896,7 @@ static int run_sql_fix_privilege_tables(void)
|
||||
if (init_dynamic_string(&ds_result, "", 512, 512))
|
||||
die("Out of memory");
|
||||
|
||||
verbose("Phase 3/3: Running 'mysql_fix_privilege_tables'...");
|
||||
verbose("Phase %d/%d: Running 'mysql_fix_privilege_tables'...", phase++, phases_total);
|
||||
run_query(mysql_fix_privilege_tables,
|
||||
&ds_result, /* Collect result */
|
||||
TRUE);
|
||||
@ -1001,7 +1059,8 @@ int main(int argc, char **argv)
|
||||
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
|
||||
*/
|
||||
if ((!opt_systables_only &&
|
||||
(run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) ||
|
||||
(run_mysqlcheck_views() ||
|
||||
run_mysqlcheck_fixnames() || run_mysqlcheck_upgrade())) ||
|
||||
run_sql_fix_privilege_tables())
|
||||
{
|
||||
/*
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
/* By Jani Tolonen, 2001-04-20, MySQL Development Team */
|
||||
|
||||
#define CHECK_VERSION "2.7.1"
|
||||
#define CHECK_VERSION "2.7.2-MariaDB"
|
||||
|
||||
#include "client_priv.h"
|
||||
#include <m_ctype.h>
|
||||
@ -42,7 +42,8 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
|
||||
opt_medium_check = 0, opt_quick = 0, opt_all_in_1 = 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_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 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;
|
||||
@ -57,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',
|
||||
@ -196,6 +211,15 @@ 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},
|
||||
{"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},
|
||||
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@ -212,7 +236,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_one_db(char *database);
|
||||
static int use_db(char *database);
|
||||
static int handle_request_for_tables(char *tables, uint length);
|
||||
static int handle_request_for_tables(char *tables, uint length, my_bool view);
|
||||
static int dbConnect(char *host, char *user,char *passwd);
|
||||
static void dbDisconnect(char *host);
|
||||
static void DBerror(MYSQL *mysql, const char *when);
|
||||
@ -332,7 +356,18 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'V': print_version(); exit(0);
|
||||
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);
|
||||
@ -363,6 +398,23 @@ 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_upgrade_views || opt_fix_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",
|
||||
my_progname);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (!what_to_do)
|
||||
{
|
||||
size_t pnlen= strlen(my_progname);
|
||||
@ -463,8 +515,41 @@ static int process_databases(char **db_names)
|
||||
} /* process_databases */
|
||||
|
||||
|
||||
/* returns: -1 for error, 1 for view, 0 for table */
|
||||
static int is_view(const char *table, uint length)
|
||||
{
|
||||
char *query, *ptr;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_FIELD *field;
|
||||
int view;
|
||||
DBUG_ENTER("is_view");
|
||||
|
||||
if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME))))
|
||||
DBUG_RETURN(-1);
|
||||
ptr= strmov(query, "SHOW CREATE TABLE `");
|
||||
ptr= strxmov(ptr, table, NullS);
|
||||
ptr= strxmov(ptr, "`", NullS);
|
||||
if (mysql_query(sock, query))
|
||||
{
|
||||
fprintf(stderr, "Failed to %s\n", query);
|
||||
fprintf(stderr, "Error: %s\n", mysql_error(sock));
|
||||
my_free(query);
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
res= mysql_store_result(sock);
|
||||
field= mysql_fetch_field(res);
|
||||
view= (strcmp(field->name,"View")==0) ? 1 : 0;
|
||||
mysql_free_result(res);
|
||||
my_free(query);
|
||||
|
||||
DBUG_RETURN(view);
|
||||
}
|
||||
|
||||
static int process_selected_tables(char *db, char **table_names, int tables)
|
||||
{
|
||||
int view;
|
||||
char *table;
|
||||
uint table_len;
|
||||
DBUG_ENTER("process_selected_tables");
|
||||
|
||||
if (use_db(db))
|
||||
@ -494,12 +579,24 @@ static int process_selected_tables(char *db, char **table_names, int tables)
|
||||
*end++= ',';
|
||||
}
|
||||
*--end = 0;
|
||||
handle_request_for_tables(table_names_comma_sep + 1, (uint) (tot_length - 1));
|
||||
table= table_names_comma_sep + 1;
|
||||
table_len= tot_length - 1;
|
||||
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);
|
||||
}
|
||||
else
|
||||
for (; tables > 0; tables--, table_names++)
|
||||
handle_request_for_tables(*table_names, fixed_name_length(*table_names));
|
||||
{
|
||||
table= *table_names;
|
||||
table_len= fixed_name_length(*table_names);
|
||||
view= is_view(table, table_len);
|
||||
if (view < 0)
|
||||
continue;
|
||||
handle_request_for_tables(table, table_len, (view==1));
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
} /* process_selected_tables */
|
||||
|
||||
@ -546,6 +643,7 @@ static int process_all_tables_in_db(char *database)
|
||||
MYSQL_ROW row;
|
||||
uint num_columns;
|
||||
my_bool system_database= 0;
|
||||
my_bool view= FALSE;
|
||||
DBUG_ENTER("process_all_tables_in_db");
|
||||
|
||||
if (use_db(database))
|
||||
@ -575,8 +673,17 @@ static int process_all_tables_in_db(char *database)
|
||||
char *tables, *end;
|
||||
uint tot_length = 0;
|
||||
|
||||
char *views, *views_end;
|
||||
uint tot_views_length = 0;
|
||||
|
||||
while ((row = mysql_fetch_row(res)))
|
||||
tot_length+= fixed_name_length(row[0]) + 2;
|
||||
{
|
||||
if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0) &&
|
||||
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;
|
||||
}
|
||||
mysql_data_seek(res, 0);
|
||||
|
||||
if (!(tables=(char *) my_malloc(sizeof(char)*tot_length+4, MYF(MY_WME))))
|
||||
@ -584,18 +691,38 @@ static int process_all_tables_in_db(char *database)
|
||||
mysql_free_result(res);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
for (end = tables + 1; (row = mysql_fetch_row(res)) ;)
|
||||
if (!(views=(char *) my_malloc(sizeof(char)*tot_views_length+4, MYF(MY_WME))))
|
||||
{
|
||||
my_free(tables);
|
||||
mysql_free_result(res);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
for (end = tables + 1, views_end= views + 1; (row = mysql_fetch_row(res)) ;)
|
||||
{
|
||||
if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0))
|
||||
continue;
|
||||
|
||||
end= fix_table_name(end, row[0]);
|
||||
*end++= ',';
|
||||
{
|
||||
if (!opt_upgrade_views)
|
||||
continue;
|
||||
views_end= fix_table_name(views_end, row[0]);
|
||||
*views_end++= ',';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!opt_fix_tables)
|
||||
continue;
|
||||
end= fix_table_name(end, row[0]);
|
||||
*end++= ',';
|
||||
}
|
||||
}
|
||||
*--end = 0;
|
||||
*--views_end = 0;
|
||||
if (tot_length)
|
||||
handle_request_for_tables(tables + 1, tot_length - 1);
|
||||
handle_request_for_tables(tables + 1, tot_length - 1, FALSE);
|
||||
if (tot_views_length)
|
||||
handle_request_for_tables(views + 1, tot_views_length - 1, TRUE);
|
||||
my_free(tables);
|
||||
my_free(views);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -603,13 +730,23 @@ 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))
|
||||
continue;
|
||||
{
|
||||
if (!opt_upgrade_views)
|
||||
continue;
|
||||
view= TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!opt_fix_tables)
|
||||
continue;
|
||||
view= FALSE;
|
||||
}
|
||||
if (system_database &&
|
||||
(!strcmp(row[0], "general_log") ||
|
||||
!strcmp(row[0], "slow_log")))
|
||||
continue; /* Skip logging tables */
|
||||
|
||||
handle_request_for_tables(row[0], fixed_name_length(row[0]));
|
||||
handle_request_for_tables(row[0], fixed_name_length(row[0]), view);
|
||||
}
|
||||
}
|
||||
mysql_free_result(res);
|
||||
@ -727,15 +864,17 @@ static int disable_binlog()
|
||||
return run_query(stmt);
|
||||
}
|
||||
|
||||
static int handle_request_for_tables(char *tables, uint length)
|
||||
static int handle_request_for_tables(char *tables, uint length, my_bool view)
|
||||
{
|
||||
char *query, *end, options[100], message[100];
|
||||
char table_name_buff[NAME_CHAR_LEN*2*2+1], *table_name;
|
||||
uint query_length= 0;
|
||||
const char *op = 0;
|
||||
const char *tab_view;
|
||||
DBUG_ENTER("handle_request_for_tables");
|
||||
|
||||
options[0] = 0;
|
||||
tab_view= view ? " VIEW " : " TABLE ";
|
||||
end = options;
|
||||
switch (what_to_do) {
|
||||
case DO_CHECK:
|
||||
@ -748,10 +887,13 @@ static int handle_request_for_tables(char *tables, uint length)
|
||||
if (opt_upgrade) end = strmov(end, " FOR UPGRADE");
|
||||
break;
|
||||
case DO_REPAIR:
|
||||
op= (opt_write_binlog) ? "REPAIR" : "REPAIR NO_WRITE_TO_BINLOG";
|
||||
op= (opt_write_binlog) ?
|
||||
"REPAIR" : "REPAIR NO_WRITE_TO_BINLOG";
|
||||
if (opt_quick) end = strmov(end, " QUICK");
|
||||
if (opt_extended) end = strmov(end, " EXTENDED");
|
||||
if (opt_frm) end = strmov(end, " USE_FRM");
|
||||
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";
|
||||
@ -768,14 +910,15 @@ static int handle_request_for_tables(char *tables, uint length)
|
||||
if (opt_all_in_1)
|
||||
{
|
||||
/* No backticks here as we added them before */
|
||||
query_length= sprintf(query, "%s TABLE %s %s", op, tables, options);
|
||||
query_length= sprintf(query, "%s%s%s %s", op,
|
||||
tab_view, tables, options);
|
||||
table_name= tables;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *ptr, *org;
|
||||
|
||||
org= ptr= strmov(strmov(query, op), " TABLE ");
|
||||
org= ptr= strmov(strmov(query, op), tab_view);
|
||||
ptr= fix_table_name(ptr, tables);
|
||||
strmake(table_name_buff, org, min((int) sizeof(table_name_buff)-1,
|
||||
(int) (ptr - org)));
|
||||
@ -785,7 +928,8 @@ static int handle_request_for_tables(char *tables, uint length)
|
||||
}
|
||||
if (mysql_real_query(sock, query, query_length))
|
||||
{
|
||||
sprintf(message, "when executing '%s TABLE ... %s'", op, options);
|
||||
sprintf(message, "when executing '%s%s... %s'", op, tab_view, options);
|
||||
/* sprintf(message, "when executing '%s'", query); */
|
||||
DBerror(sock, message);
|
||||
my_free(query);
|
||||
DBUG_RETURN(1);
|
||||
@ -1055,7 +1199,7 @@ int main(int argc, char **argv)
|
||||
for (i = 0; i < tables4repair.elements ; i++)
|
||||
{
|
||||
char *name= (char*) dynamic_array_ptr(&tables4repair, i);
|
||||
handle_request_for_tables(name, fixed_name_length(name));
|
||||
handle_request_for_tables(name, fixed_name_length(name), FALSE);
|
||||
}
|
||||
for (i = 0; i < tables4rebuild.elements ; i++)
|
||||
rebuild_table((char*) dynamic_array_ptr(&tables4rebuild, i));
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#define TT_USEFRM 1
|
||||
#define TT_FOR_UPGRADE 2
|
||||
#define TT_FROM_MYSQL 4
|
||||
|
||||
/* Bits set in out_flag */
|
||||
#define O_NEW_DATA 2
|
||||
|
@ -1,6 +1,7 @@
|
||||
Run mysql_upgrade once
|
||||
Phase 1/3: Fixing table and database names
|
||||
Phase 2/3: Checking and upgrading tables
|
||||
Phase 1/4: Fixing views
|
||||
Phase 2/4: Fixing table and database names
|
||||
Phase 3/4: Checking and upgrading tables
|
||||
Processing databases
|
||||
information_schema
|
||||
mtr
|
||||
@ -31,13 +32,14 @@ mysql.time_zone_transition_type OK
|
||||
mysql.user OK
|
||||
performance_schema
|
||||
test
|
||||
Phase 3/3: Running 'mysql_fix_privilege_tables'...
|
||||
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
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
|
||||
Force should run it regardless of wether it's been run before
|
||||
Phase 1/3: Fixing table and database names
|
||||
Phase 2/3: Checking and upgrading tables
|
||||
Phase 1/4: Fixing views
|
||||
Phase 2/4: Fixing table and database names
|
||||
Phase 3/4: Checking and upgrading tables
|
||||
Processing databases
|
||||
information_schema
|
||||
mtr
|
||||
@ -68,13 +70,14 @@ mysql.time_zone_transition_type OK
|
||||
mysql.user OK
|
||||
performance_schema
|
||||
test
|
||||
Phase 3/3: Running 'mysql_fix_privilege_tables'...
|
||||
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila';
|
||||
GRANT ALL ON *.* TO mysqltest1@'%';
|
||||
Run mysql_upgrade with password protected account
|
||||
Phase 1/3: Fixing table and database names
|
||||
Phase 2/3: Checking and upgrading tables
|
||||
Phase 1/4: Fixing views
|
||||
Phase 2/4: Fixing table and database names
|
||||
Phase 3/4: Checking and upgrading tables
|
||||
Processing databases
|
||||
information_schema
|
||||
mtr
|
||||
@ -105,7 +108,7 @@ mysql.time_zone_transition_type OK
|
||||
mysql.user OK
|
||||
performance_schema
|
||||
test
|
||||
Phase 3/3: Running 'mysql_fix_privilege_tables'...
|
||||
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
DROP USER mysqltest1@'%';
|
||||
Version check failed. Got the following error when calling the 'mysql' command line client
|
||||
@ -115,8 +118,9 @@ Run mysql_upgrade with a non existing server socket
|
||||
mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errno) when trying to connect
|
||||
FATAL ERROR: Upgrade failed
|
||||
set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE';
|
||||
Phase 1/3: Fixing table and database names
|
||||
Phase 2/3: Checking and upgrading tables
|
||||
Phase 1/4: Fixing views
|
||||
Phase 2/4: Fixing table and database names
|
||||
Phase 3/4: Checking and upgrading tables
|
||||
Processing databases
|
||||
information_schema
|
||||
mtr
|
||||
@ -147,7 +151,7 @@ mysql.time_zone_transition_type OK
|
||||
mysql.user OK
|
||||
performance_schema
|
||||
test
|
||||
Phase 3/3: Running 'mysql_fix_privilege_tables'...
|
||||
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
set GLOBAL sql_mode=default;
|
||||
#
|
||||
@ -158,8 +162,9 @@ CREATE PROCEDURE testproc() BEGIN END;
|
||||
UPDATE mysql.proc SET character_set_client = NULL WHERE name LIKE 'testproc';
|
||||
UPDATE mysql.proc SET collation_connection = NULL WHERE name LIKE 'testproc';
|
||||
UPDATE mysql.proc SET db_collation = NULL WHERE name LIKE 'testproc';
|
||||
Phase 1/3: Fixing table and database names
|
||||
Phase 2/3: Checking and upgrading tables
|
||||
Phase 1/4: Fixing views
|
||||
Phase 2/4: Fixing table and database names
|
||||
Phase 3/4: Checking and upgrading tables
|
||||
Processing databases
|
||||
information_schema
|
||||
mtr
|
||||
@ -190,7 +195,7 @@ mysql.time_zone_transition_type OK
|
||||
mysql.user OK
|
||||
performance_schema
|
||||
test
|
||||
Phase 3/3: Running 'mysql_fix_privilege_tables'...
|
||||
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
CALL testproc();
|
||||
DROP PROCEDURE testproc;
|
||||
@ -204,8 +209,9 @@ WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been
|
||||
GRANT USAGE ON *.* TO 'user3'@'%';
|
||||
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%';
|
||||
Run mysql_upgrade with all privileges on a user
|
||||
Phase 1/3: Fixing table and database names
|
||||
Phase 2/3: Checking and upgrading tables
|
||||
Phase 1/4: Fixing views
|
||||
Phase 2/4: Fixing table and database names
|
||||
Phase 3/4: Checking and upgrading tables
|
||||
Processing databases
|
||||
information_schema
|
||||
mtr
|
||||
@ -236,7 +242,7 @@ mysql.time_zone_transition_type OK
|
||||
mysql.user OK
|
||||
performance_schema
|
||||
test
|
||||
Phase 3/3: Running 'mysql_fix_privilege_tables'...
|
||||
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
SHOW GRANTS FOR 'user3'@'%';
|
||||
Grants for user3@%
|
||||
@ -245,7 +251,7 @@ GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'
|
||||
DROP USER 'user3'@'%';
|
||||
End of 5.1 tests
|
||||
The --upgrade-system-tables option was used, databases won't be touched.
|
||||
Phase 3/3: Running 'mysql_fix_privilege_tables'...
|
||||
Phase 1/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
#
|
||||
# Bug#11827359 60223: MYSQL_UPGRADE PROBLEM WITH OPTION
|
||||
@ -253,8 +259,9 @@ OK
|
||||
#
|
||||
# Droping the previously created mysql_upgrade_info file..
|
||||
# Running mysql_upgrade with --skip-write-binlog..
|
||||
Phase 1/3: Fixing table and database names
|
||||
Phase 2/3: Checking and upgrading tables
|
||||
Phase 1/4: Fixing views
|
||||
Phase 2/4: Fixing table and database names
|
||||
Phase 3/4: Checking and upgrading tables
|
||||
Processing databases
|
||||
information_schema
|
||||
mtr
|
||||
@ -285,7 +292,7 @@ mysql.time_zone_transition_type OK
|
||||
mysql.user OK
|
||||
performance_schema
|
||||
test
|
||||
Phase 3/3: Running 'mysql_fix_privilege_tables'...
|
||||
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
#
|
||||
# MDEV-4332 Increase username length from 16 characters
|
||||
@ -313,8 +320,9 @@ GRANT INSERT ON mysql.user TO very_long_user_name_number_2;
|
||||
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_1;
|
||||
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_2;
|
||||
CREATE PROCEDURE test.pr() BEGIN END;
|
||||
Phase 1/3: Fixing table and database names
|
||||
Phase 2/3: Checking and upgrading tables
|
||||
Phase 1/4: Fixing views
|
||||
Phase 2/4: Fixing table and database names
|
||||
Phase 3/4: Checking and upgrading tables
|
||||
Processing databases
|
||||
information_schema
|
||||
mtr
|
||||
@ -345,7 +353,7 @@ mysql.time_zone_transition_type OK
|
||||
mysql.user OK
|
||||
performance_schema
|
||||
test
|
||||
Phase 3/3: Running 'mysql_fix_privilege_tables'...
|
||||
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
SELECT definer FROM mysql.proc WHERE db = 'test' AND name = 'pr';
|
||||
definer
|
||||
|
205
mysql-test/r/mysql_upgrade_view.result
Normal file
205
mysql-test/r/mysql_upgrade_view.result
Normal file
@ -0,0 +1,205 @@
|
||||
set sql_log_bin=0;
|
||||
drop table if exists t1,v1,v2,v3,v4,v1badcheck;
|
||||
drop view if exists t1,v1,v2,v3,v4,v1badcheck;
|
||||
create table t1(a int);
|
||||
create table kv(k varchar(30) NOT NULL PRIMARY KEY,v varchar(50));
|
||||
flush tables;
|
||||
Phase 1/4: Fixing views
|
||||
test.v1 OK
|
||||
test.v1badcheck OK
|
||||
test.v2 OK
|
||||
test.v3 OK
|
||||
Phase 2/4: Fixing table and database names
|
||||
Phase 3/4: Checking and upgrading tables
|
||||
Processing databases
|
||||
information_schema
|
||||
mtr
|
||||
mtr.global_suppressions OK
|
||||
mtr.test_suppressions OK
|
||||
mysql
|
||||
mysql.columns_priv OK
|
||||
mysql.db OK
|
||||
mysql.event OK
|
||||
mysql.func OK
|
||||
mysql.help_category OK
|
||||
mysql.help_keyword OK
|
||||
mysql.help_relation OK
|
||||
mysql.help_topic OK
|
||||
mysql.host OK
|
||||
mysql.ndb_binlog_index OK
|
||||
mysql.plugin OK
|
||||
mysql.proc OK
|
||||
mysql.procs_priv OK
|
||||
mysql.proxies_priv OK
|
||||
mysql.servers OK
|
||||
mysql.tables_priv OK
|
||||
mysql.time_zone OK
|
||||
mysql.time_zone_leap_second OK
|
||||
mysql.time_zone_name OK
|
||||
mysql.time_zone_transition OK
|
||||
mysql.time_zone_transition_type OK
|
||||
mysql.user OK
|
||||
performance_schema
|
||||
test
|
||||
test.kv OK
|
||||
test.t1 OK
|
||||
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8 utf8_general_ci
|
||||
show create view v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a` from `t1` utf8 utf8_general_ci
|
||||
show create view v3;
|
||||
View Create View character_set_client collation_connection
|
||||
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a` from `t1` utf8 utf8_general_ci
|
||||
set sql_log_bin=1;
|
||||
REPAIR VIEW v1,v2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.v1 repair status OK
|
||||
test.v2 repair status OK
|
||||
REPAIR VIEW v1badcheck;
|
||||
Table Op Msg_type Msg_text
|
||||
test.v1badcheck repair status OK
|
||||
REPAIR NO_WRITE_TO_BINLOG VIEW v3;
|
||||
Table Op Msg_type Msg_text
|
||||
test.v3 repair status OK
|
||||
set sql_log_bin=0;
|
||||
show binlog events from <binlog_start>;
|
||||
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 v1badcheck
|
||||
LOAD DATA INFILE 'MYSQLD_DATADIR/test/v1.frm' REPLACE INTO TABLE kv FIELDS TERMINATED BY '=';
|
||||
SELECT k,v from kv where k in ('md5','algorithm');
|
||||
k v
|
||||
algorithm 1
|
||||
md5 5e6eaf216e7b016fcedfd4e1113517af
|
||||
SELECT k from kv where k ='mariadb-version';
|
||||
k
|
||||
mariadb-version
|
||||
truncate table kv;
|
||||
LOAD DATA INFILE 'MYSQLD_DATADIR/test/v2.frm' REPLACE INTO TABLE kv FIELDS TERMINATED BY '=';
|
||||
SELECT k,v from kv where k in ('md5','algorithm');
|
||||
k v
|
||||
algorithm 2
|
||||
md5 5e6eaf216e7b016fcedfd4e1113517af
|
||||
SELECT k from kv where k ='mariadb-version';
|
||||
k
|
||||
mariadb-version
|
||||
truncate table kv;
|
||||
LOAD DATA INFILE 'MYSQLD_DATADIR/test/v3.frm' REPLACE INTO TABLE kv FIELDS TERMINATED BY '=';
|
||||
SELECT k,v from kv where k in ('md5','algorithm');
|
||||
k v
|
||||
algorithm 0
|
||||
md5 5e6eaf216e7b016fcedfd4e1113517af
|
||||
SELECT k from kv where k ='mariadb-version';
|
||||
k
|
||||
mariadb-version
|
||||
truncate table kv;
|
||||
LOAD DATA INFILE 'MYSQLD_DATADIR/test/v1badcheck.frm' REPLACE INTO TABLE kv FIELDS TERMINATED BY '=';
|
||||
SELECT k,v from kv where k in ('md5','algorithm');
|
||||
k v
|
||||
algorithm 1
|
||||
md5 5e6eaf216e7b016fcedfd4e1113517af
|
||||
SELECT k from kv where k ='mariadb-version';
|
||||
k
|
||||
mariadb-version
|
||||
truncate table kv;
|
||||
drop view if exists v1,v2,v3,v1badcheck;
|
||||
flush tables;
|
||||
create algorithm=temptable view v4 as select a from t1;
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8 utf8_general_ci
|
||||
show create view v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a` from `t1` utf8 utf8_general_ci
|
||||
show create view v3;
|
||||
View Create View character_set_client collation_connection
|
||||
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a` from `t1` utf8 utf8_general_ci
|
||||
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 1/4: Fixing views from mysql
|
||||
test.v1 OK
|
||||
test.v2 OK
|
||||
test.v3 OK
|
||||
test.v4 OK
|
||||
Phase 2/4: Fixing table and database names
|
||||
Phase 3/4: Checking and upgrading tables
|
||||
Processing databases
|
||||
information_schema
|
||||
mtr
|
||||
mtr.global_suppressions OK
|
||||
mtr.test_suppressions OK
|
||||
mysql
|
||||
mysql.columns_priv OK
|
||||
mysql.db OK
|
||||
mysql.ev_bk OK
|
||||
mysql.event OK
|
||||
mysql.func OK
|
||||
mysql.help_category OK
|
||||
mysql.help_keyword OK
|
||||
mysql.help_relation OK
|
||||
mysql.help_topic OK
|
||||
mysql.host OK
|
||||
mysql.ndb_binlog_index OK
|
||||
mysql.plugin OK
|
||||
mysql.proc OK
|
||||
mysql.procs_priv OK
|
||||
mysql.proxies_priv OK
|
||||
mysql.servers OK
|
||||
mysql.tables_priv OK
|
||||
mysql.time_zone OK
|
||||
mysql.time_zone_leap_second OK
|
||||
mysql.time_zone_name OK
|
||||
mysql.time_zone_transition OK
|
||||
mysql.time_zone_transition_type OK
|
||||
mysql.user OK
|
||||
performance_schema
|
||||
test
|
||||
test.kv OK
|
||||
test.t1 OK
|
||||
Phase 4/4: Running 'mysql_fix_privilege_tables'...
|
||||
OK
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8 utf8_general_ci
|
||||
show create view v2;
|
||||
View Create View character_set_client collation_connection
|
||||
v2 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a` from `t1` utf8 utf8_general_ci
|
||||
show create view v3;
|
||||
View Create View character_set_client collation_connection
|
||||
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a` from `t1` utf8 utf8_general_ci
|
||||
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
|
||||
LOAD DATA INFILE 'MYSQLD_DATADIR/test/v1.frm' REPLACE INTO TABLE kv FIELDS TERMINATED BY '=';
|
||||
SELECT k,v from kv where k in ('md5','algorithm');
|
||||
k v
|
||||
algorithm 2
|
||||
md5 5e6eaf216e7b016fcedfd4e1113517af
|
||||
SELECT k from kv where k ='mariadb-version';
|
||||
k
|
||||
mariadb-version
|
||||
truncate table kv;
|
||||
drop view if exists v1,v2,v3;
|
||||
flush tables;
|
||||
test.v1 OK
|
||||
test.v2 OK
|
||||
test.v3 OK
|
||||
test.v4 OK
|
||||
show binlog events from <binlog_start>;
|
||||
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 v1badcheck
|
||||
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 `v3` FROM MYSQL
|
||||
master-bin.000001 # Query # # use `test`; REPAIR VIEW `v4` FROM MYSQL
|
||||
flush tables;
|
||||
drop table if exists kv;
|
||||
drop view v1,v2,v3,v4;
|
||||
drop table t1;
|
0
mysql-test/std_data/mysql_upgrade/event.MYD
Normal file
0
mysql-test/std_data/mysql_upgrade/event.MYD
Normal file
BIN
mysql-test/std_data/mysql_upgrade/event.MYI
Normal file
BIN
mysql-test/std_data/mysql_upgrade/event.MYI
Normal file
Binary file not shown.
BIN
mysql-test/std_data/mysql_upgrade/event.frm
Normal file
BIN
mysql-test/std_data/mysql_upgrade/event.frm
Normal file
Binary file not shown.
15
mysql-test/std_data/mysql_upgrade/v1.frm
Normal file
15
mysql-test/std_data/mysql_upgrade/v1.frm
Normal file
@ -0,0 +1,15 @@
|
||||
TYPE=VIEW
|
||||
query=select `test`.`t1`.`a` AS `a` from `test`.`t1`
|
||||
md5=5e6eaf216e7b016fcedfd4e1113517af
|
||||
updatable=0
|
||||
algorithm=1
|
||||
definer_user=root
|
||||
definer_host=localhost
|
||||
suid=2
|
||||
with_check_option=0
|
||||
timestamp=2014-12-11 15:26:20
|
||||
create-version=1
|
||||
source=select a from t1
|
||||
client_cs_name=utf8
|
||||
connection_cl_name=utf8_general_ci
|
||||
view_body_utf8=select `test`.`t1`.`a` AS `a` from `test`.`t1`
|
15
mysql-test/std_data/mysql_upgrade/v1badcheck.frm
Normal file
15
mysql-test/std_data/mysql_upgrade/v1badcheck.frm
Normal file
@ -0,0 +1,15 @@
|
||||
TYPE=VIEW
|
||||
query=select `test`.`t1`.`a` AS `a` from `test`.`t1`
|
||||
md5=00000000000000000000000000000000
|
||||
updatable=0
|
||||
algorithm=1
|
||||
definer_user=root
|
||||
definer_host=localhost
|
||||
suid=2
|
||||
with_check_option=0
|
||||
timestamp=2014-12-11 15:26:20
|
||||
create-version=1
|
||||
source=select a from t1
|
||||
client_cs_name=utf8
|
||||
connection_cl_name=utf8_general_ci
|
||||
view_body_utf8=select `test`.`t1`.`a` AS `a` from `test`.`t1`
|
15
mysql-test/std_data/mysql_upgrade/v2.frm
Normal file
15
mysql-test/std_data/mysql_upgrade/v2.frm
Normal file
@ -0,0 +1,15 @@
|
||||
TYPE=VIEW
|
||||
query=select `test`.`t1`.`a` AS `a` from `test`.`t1`
|
||||
md5=5e6eaf216e7b016fcedfd4e1113517af
|
||||
updatable=1
|
||||
algorithm=2
|
||||
definer_user=root
|
||||
definer_host=localhost
|
||||
suid=2
|
||||
with_check_option=0
|
||||
timestamp=2014-12-11 15:26:29
|
||||
create-version=1
|
||||
source=select a from t1
|
||||
client_cs_name=utf8
|
||||
connection_cl_name=utf8_general_ci
|
||||
view_body_utf8=select `test`.`t1`.`a` AS `a` from `test`.`t1`
|
15
mysql-test/std_data/mysql_upgrade/v3.frm
Normal file
15
mysql-test/std_data/mysql_upgrade/v3.frm
Normal file
@ -0,0 +1,15 @@
|
||||
TYPE=VIEW
|
||||
query=select `test`.`t1`.`a` AS `a` from `test`.`t1`
|
||||
md5=5e6eaf216e7b016fcedfd4e1113517af
|
||||
updatable=0
|
||||
algorithm=0
|
||||
definer_user=root
|
||||
definer_host=localhost
|
||||
suid=2
|
||||
with_check_option=0
|
||||
timestamp=2014-12-11 15:26:20
|
||||
create-version=1
|
||||
source=select a from t1
|
||||
client_cs_name=utf8
|
||||
connection_cl_name=utf8_general_ci
|
||||
view_body_utf8=select `test`.`t1`.`a` AS `a` from `test`.`t1`
|
16
mysql-test/std_data/mysql_upgrade/v4.frm
Normal file
16
mysql-test/std_data/mysql_upgrade/v4.frm
Normal file
@ -0,0 +1,16 @@
|
||||
TYPE=VIEW
|
||||
query=select `test`.`t1`.`a` AS `a` from `test`.`t1`
|
||||
md5=5e6eaf216e7b016fcedfd4e1113517a0
|
||||
updatable=1
|
||||
algorithm=0
|
||||
definer_user=root
|
||||
definer_host=localhost
|
||||
suid=2
|
||||
with_check_option=0
|
||||
timestamp=2015-02-08 19:21:14
|
||||
create-version=1
|
||||
source=select a from t1
|
||||
client_cs_name=latin1
|
||||
connection_cl_name=latin1_swedish_ci
|
||||
view_body_utf8=select `test`.`t1`.`a` AS `a` from `test`.`t1`
|
||||
mariadb-version=50542
|
146
mysql-test/t/mysql_upgrade_view.test
Normal file
146
mysql-test/t/mysql_upgrade_view.test
Normal file
@ -0,0 +1,146 @@
|
||||
-- source include/have_log_bin.inc
|
||||
|
||||
set sql_log_bin=0;
|
||||
--disable_warnings
|
||||
drop table if exists t1,v1,v2,v3,v4,v1badcheck;
|
||||
drop view if exists t1,v1,v2,v3,v4,v1badcheck;
|
||||
--enable_warnings
|
||||
|
||||
create table t1(a int);
|
||||
create table kv(k varchar(30) NOT NULL PRIMARY KEY,v varchar(50));
|
||||
|
||||
let $MYSQLD_DATADIR= `select @@datadir`;
|
||||
|
||||
--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/v1badcheck.frm $MYSQLD_DATADIR/test/v1badcheck.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
|
||||
|
||||
flush tables;
|
||||
|
||||
--replace_result $MYSQLTEST_VARDIR var
|
||||
--exec $MYSQL_UPGRADE --force 2>&1
|
||||
|
||||
# "Phase 1/4: Fixing views" expected (without from_mysql)
|
||||
|
||||
show create view v1;
|
||||
show create view v2;
|
||||
show create view v3;
|
||||
|
||||
# Now force a mariadb version to be added
|
||||
|
||||
set sql_log_bin=1;
|
||||
REPAIR VIEW v1,v2;
|
||||
REPAIR VIEW v1badcheck;
|
||||
REPAIR NO_WRITE_TO_BINLOG VIEW v3;
|
||||
set sql_log_bin=0;
|
||||
|
||||
--source include/show_binlog_events.inc
|
||||
|
||||
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
|
||||
eval LOAD DATA INFILE '$MYSQLD_DATADIR/test/v1.frm' REPLACE INTO TABLE kv FIELDS TERMINATED BY '=';
|
||||
SELECT k,v from kv where k in ('md5','algorithm');
|
||||
SELECT k from kv where k ='mariadb-version';
|
||||
truncate table kv;
|
||||
|
||||
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
|
||||
eval LOAD DATA INFILE '$MYSQLD_DATADIR/test/v2.frm' REPLACE INTO TABLE kv FIELDS TERMINATED BY '=';
|
||||
SELECT k,v from kv where k in ('md5','algorithm');
|
||||
SELECT k from kv where k ='mariadb-version';
|
||||
truncate table kv;
|
||||
|
||||
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
|
||||
eval LOAD DATA INFILE '$MYSQLD_DATADIR/test/v3.frm' REPLACE INTO TABLE kv FIELDS TERMINATED BY '=';
|
||||
SELECT k,v from kv where k in ('md5','algorithm');
|
||||
SELECT k from kv where k ='mariadb-version';
|
||||
truncate table kv;
|
||||
|
||||
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
|
||||
eval LOAD DATA INFILE '$MYSQLD_DATADIR/test/v1badcheck.frm' REPLACE INTO TABLE kv FIELDS TERMINATED BY '=';
|
||||
SELECT k,v from kv where k in ('md5','algorithm');
|
||||
SELECT k from kv where k ='mariadb-version';
|
||||
truncate table kv;
|
||||
|
||||
--disable_warnings
|
||||
drop view if exists v1,v2,v3,v1badcheck;
|
||||
--enable_warnings
|
||||
|
||||
# Make it look like a MySQL directory now
|
||||
|
||||
--copy_file $MYSQLD_DATADIR/mysql/event.MYI $MYSQLD_DATADIR/mysql/ev_bk.MYI
|
||||
--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.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/v2.frm $MYSQLD_DATADIR/test/v2.frm
|
||||
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v3.frm $MYSQLD_DATADIR/test/v3.frm
|
||||
|
||||
flush tables;
|
||||
|
||||
create algorithm=temptable view v4 as select a from t1;
|
||||
show create view v1;
|
||||
show create view v2;
|
||||
show create view v3;
|
||||
show create view v4;
|
||||
|
||||
# here we test the fixing views from mysql to occur
|
||||
--replace_result $MYSQLTEST_VARDIR var
|
||||
--exec $MYSQL_UPGRADE --force 2>&1
|
||||
|
||||
show create view v1;
|
||||
show create view v2;
|
||||
show create view v3;
|
||||
show create view v4;
|
||||
|
||||
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
|
||||
eval LOAD DATA INFILE '$MYSQLD_DATADIR/test/v1.frm' REPLACE INTO TABLE kv FIELDS TERMINATED BY '=';
|
||||
SELECT k,v from kv where k in ('md5','algorithm');
|
||||
SELECT k from kv where k ='mariadb-version';
|
||||
truncate table kv;
|
||||
|
||||
--disable_warnings
|
||||
drop view if exists v1,v2,v3;
|
||||
--enable_warnings
|
||||
|
||||
|
||||
--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.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/v2.frm $MYSQLD_DATADIR/test/v2.frm
|
||||
--copy_file $MYSQL_TEST_DIR/std_data/mysql_upgrade/v3.frm $MYSQLD_DATADIR/test/v3.frm
|
||||
flush tables;
|
||||
|
||||
# check of binlog
|
||||
--exec $MYSQL_CHECK --write-binlog --upgrade-views=FROM_MYSQL --skip-fix-tables --all-databases 2>&1
|
||||
|
||||
--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 view v1,v2,v3,v4;
|
||||
drop table t1;
|
||||
|
@ -376,6 +376,7 @@ static SYMBOL symbols[] = {
|
||||
{ "MULTIPOINT", SYM(MULTIPOINT)},
|
||||
{ "MULTIPOLYGON", SYM(MULTIPOLYGON)},
|
||||
{ "MUTEX", SYM(MUTEX_SYM)},
|
||||
{ "MYSQL", SYM(MYSQL_SYM)},
|
||||
{ "MYSQL_ERRNO", SYM(MYSQL_ERRNO_SYM)},
|
||||
{ "NAME", SYM(NAME_SYM)},
|
||||
{ "NAMES", SYM(NAMES_SYM)},
|
||||
|
@ -314,7 +314,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
HA_CHECK_OPT *),
|
||||
int (handler::*operator_func)(THD *,
|
||||
HA_CHECK_OPT *),
|
||||
int (view_operator_func)(THD *, TABLE_LIST*))
|
||||
int (view_operator_func)(THD *, TABLE_LIST*,
|
||||
HA_CHECK_OPT *))
|
||||
{
|
||||
TABLE_LIST *table;
|
||||
SELECT_LEX *select= &thd->lex->select_lex;
|
||||
@ -380,7 +381,18 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
lex->query_tables_own_last= 0;
|
||||
|
||||
if (view_operator_func == NULL)
|
||||
{
|
||||
table->required_type=FRMTYPE_TABLE;
|
||||
DBUG_ASSERT(!lex->only_view);
|
||||
}
|
||||
else if (lex->only_view)
|
||||
{
|
||||
table->required_type= FRMTYPE_VIEW;
|
||||
}
|
||||
else if (!lex->only_view && lex->sql_command == SQLCOM_REPAIR)
|
||||
{
|
||||
table->required_type= FRMTYPE_TABLE;
|
||||
}
|
||||
|
||||
if (lex->sql_command == SQLCOM_CHECK ||
|
||||
lex->sql_command == SQLCOM_REPAIR ||
|
||||
@ -506,9 +518,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
}
|
||||
|
||||
/*
|
||||
CHECK TABLE command is only command where VIEW allowed here and this
|
||||
command use only temporary teble method for VIEWs resolving => there
|
||||
can't be VIEW tree substitition of join view => if opening table
|
||||
CHECK/REPAIR TABLE command is only command where VIEW allowed here and
|
||||
this command use only temporary table method for VIEWs resolving =>
|
||||
there can't be VIEW tree substitition of join view => if opening table
|
||||
succeed then table->table will have real TABLE pointer as value (in
|
||||
case of join view substitution table->table can be 0, but here it is
|
||||
impossible)
|
||||
@ -521,7 +533,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
ER_CHECK_NO_SUCH_TABLE, ER(ER_CHECK_NO_SUCH_TABLE));
|
||||
/* if it was a view will check md5 sum */
|
||||
if (table->view &&
|
||||
view_checksum(thd, table) == HA_ADMIN_WRONG_CHECKSUM)
|
||||
view_check(thd, table, check_opt) == HA_ADMIN_WRONG_CHECKSUM)
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM));
|
||||
if (thd->stmt_da->is_error() &&
|
||||
@ -536,7 +548,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
if (table->view)
|
||||
{
|
||||
DBUG_PRINT("admin", ("calling view_operator_func"));
|
||||
result_code= (*view_operator_func)(thd, table);
|
||||
result_code= (*view_operator_func)(thd, table, check_opt);
|
||||
goto send_result;
|
||||
}
|
||||
|
||||
@ -1071,7 +1083,7 @@ bool Check_table_statement::execute(THD *thd)
|
||||
|
||||
res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "check",
|
||||
lock_type, 0, 0, HA_OPEN_FOR_REPAIR, 0,
|
||||
&handler::ha_check, &view_checksum);
|
||||
&handler::ha_check, &view_check);
|
||||
|
||||
m_lex->select_lex.table_list.first= first_table;
|
||||
m_lex->query_tables= first_table;
|
||||
@ -1126,7 +1138,7 @@ bool Repair_table_statement::execute(THD *thd)
|
||||
TL_WRITE, 1,
|
||||
test(m_lex->check_opt.sql_flags & TT_USEFRM),
|
||||
HA_OPEN_FOR_REPAIR, &prepare_for_repair,
|
||||
&handler::ha_repair, 0);
|
||||
&handler::ha_repair, &view_repair);
|
||||
|
||||
/* ! we write after unlocking the table */
|
||||
if (!res && !m_lex->no_write_to_binlog)
|
||||
|
@ -643,7 +643,8 @@ found:
|
||||
open_table_error(share, share->error, share->open_errno, share->errarg);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
if (share->is_view && !(db_flags & OPEN_VIEW))
|
||||
if ((share->is_view && !(db_flags & OPEN_VIEW)) ||
|
||||
(!share->is_view && (db_flags & OPEN_VIEW_ONLY)))
|
||||
{
|
||||
open_table_error(share, 1, ENOENT, 0);
|
||||
DBUG_RETURN(0);
|
||||
@ -3027,7 +3028,11 @@ retry_share:
|
||||
mysql_mutex_lock(&LOCK_open);
|
||||
|
||||
if (!(share= get_table_share_with_discover(thd, table_list, key,
|
||||
key_length, OPEN_VIEW,
|
||||
key_length,
|
||||
(OPEN_VIEW |
|
||||
((table_list->required_type ==
|
||||
FRMTYPE_VIEW) ?
|
||||
OPEN_VIEW_ONLY : 0)),
|
||||
&error,
|
||||
hash_value)))
|
||||
{
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "sql_base.h" // open_table_uncached, lock_table_names
|
||||
#include "lock.h" // mysql_unlock_tables
|
||||
#include "strfunc.h" // find_type2, find_set
|
||||
#include "sql_view.h" // view_checksum
|
||||
#include "sql_truncate.h" // regenerate_locked_table
|
||||
#include "sql_partition.h" // mem_alloc_error,
|
||||
// generate_partition_syntax,
|
||||
|
177
sql/sql_view.cc
177
sql/sql_view.cc
@ -729,6 +729,26 @@ err:
|
||||
}
|
||||
|
||||
|
||||
static void make_view_filename(LEX_STRING *dir, char *dir_buff,
|
||||
size_t dir_buff_len,
|
||||
LEX_STRING *path, char *path_buff,
|
||||
size_t path_buff_len,
|
||||
LEX_STRING *file,
|
||||
TABLE_LIST *view)
|
||||
{
|
||||
/* print file name */
|
||||
dir->length= build_table_filename(dir_buff, dir_buff_len - 1,
|
||||
view->db, "", "", 0);
|
||||
dir->str= dir_buff;
|
||||
|
||||
path->length= build_table_filename(path_buff, path_buff_len - 1,
|
||||
view->db, view->table_name, reg_ext, 0);
|
||||
path->str= path_buff;
|
||||
|
||||
file->str= path->str + dir->length;
|
||||
file->length= path->length - dir->length;
|
||||
}
|
||||
|
||||
/* number of required parameters for making view */
|
||||
static const int required_view_parameters= 15;
|
||||
|
||||
@ -791,6 +811,86 @@ static File_option view_parameters[]=
|
||||
static LEX_STRING view_file_type[]= {{(char*) STRING_WITH_LEN("VIEW") }};
|
||||
|
||||
|
||||
int mariadb_fix_view(THD *thd, TABLE_LIST *view, bool wrong_checksum,
|
||||
bool swap_alg)
|
||||
{
|
||||
char dir_buff[FN_REFLEN + 1], path_buff[FN_REFLEN + 1];
|
||||
LEX_STRING dir, file, path;
|
||||
DBUG_ENTER("mariadb_fix_view");
|
||||
|
||||
if (!wrong_checksum && view->mariadb_version)
|
||||
DBUG_RETURN(HA_ADMIN_OK);
|
||||
|
||||
make_view_filename(&dir, dir_buff, sizeof(dir_buff),
|
||||
&path, path_buff, sizeof(path_buff),
|
||||
&file, view);
|
||||
/* init timestamp */
|
||||
if (!view->timestamp.str)
|
||||
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)
|
||||
{
|
||||
DBUG_ASSERT(view->algorithm == VIEW_ALGORITHM_MERGE ||
|
||||
view->algorithm == VIEW_ALGORITHM_TMPTABLE);
|
||||
if (view->algorithm == VIEW_ALGORITHM_MERGE)
|
||||
view->algorithm= VIEW_ALGORITHM_TMPTABLE;
|
||||
else
|
||||
view->algorithm= VIEW_ALGORITHM_MERGE;
|
||||
}
|
||||
else
|
||||
swap_alg= 0;
|
||||
if (wrong_checksum)
|
||||
{
|
||||
if (view->md5.length != 32)
|
||||
{
|
||||
if ((view->md5.str= (char *)thd->alloc(32 + 1)) == NULL)
|
||||
DBUG_RETURN(HA_ADMIN_FAILED);
|
||||
}
|
||||
view->calc_md5(view->md5.str);
|
||||
view->md5.length= 32;
|
||||
}
|
||||
view->mariadb_version= MYSQL_VERSION_ID;
|
||||
|
||||
if (sql_create_definition_file(&dir, &file, view_file_type,
|
||||
(uchar*)view, view_parameters))
|
||||
{
|
||||
sql_print_error("View '%-.192s'.'%-.192s': algorithm swap error.",
|
||||
view->db, view->table_name);
|
||||
DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
|
||||
}
|
||||
sql_print_information("View '%-.192s'.'%-.192s': versioned to %llu%s%s",
|
||||
view->db, view->table_name, view->mariadb_version,
|
||||
(wrong_checksum ? ", and checksum corrected" : ""),
|
||||
(swap_alg ?
|
||||
((view->algorithm == VIEW_ALGORITHM_MERGE) ?
|
||||
", and algorithm swapped to 'MERGE'"
|
||||
: ", and algorithm swapped to 'TEMPTABLE'")
|
||||
: ""));
|
||||
|
||||
|
||||
DBUG_RETURN(HA_ADMIN_OK);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Register VIEW (write .frm & process .frm's history backups)
|
||||
|
||||
@ -927,17 +1027,9 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
|
||||
}
|
||||
loop_out:
|
||||
/* print file name */
|
||||
dir.length= build_table_filename(dir_buff, sizeof(dir_buff) - 1,
|
||||
view->db, "", "", 0);
|
||||
dir.str= dir_buff;
|
||||
|
||||
path.length= build_table_filename(path_buff, sizeof(path_buff) - 1,
|
||||
view->db, view->table_name, reg_ext, 0);
|
||||
path.str= path_buff;
|
||||
|
||||
file.str= path.str + dir.length;
|
||||
file.length= path.length - dir.length;
|
||||
|
||||
make_view_filename(&dir, dir_buff, sizeof(dir_buff),
|
||||
&path, path_buff, sizeof(path_buff),
|
||||
&file, view);
|
||||
/* init timestamp */
|
||||
if (!view->timestamp.str)
|
||||
view->timestamp.str= view->timestamp_buffer;
|
||||
@ -1063,7 +1155,7 @@ err:
|
||||
|
||||
SYNOPSIS
|
||||
mysql_make_view()
|
||||
thd Thread handler
|
||||
thd Thread handle
|
||||
parser parser object
|
||||
table TABLE_LIST structure for filling
|
||||
flags flags
|
||||
@ -1634,7 +1726,7 @@ err:
|
||||
|
||||
SYNOPSIS
|
||||
mysql_drop_view()
|
||||
thd - thread handler
|
||||
thd - thread handle
|
||||
views - views to delete
|
||||
drop_mode - cascade/check
|
||||
|
||||
@ -1755,7 +1847,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
|
||||
|
||||
SYNOPSIS
|
||||
check_key_in_view()
|
||||
thd thread handler
|
||||
thd thread handle
|
||||
view view for check with opened table
|
||||
|
||||
DESCRIPTION
|
||||
@ -1941,6 +2033,63 @@ int view_checksum(THD *thd, TABLE_LIST *view)
|
||||
HA_ADMIN_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
Check view
|
||||
|
||||
@param thd thread handle
|
||||
@param view view for check
|
||||
@param check_opt check options
|
||||
|
||||
@retval HA_ADMIN_OK OK
|
||||
@retval HA_ADMIN_NOT_IMPLEMENTED it is not VIEW
|
||||
@retval HA_ADMIN_WRONG_CHECKSUM check sum is wrong
|
||||
*/
|
||||
int view_check(THD *thd, TABLE_LIST *view, HA_CHECK_OPT *check_opt)
|
||||
{
|
||||
int res;
|
||||
DBUG_ENTER("view_check");
|
||||
if ((res= view_checksum(thd, view)) != HA_ADMIN_OK)
|
||||
DBUG_RETURN(res);
|
||||
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_OK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Repair view
|
||||
|
||||
@param thd thread handle
|
||||
@param view view for check
|
||||
@param check_opt check options
|
||||
|
||||
@retval HA_ADMIN_OK OK
|
||||
@retval HA_ADMIN_NOT_IMPLEMENTED it is not VIEW
|
||||
@retval HA_ADMIN_WRONG_CHECKSUM check sum is wrong
|
||||
*/
|
||||
|
||||
int view_repair(THD *thd, TABLE_LIST *view, HA_CHECK_OPT *check_opt)
|
||||
{
|
||||
DBUG_ENTER("view_repair");
|
||||
bool swap_alg= (check_opt->sql_flags & TT_FROM_MYSQL);
|
||||
bool wrong_checksum= view_checksum(thd, view);
|
||||
int ret;
|
||||
if (wrong_checksum || swap_alg || (!view->mariadb_version))
|
||||
{
|
||||
ret= mariadb_fix_view(thd, view, wrong_checksum, swap_alg);
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
DBUG_RETURN(HA_ADMIN_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
rename view
|
||||
|
||||
|
@ -44,6 +44,8 @@ bool check_key_in_view(THD *thd, TABLE_LIST * view);
|
||||
bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view);
|
||||
|
||||
int view_checksum(THD *thd, TABLE_LIST *view);
|
||||
int view_check(THD *thd, TABLE_LIST *view, HA_CHECK_OPT *check_opt);
|
||||
int view_repair(THD *thd, TABLE_LIST *view, HA_CHECK_OPT *check_opt);
|
||||
|
||||
extern TYPELIB updatable_views_with_limit_typelib;
|
||||
|
||||
|
@ -1145,6 +1145,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
|
||||
%token MULTIPOINT
|
||||
%token MULTIPOLYGON
|
||||
%token MUTEX_SYM
|
||||
%token MYSQL_SYM
|
||||
%token MYSQL_ERRNO_SYM
|
||||
%token NAMES_SYM /* SQL-2003-N */
|
||||
%token NAME_SYM /* SQL-2003-N */
|
||||
@ -7191,7 +7192,7 @@ opt_checksum_type:
|
||||
;
|
||||
|
||||
repair:
|
||||
REPAIR opt_no_write_to_binlog table_or_tables
|
||||
REPAIR opt_no_write_to_binlog table_or_view
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
lex->sql_command = SQLCOM_REPAIR;
|
||||
@ -7204,6 +7205,15 @@ repair:
|
||||
table_list opt_mi_repair_type
|
||||
{
|
||||
LEX* lex= thd->lex;
|
||||
if ((lex->only_view &&
|
||||
((lex->check_opt.flags & (T_QUICK | T_EXTEND)) ||
|
||||
(lex->check_opt.sql_flags & TT_USEFRM))) ||
|
||||
(!lex->only_view &&
|
||||
(lex->check_opt.sql_flags & TT_FROM_MYSQL)))
|
||||
{
|
||||
my_parse_error(ER(ER_SYNTAX_ERROR));
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
DBUG_ASSERT(!lex->m_stmt);
|
||||
lex->m_stmt= new (thd->mem_root) Repair_table_statement(lex);
|
||||
if (lex->m_stmt == NULL)
|
||||
@ -7225,6 +7235,7 @@ mi_repair_type:
|
||||
QUICK { Lex->check_opt.flags|= T_QUICK; }
|
||||
| EXTENDED_SYM { Lex->check_opt.flags|= T_EXTEND; }
|
||||
| USE_FRM { Lex->check_opt.sql_flags|= TT_USEFRM; }
|
||||
| FROM MYSQL_SYM { Lex->check_opt.sql_flags|= TT_FROM_MYSQL; }
|
||||
;
|
||||
|
||||
analyze:
|
||||
@ -7257,7 +7268,7 @@ binlog_base64_event:
|
||||
;
|
||||
|
||||
check:
|
||||
CHECK_SYM table_or_tables
|
||||
CHECK_SYM table_or_view
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
|
||||
@ -7275,6 +7286,13 @@ check:
|
||||
table_list opt_mi_check_type
|
||||
{
|
||||
LEX* lex= thd->lex;
|
||||
if (lex->only_view &&
|
||||
(lex->check_opt.flags & (T_QUICK | T_FAST | T_EXTEND |
|
||||
T_CHECK_ONLY_CHANGED)))
|
||||
{
|
||||
my_parse_error(ER(ER_SYNTAX_ERROR));
|
||||
MYSQL_YYABORT;
|
||||
}
|
||||
DBUG_ASSERT(!lex->m_stmt);
|
||||
lex->m_stmt= new (thd->mem_root) Check_table_statement(lex);
|
||||
if (lex->m_stmt == NULL)
|
||||
@ -7382,6 +7400,7 @@ keycache:
|
||||
LEX *lex=Lex;
|
||||
lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE;
|
||||
lex->ident= $6;
|
||||
lex->only_view= FALSE;
|
||||
}
|
||||
;
|
||||
|
||||
@ -7426,6 +7445,7 @@ preload:
|
||||
LEX *lex=Lex;
|
||||
lex->sql_command=SQLCOM_PRELOAD_KEYS;
|
||||
lex->alter_info.reset();
|
||||
lex->only_view= FALSE;
|
||||
}
|
||||
preload_list_or_parts
|
||||
{}
|
||||
@ -13187,6 +13207,7 @@ keyword_sp:
|
||||
| MULTIPOINT {}
|
||||
| MULTIPOLYGON {}
|
||||
| MUTEX_SYM {}
|
||||
| MYSQL_SYM {}
|
||||
| MYSQL_ERRNO_SYM {}
|
||||
| NAME_SYM {}
|
||||
| NAMES_SYM {}
|
||||
@ -13786,7 +13807,18 @@ lock:
|
||||
|
||||
table_or_tables:
|
||||
TABLE_SYM
|
||||
{ Lex->only_view= FALSE; }
|
||||
| TABLES
|
||||
{ Lex->only_view= FALSE; }
|
||||
;
|
||||
|
||||
table_or_view:
|
||||
TABLE_SYM
|
||||
{ Lex->only_view= FALSE; }
|
||||
| TABLES
|
||||
{ Lex->only_view= FALSE; }
|
||||
| VIEW_SYM
|
||||
{ Lex->only_view= TRUE; }
|
||||
;
|
||||
|
||||
table_lock_list:
|
||||
|
Loading…
x
Reference in New Issue
Block a user