summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-06-03 11:11:53 +0200
committerSergei Golubchik <serg@mariadb.org>2015-06-03 15:44:31 +0200
commit64569fa81de811b2c355c8d51bf4d3daa6b56444 (patch)
treee5acc92ebb25c0dae813a4d39f03747c5710c076 /sql
parent0ffef5d2a72bad8fe0cb72b78e426f4f50a29bf2 (diff)
downloadmariadb-git-64569fa81de811b2c355c8d51bf4d3daa6b56444.tar.gz
parser: better error messages for CHECK/REPAIR VIEW
remove the code that checks for correct options for for CHECK/REPAIR VIEW. Rewrite the grammar for the parser to check that. This changes error messages as -ERROR 42000: You have an error ... near '' at line 1 +ERROR 42000: You have an error ... near 'quick' at line 1
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_lex.cc1
-rw-r--r--sql/sql_yacc.yy60
2 files changed, 28 insertions, 33 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 74591b5371e..a71051e801b 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -533,6 +533,7 @@ void lex_start(THD *thd)
lex->is_lex_started= TRUE;
lex->used_tables= 0;
+ lex->only_view= FALSE;
lex->reset_slave_info.all= false;
lex->limit_rows_examined= 0;
lex->limit_rows_examined_cnt= ULONGLONG_MAX;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index cc16101c38b..5b2f10b278c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -7191,8 +7191,13 @@ opt_checksum_type:
| EXTENDED_SYM { Lex->check_opt.flags= T_EXTEND; }
;
+repair_table_or_view:
+ table_or_tables table_list opt_mi_repair_type
+ | VIEW_SYM { Lex->only_view= TRUE; } table_list opt_view_repair_type
+ ;
+
repair:
- REPAIR opt_no_write_to_binlog table_or_view
+ REPAIR opt_no_write_to_binlog
{
LEX *lex=Lex;
lex->sql_command = SQLCOM_REPAIR;
@@ -7202,18 +7207,9 @@ repair:
/* Will be overriden during execution. */
YYPS->m_lock_type= TL_UNLOCK;
}
- table_list opt_mi_repair_type
+ repair_table_or_view
{
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)
@@ -7235,6 +7231,10 @@ 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; }
+ ;
+
+opt_view_repair_type:
+ /* empty */ { }
| FROM MYSQL_SYM { Lex->check_opt.sql_flags|= TT_FROM_MYSQL; }
;
@@ -7267,30 +7267,27 @@ binlog_base64_event:
}
;
-check:
- CHECK_SYM table_or_view
+check_view_or_table:
+ table_or_tables table_list opt_mi_check_type
+ | VIEW_SYM { Lex->only_view= TRUE; } table_list opt_view_check_type
+ ;
+
+check: CHECK_SYM
{
LEX *lex=Lex;
- if (lex->sphead)
- {
- my_error(ER_SP_BADSTATEMENT, MYF(0), "CHECK");
- MYSQL_YYABORT;
- }
lex->sql_command = SQLCOM_CHECK;
lex->check_opt.init();
lex->alter_info.reset();
/* Will be overriden during execution. */
YYPS->m_lock_type= TL_UNLOCK;
}
- table_list opt_mi_check_type
+ check_view_or_table
{
LEX* lex= thd->lex;
- if (lex->only_view &&
- (lex->check_opt.flags & (T_QUICK | T_FAST | T_EXTEND |
- T_CHECK_ONLY_CHANGED)))
+ if (lex->sphead)
{
- my_parse_error(ER(ER_SYNTAX_ERROR));
+ my_error(ER_SP_BADSTATEMENT, MYF(0), "CHECK");
MYSQL_YYABORT;
}
DBUG_ASSERT(!lex->m_stmt);
@@ -7319,6 +7316,11 @@ mi_check_type:
| FOR_SYM UPGRADE_SYM { Lex->check_opt.sql_flags|= TT_FOR_UPGRADE; }
;
+opt_view_check_type:
+ /* empty */ { }
+ | FOR_SYM UPGRADE_SYM { Lex->check_opt.sql_flags|= TT_FOR_UPGRADE; }
+ ;
+
optimize:
OPTIMIZE opt_no_write_to_binlog table_or_tables
{
@@ -7400,7 +7402,6 @@ keycache:
LEX *lex=Lex;
lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE;
lex->ident= $6;
- lex->only_view= FALSE;
}
;
@@ -7445,7 +7446,6 @@ preload:
LEX *lex=Lex;
lex->sql_command=SQLCOM_PRELOAD_KEYS;
lex->alter_info.reset();
- lex->only_view= FALSE;
}
preload_list_or_parts
{}
@@ -11610,7 +11610,6 @@ show_param:
lex->sql_command = SQLCOM_SHOW_CREATE;
if (!lex->select_lex.add_table_to_list(thd, $3, NULL,0))
MYSQL_YYABORT;
- lex->only_view= 0;
lex->create_info.storage_media= HA_SM_DEFAULT;
}
| CREATE VIEW_SYM table_ident
@@ -13806,13 +13805,8 @@ lock:
;
table_or_tables:
- TABLE_SYM { Lex->only_view= FALSE; }
- | TABLES { Lex->only_view= FALSE; }
- ;
-
-table_or_view:
- table_or_tables
- | VIEW_SYM { Lex->only_view= TRUE; }
+ TABLE_SYM { }
+ | TABLES { }
;
table_lock_list: