Commit c8dbef22 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin Committed by Daniel Black

MDEV-6916 REPAIR VIEW / mysql migration

from: r4407
parent e5191dd1
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#define TT_USEFRM 1 #define TT_USEFRM 1
#define TT_FOR_UPGRADE 2 #define TT_FOR_UPGRADE 2
#define TT_FROM_MYSQL 4
/* Bits set in out_flag */ /* Bits set in out_flag */
#define O_NEW_DATA 2 #define O_NEW_DATA 2
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
// the following is for checking tables // the following is for checking tables
#define HA_ADMIN_VIEW_REPAIR_IS_DONE 2
#define HA_ADMIN_ALREADY_DONE 1 #define HA_ADMIN_ALREADY_DONE 1
#define HA_ADMIN_OK 0 #define HA_ADMIN_OK 0
#define HA_ADMIN_NOT_IMPLEMENTED -1 #define HA_ADMIN_NOT_IMPLEMENTED -1
...@@ -56,6 +57,7 @@ ...@@ -56,6 +57,7 @@
#define HA_ADMIN_NEEDS_UPGRADE -10 #define HA_ADMIN_NEEDS_UPGRADE -10
#define HA_ADMIN_NEEDS_ALTER -11 #define HA_ADMIN_NEEDS_ALTER -11
#define HA_ADMIN_NEEDS_CHECK -12 #define HA_ADMIN_NEEDS_CHECK -12
#define HA_ADMIN_NEEDS_REPAIR -13
/* Bits in table_flags() to show what database can do */ /* Bits in table_flags() to show what database can do */
......
...@@ -376,6 +376,7 @@ static SYMBOL symbols[] = { ...@@ -376,6 +376,7 @@ static SYMBOL symbols[] = {
{ "MULTIPOINT", SYM(MULTIPOINT)}, { "MULTIPOINT", SYM(MULTIPOINT)},
{ "MULTIPOLYGON", SYM(MULTIPOLYGON)}, { "MULTIPOLYGON", SYM(MULTIPOLYGON)},
{ "MUTEX", SYM(MUTEX_SYM)}, { "MUTEX", SYM(MUTEX_SYM)},
{ "MYSQL", SYM(MYSQL_SYM)},
{ "MYSQL_ERRNO", SYM(MYSQL_ERRNO_SYM)}, { "MYSQL_ERRNO", SYM(MYSQL_ERRNO_SYM)},
{ "NAME", SYM(NAME_SYM)}, { "NAME", SYM(NAME_SYM)},
{ "NAMES", SYM(NAMES_SYM)}, { "NAMES", SYM(NAMES_SYM)},
......
...@@ -6565,3 +6565,9 @@ ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT ...@@ -6565,3 +6565,9 @@ ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT
ER_NO_SUCH_TABLE_IN_ENGINE 42S02 ER_NO_SUCH_TABLE_IN_ENGINE 42S02
eng "Table '%-.192s.%-.192s' doesn't exist in engine" eng "Table '%-.192s.%-.192s' doesn't exist in engine"
swe "Det finns ingen tabell som heter '%-.192s.%-.192s' i handlern" swe "Det finns ingen tabell som heter '%-.192s.%-.192s' i handlern"
ER_NO_MARIADB_SERVER_FIELD
eng "view '%-.192s.%-.192s' has no field mariadb server in its .frm file"
ER_VIEW_REPAIR_IS_DONE
eng "view is repaired"
ER_NEEDS_REPAIR
eng "needs repair"
...@@ -314,7 +314,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -314,7 +314,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
HA_CHECK_OPT *), HA_CHECK_OPT *),
int (handler::*operator_func)(THD *, int (handler::*operator_func)(THD *,
HA_CHECK_OPT *), HA_CHECK_OPT *),
int (view_operator_func)(THD *, TABLE_LIST*)) int (view_operator_func)(THD *, TABLE_LIST*,
HA_CHECK_OPT *))
{ {
TABLE_LIST *table; TABLE_LIST *table;
SELECT_LEX *select= &thd->lex->select_lex; SELECT_LEX *select= &thd->lex->select_lex;
...@@ -380,7 +381,18 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -380,7 +381,18 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
lex->query_tables_own_last= 0; lex->query_tables_own_last= 0;
if (view_operator_func == NULL) if (view_operator_func == NULL)
{
table->required_type=FRMTYPE_TABLE; 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 || if (lex->sql_command == SQLCOM_CHECK ||
lex->sql_command == SQLCOM_REPAIR || lex->sql_command == SQLCOM_REPAIR ||
...@@ -506,9 +518,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -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 CHECK/REPAIR TABLE command is only command where VIEW allowed here and
command use only temporary teble method for VIEWs resolving => there this command use only temporary table method for VIEWs resolving =>
can't be VIEW tree substitition of join view => if opening table 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 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 case of join view substitution table->table can be 0, but here it is
impossible) impossible)
...@@ -521,7 +533,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -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)); ER_CHECK_NO_SUCH_TABLE, ER(ER_CHECK_NO_SUCH_TABLE));
/* if it was a view will check md5 sum */ /* if it was a view will check md5 sum */
if (table->view && 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, push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM)); ER_VIEW_CHECKSUM, ER(ER_VIEW_CHECKSUM));
if (thd->stmt_da->is_error() && if (thd->stmt_da->is_error() &&
...@@ -536,7 +548,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -536,7 +548,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
if (table->view) if (table->view)
{ {
DBUG_PRINT("admin", ("calling view_operator_func")); 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; goto send_result;
} }
...@@ -867,6 +879,22 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -867,6 +879,22 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
fatal_error=1; fatal_error=1;
break; break;
} }
case HA_ADMIN_VIEW_REPAIR_IS_DONE:
{
protocol->store(STRING_WITH_LEN("status"), system_charset_info);
protocol->store(ER(ER_VIEW_REPAIR_IS_DONE),
strlen(ER(ER_VIEW_REPAIR_IS_DONE)),
system_charset_info);
break;
}
case HA_ADMIN_NEEDS_REPAIR:
{
protocol->store(STRING_WITH_LEN("status"), system_charset_info);
protocol->store(ER(ER_NEEDS_REPAIR),
strlen(ER(ER_NEEDS_REPAIR)),
system_charset_info);
break;
}
default: // Probably HA_ADMIN_INTERNAL_ERROR default: // Probably HA_ADMIN_INTERNAL_ERROR
{ {
...@@ -1071,7 +1099,7 @@ bool Check_table_statement::execute(THD *thd) ...@@ -1071,7 +1099,7 @@ bool Check_table_statement::execute(THD *thd)
res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "check", res= mysql_admin_table(thd, first_table, &m_lex->check_opt, "check",
lock_type, 0, 0, HA_OPEN_FOR_REPAIR, 0, 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->select_lex.table_list.first= first_table;
m_lex->query_tables= first_table; m_lex->query_tables= first_table;
...@@ -1126,7 +1154,7 @@ bool Repair_table_statement::execute(THD *thd) ...@@ -1126,7 +1154,7 @@ bool Repair_table_statement::execute(THD *thd)
TL_WRITE, 1, TL_WRITE, 1,
test(m_lex->check_opt.sql_flags & TT_USEFRM), test(m_lex->check_opt.sql_flags & TT_USEFRM),
HA_OPEN_FOR_REPAIR, &prepare_for_repair, HA_OPEN_FOR_REPAIR, &prepare_for_repair,
&handler::ha_repair, 0); &handler::ha_repair, &view_repair);
/* ! we write after unlocking the table */ /* ! we write after unlocking the table */
if (!res && !m_lex->no_write_to_binlog) if (!res && !m_lex->no_write_to_binlog)
......
...@@ -643,7 +643,8 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, ...@@ -643,7 +643,8 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
open_table_error(share, share->error, share->open_errno, share->errarg); open_table_error(share, share->error, share->open_errno, share->errarg);
DBUG_RETURN(0); 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); open_table_error(share, 1, ENOENT, 0);
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -3022,12 +3023,17 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, ...@@ -3022,12 +3023,17 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
else if (table_list->open_strategy == TABLE_LIST::OPEN_STUB) else if (table_list->open_strategy == TABLE_LIST::OPEN_STUB)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
retry_share: retry_share:
mysql_mutex_lock(&LOCK_open); mysql_mutex_lock(&LOCK_open);
if (!(share= get_table_share_with_discover(thd, table_list, key, 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, &error,
hash_value))) hash_value)))
{ {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "sql_base.h" // open_table_uncached, lock_table_names #include "sql_base.h" // open_table_uncached, lock_table_names
#include "lock.h" // mysql_unlock_tables #include "lock.h" // mysql_unlock_tables
#include "strfunc.h" // find_type2, find_set #include "strfunc.h" // find_type2, find_set
#include "sql_view.h" // view_checksum #include "sql_view.h" // view_check
#include "sql_truncate.h" // regenerate_locked_table #include "sql_truncate.h" // regenerate_locked_table
#include "sql_partition.h" // mem_alloc_error, #include "sql_partition.h" // mem_alloc_error,
// generate_partition_syntax, // generate_partition_syntax,
......
...@@ -729,6 +729,26 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, ...@@ -729,6 +729,26 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
} }
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 */ /* number of required parameters for making view */
static const int required_view_parameters= 15; static const int required_view_parameters= 15;
...@@ -791,6 +811,81 @@ static File_option view_parameters[]= ...@@ -791,6 +811,81 @@ static File_option view_parameters[]=
static LEX_STRING view_file_type[]= {{(char*) STRING_WITH_LEN("VIEW") }}; 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 (view->algorithm == VIEW_ALGORITHM_UNDEFINED &&
!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;
}
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': algorithm swapped to '%s'",
view->db, view->table_name,
(view->algorithm == VIEW_ALGORITHM_MERGE)?
"MERGE":"TEMPTABLE");
DBUG_RETURN(HA_ADMIN_VIEW_REPAIR_IS_DONE);
}
/* /*
Register VIEW (write .frm & process .frm's history backups) Register VIEW (write .frm & process .frm's history backups)
...@@ -927,17 +1022,9 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, ...@@ -927,17 +1022,9 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
} }
loop_out: loop_out:
/* print file name */ /* print file name */
dir.length= build_table_filename(dir_buff, sizeof(dir_buff) - 1, make_view_filename(&dir, dir_buff, sizeof(dir_buff),
view->db, "", "", 0); &path, path_buff, sizeof(path_buff),
dir.str= dir_buff; &file, view);
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;
/* init timestamp */ /* init timestamp */
if (!view->timestamp.str) if (!view->timestamp.str)
view->timestamp.str= view->timestamp_buffer; view->timestamp.str= view->timestamp_buffer;
...@@ -1063,7 +1150,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, ...@@ -1063,7 +1150,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
SYNOPSIS SYNOPSIS
mysql_make_view() mysql_make_view()
thd Thread handler thd Thread handle
parser parser object parser parser object
table TABLE_LIST structure for filling table TABLE_LIST structure for filling
flags flags flags flags
...@@ -1634,7 +1721,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, ...@@ -1634,7 +1721,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
SYNOPSIS SYNOPSIS
mysql_drop_view() mysql_drop_view()
thd - thread handler thd - thread handle
views - views to delete views - views to delete
drop_mode - cascade/check drop_mode - cascade/check
...@@ -1755,7 +1842,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) ...@@ -1755,7 +1842,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
SYNOPSIS SYNOPSIS
check_key_in_view() check_key_in_view()
thd thread handler thd thread handle
view view for check with opened table view view for check with opened table
DESCRIPTION DESCRIPTION
...@@ -1941,6 +2028,63 @@ int view_checksum(THD *thd, TABLE_LIST *view) ...@@ -1941,6 +2028,63 @@ int view_checksum(THD *thd, TABLE_LIST *view)
HA_ADMIN_OK); 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_NO_MARIADB_SERVER_FIELD,
ER(ER_NO_MARIADB_SERVER_FIELD),
view->db,
view->table_name);
DBUG_RETURN(HA_ADMIN_NEEDS_REPAIR);
}
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) &&
(!view->mariadb_version));
bool wrong_checksum= view_checksum(thd, view);
if (wrong_checksum || swap_alg)
{
DBUG_RETURN(mariadb_fix_view(thd, view, wrong_checksum, swap_alg));
}
DBUG_RETURN(HA_ADMIN_OK);
}
/* /*
rename view rename view
......
...@@ -44,6 +44,8 @@ bool check_key_in_view(THD *thd, TABLE_LIST * 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); bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view);
int view_checksum(THD *thd, 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; extern TYPELIB updatable_views_with_limit_typelib;
......
...@@ -1145,6 +1145,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1145,6 +1145,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token MULTIPOINT %token MULTIPOINT
%token MULTIPOLYGON %token MULTIPOLYGON
%token MUTEX_SYM %token MUTEX_SYM
%token MYSQL_SYM
%token MYSQL_ERRNO_SYM %token MYSQL_ERRNO_SYM
%token NAMES_SYM /* SQL-2003-N */ %token NAMES_SYM /* SQL-2003-N */
%token NAME_SYM /* SQL-2003-N */ %token NAME_SYM /* SQL-2003-N */
...@@ -7191,11 +7192,16 @@ opt_checksum_type: ...@@ -7191,11 +7192,16 @@ opt_checksum_type:
; ;
repair: repair:
REPAIR opt_no_write_to_binlog table_or_tables REPAIR opt_no_write_to_binlog table_or_view
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->sql_command = SQLCOM_REPAIR; lex->sql_command = SQLCOM_REPAIR;
lex->no_write_to_binlog= $2; lex->no_write_to_binlog= $2;
if (lex->no_write_to_binlog && lex->only_view)
{
my_parse_error(ER(ER_SYNTAX_ERROR));
MYSQL_YYABORT;
}
lex->check_opt.init(); lex->check_opt.init();
lex->alter_info.reset(); lex->alter_info.reset();
/* Will be overriden during execution. */ /* Will be overriden during execution. */
...@@ -7204,6 +7210,15 @@ repair: ...@@ -7204,6 +7210,15 @@ repair:
table_list opt_mi_repair_type table_list opt_mi_repair_type
{ {
LEX* lex= thd->lex; 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); DBUG_ASSERT(!lex->m_stmt);
lex->m_stmt= new (thd->mem_root) Repair_table_statement(lex); lex->m_stmt= new (thd->mem_root) Repair_table_statement(lex);
if (lex->m_stmt == NULL) if (lex->m_stmt == NULL)
...@@ -7225,6 +7240,7 @@ mi_repair_type: ...@@ -7225,6 +7240,7 @@ mi_repair_type:
QUICK { Lex->check_opt.flags|= T_QUICK; } QUICK { Lex->check_opt.flags|= T_QUICK; }
| EXTENDED_SYM { Lex->check_opt.flags|= T_EXTEND; } | EXTENDED_SYM { Lex->check_opt.flags|= T_EXTEND; }
| USE_FRM { Lex->check_opt.sql_flags|= TT_USEFRM; } | USE_FRM { Lex->check_opt.sql_flags|= TT_USEFRM; }
| FROM MYSQL_SYM { Lex->check_opt.sql_flags|= TT_FROM_MYSQL; }
; ;
analyze: analyze:
...@@ -7257,7 +7273,7 @@ binlog_base64_event: ...@@ -7257,7 +7273,7 @@ binlog_base64_event:
; ;
check: check:
CHECK_SYM table_or_tables CHECK_SYM table_or_view
{ {
LEX *lex=Lex; LEX *lex=Lex;
...@@ -7275,6 +7291,13 @@ check: ...@@ -7275,6 +7291,13 @@ check:
table_list opt_mi_check_type table_list opt_mi_check_type
{ {
LEX* lex= thd->lex; 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); DBUG_ASSERT(!lex->m_stmt);
lex->m_stmt= new (thd->mem_root) Check_table_statement(lex); lex->m_stmt= new (thd->mem_root) Check_table_statement(lex);
if (lex->m_stmt == NULL) if (lex->m_stmt == NULL)
...@@ -7382,6 +7405,7 @@ keycache: ...@@ -7382,6 +7405,7 @@ keycache:
LEX *lex=Lex; LEX *lex=Lex;
lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE; lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE;
lex->ident= $6; lex->ident= $6;
lex->only_view= FALSE;
} }
; ;
...@@ -7426,6 +7450,7 @@ preload: ...@@ -7426,6 +7450,7 @@ preload:
LEX *lex=Lex; LEX *lex=Lex;
lex->sql_command=SQLCOM_PRELOAD_KEYS; lex->sql_command=SQLCOM_PRELOAD_KEYS;
lex->alter_info.reset(); lex->alter_info.reset();
lex->only_view= FALSE;
} }
preload_list_or_parts preload_list_or_parts
{} {}
...@@ -13187,6 +13212,7 @@ keyword_sp: ...@@ -13187,6 +13212,7 @@ keyword_sp:
| MULTIPOINT {} | MULTIPOINT {}
| MULTIPOLYGON {} | MULTIPOLYGON {}
| MUTEX_SYM {} | MUTEX_SYM {}
| MYSQL_SYM {}
| MYSQL_ERRNO_SYM {} | MYSQL_ERRNO_SYM {}
| NAME_SYM {} | NAME_SYM {}
| NAMES_SYM {} | NAMES_SYM {}
...@@ -13786,7 +13812,18 @@ lock: ...@@ -13786,7 +13812,18 @@ lock:
table_or_tables: table_or_tables:
TABLE_SYM TABLE_SYM
{ Lex->only_view= FALSE; }
| TABLES
{ Lex->only_view= FALSE; }
;
table_or_view:
TABLE_SYM
{ Lex->only_view= FALSE; }
| TABLES | 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