diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-05-04 22:00:24 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-05-04 22:00:24 +0200 |
commit | 49c853fb948aeaeb5c7e3f02da3f14da51ee4100 (patch) | |
tree | 8c3d487a02209cc0c6f126144f1340fc5897d527 /sql/sql_yacc.yy | |
parent | ae18a28500974351cf42fa3cac67c83e0647d510 (diff) | |
parent | 4c87f727734955f9e4a0ffde25aae4d43ec0b2a5 (diff) | |
download | mariadb-git-49c853fb948aeaeb5c7e3f02da3f14da51ee4100.tar.gz |
Merge branch '5.5' into 10.0
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a23a88b7559..03022c7ed19 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 @@ -1331,6 +1331,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 */ @@ -7018,6 +7019,7 @@ alter: { Lex->name.str= 0; Lex->name.length= 0; + Lex->only_view= FALSE; Lex->sql_command= SQLCOM_ALTER_TABLE; Lex->duplicates= DUP_ERROR; Lex->col_list.empty(); @@ -7910,7 +7912,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; @@ -7923,6 +7925,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) @@ -7944,6 +7955,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: @@ -8063,7 +8075,7 @@ binlog_base64_event: ; check: - CHECK_SYM table_or_tables + CHECK_SYM table_or_view { LEX *lex=Lex; @@ -8081,6 +8093,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) @@ -8188,6 +8207,7 @@ keycache: LEX *lex=Lex; lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE; lex->ident= $6; + lex->only_view= FALSE; } ; @@ -8232,6 +8252,7 @@ preload: LEX *lex=Lex; lex->sql_command=SQLCOM_PRELOAD_KEYS; lex->alter_info.reset(); + lex->only_view= FALSE; } preload_list_or_parts {} @@ -10093,7 +10114,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; } @@ -14199,6 +14221,7 @@ keyword_sp: | MULTIPOINT {} | MULTIPOLYGON {} | MUTEX_SYM {} + | MYSQL_SYM {} | MYSQL_ERRNO_SYM {} | NAME_SYM {} | NAMES_SYM {} @@ -14827,8 +14850,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: @@ -15732,6 +15760,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; } ; |