summaryrefslogtreecommitdiff
path: root/sql/sql_yacc.yy
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-06-01 15:51:25 +0200
committerSergei Golubchik <serg@mariadb.org>2015-06-01 15:51:25 +0200
commit5091a4ba755250ed8e35f4f5a39a118d476cd8f1 (patch)
tree370ba468d78204544b56e9d967d8d09e1317a1ed /sql/sql_yacc.yy
parent84eaf0911f311acba797c265ef7508ab6c108b35 (diff)
parent0880284bf715b4916cc735e19b76d1062c2bfdcf (diff)
downloadmariadb-git-5091a4ba755250ed8e35f4f5a39a118d476cd8f1.tar.gz
Merge tag 'mariadb-10.0.19' into 10.1
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r--sql/sql_yacc.yy57
1 files changed, 50 insertions, 7 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index f3616f26c38..e54a315894c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2010, 2014, Monty Program Ab.
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -62,6 +62,7 @@
#include "keycaches.h"
#include "set_var.h"
#include "rpl_mi.h"
+#include "lex_token.h"
/* this is to get the bison compilation windows warnings out */
#ifdef _MSC_VER
@@ -1370,6 +1371,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 */
@@ -7094,6 +7096,7 @@ alter:
ALTER
{
Lex->name= null_lex_str;
+ Lex->only_view= FALSE;
Lex->sql_command= SQLCOM_ALTER_TABLE;
Lex->duplicates= DUP_ERROR;
Lex->select_lex.init_order();
@@ -7963,7 +7966,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;
@@ -7976,6 +7979,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_sql_cmd);
lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_repair_table();
if (lex->m_sql_cmd == NULL)
@@ -7997,6 +8009,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:
@@ -8116,7 +8129,7 @@ binlog_base64_event:
;
check:
- CHECK_SYM table_or_tables
+ CHECK_SYM table_or_view
{
LEX *lex=Lex;
@@ -8134,6 +8147,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_sql_cmd);
lex->m_sql_cmd= new (thd->mem_root) Sql_cmd_check_table();
if (lex->m_sql_cmd == NULL)
@@ -8241,6 +8261,7 @@ keycache:
LEX *lex=Lex;
lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE;
lex->ident= $6;
+ lex->only_view= FALSE;
}
;
@@ -8285,6 +8306,7 @@ preload:
LEX *lex=Lex;
lex->sql_command=SQLCOM_PRELOAD_KEYS;
lex->alter_info.reset();
+ lex->only_view= FALSE;
}
preload_list_or_parts
{}
@@ -10168,7 +10190,8 @@ udf_expr:
parse it out. If we hijack the input stream with
remember_name we may get quoted or escaped names.
*/
- else if ($2->type() != Item::FIELD_ITEM)
+ else if ($2->type() != Item::FIELD_ITEM &&
+ $2->type() != Item::REF_ITEM /* For HAVING */ )
$2->set_name($1, (uint) ($3 - $1), thd->charset());
$$= $2;
}
@@ -13470,6 +13493,13 @@ literal:
| temporal_literal { $$= $1; }
| NULL_SYM
{
+ /*
+ For the digest computation, in this context only,
+ NULL is considered a literal, hence reduced to '?'
+ REDUCE:
+ TOK_GENERIC_VALUE := NULL_SYM
+ */
+ YYLIP->reduce_digest_token(TOK_GENERIC_VALUE, NULL_SYM);
$$ = new (thd->mem_root) Item_null();
if ($$ == NULL)
MYSQL_YYABORT;
@@ -14322,6 +14352,7 @@ keyword_sp:
| MULTIPOINT {}
| MULTIPOLYGON {}
| MUTEX_SYM {}
+ | MYSQL_SYM {}
| MYSQL_ERRNO_SYM {}
| NAME_SYM {}
| NAMES_SYM {}
@@ -14995,8 +15026,13 @@ lock:
;
table_or_tables:
- TABLE_SYM {}
- | 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_lock_list:
@@ -15896,6 +15932,13 @@ subselect_end:
*/
lex->current_select->select_n_where_fields+=
child->select_n_where_fields;
+
+ /*
+ Aggregate functions in having clause may add fields to an outer
+ select. Count them also.
+ */
+ lex->current_select->select_n_having_items+=
+ child->select_n_having_items;
}
;