diff options
author | Alexander Barkov <bar@mariadb.org> | 2016-09-07 11:36:22 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2016-09-07 11:36:22 +0400 |
commit | dd283db6bc4ecbb18127a8b10d49073047ea990b (patch) | |
tree | 242a6127c02a0c964ad1d91ece98b0301dd81328 | |
parent | 5e20c61fcc85ac8b7347c74e5d2b8c7685c0fa0a (diff) | |
download | mariadb-git-dd283db6bc4ecbb18127a8b10d49073047ea990b.tar.gz |
MDEV-8909 union parser cleanup
This is the final patch removing some old remainders that are
not needed anymore.
(Other clean-ups were done in earlier commits)
-rw-r--r-- | sql/sql_lex.cc | 8 | ||||
-rw-r--r-- | sql/sql_lex.h | 6 | ||||
-rw-r--r-- | sql/sql_parse.cc | 26 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 57 |
4 files changed, 20 insertions, 77 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 0217b8d8ef8..a22d2964fa5 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2457,7 +2457,6 @@ bool st_select_lex::mark_as_dependent(THD *thd, st_select_lex *last, return FALSE; } -bool st_select_lex_node::set_braces(bool value) { return 1; } bool st_select_lex_node::inc_in_sum_expr() { return 1; } uint st_select_lex_node::get_in_sum_expr() { return 0; } TABLE_LIST* st_select_lex_node::get_table_list() { return 0; } @@ -2607,13 +2606,6 @@ st_select_lex* st_select_lex::outer_select() } -bool st_select_lex::set_braces(bool value) -{ - braces= value; - return 0; -} - - bool st_select_lex::inc_in_sum_expr() { in_sum_expr++; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index af461d05036..b8a5eb7027e 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -531,7 +531,6 @@ public: virtual st_select_lex* outer_select()= 0; virtual st_select_lex* return_after_parsing()= 0; - virtual bool set_braces(bool value); virtual bool inc_in_sum_expr(); virtual uint get_in_sum_expr(); virtual TABLE_LIST* get_table_list(); @@ -955,7 +954,10 @@ public: bool mark_as_dependent(THD *thd, st_select_lex *last, Item *dependency); - bool set_braces(bool value); + void set_braces(bool value) + { + braces= value; + } bool inc_in_sum_expr(); uint get_in_sum_expr(); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c76e22a2e57..3d123837b99 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7468,22 +7468,16 @@ mysql_new_select(LEX *lex, bool move_down) my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO"); DBUG_RETURN(TRUE); } - if (lex->proc_list.elements!=0) - { - my_error(ER_WRONG_USAGE, MYF(0), "UNION", - "SELECT ... PROCEDURE ANALYSE()"); - DBUG_RETURN(TRUE); - } - if (lex->current_select->order_list.first && !lex->current_select->braces) - { - my_error(ER_WRONG_USAGE, MYF(0), "UNION", "ORDER BY"); - DBUG_RETURN(1); - } - if (lex->current_select->explicit_limit && !lex->current_select->braces) - { - my_error(ER_WRONG_USAGE, MYF(0), "UNION", "LIMIT"); - DBUG_RETURN(1); - } + + // SELECT 1 FROM t1 PROCEDURE ANALYSE() UNION ... -- not possible + DBUG_ASSERT(lex->proc_list.elements == 0); + // SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 -- not possible + DBUG_ASSERT(!lex->current_select->order_list.first || + lex->current_select->braces); + // SELECT 1 FROM t1 LIMIT 1 UNION SELECT 1 FROM t1; -- not possible + DBUG_ASSERT(!lex->current_select->explicit_limit || + lex->current_select->braces); + select_lex->include_neighbour(lex->current_select); SELECT_LEX_UNIT *unit= select_lex->master_unit(); if (!unit->fake_select_lex && unit->add_fake_select_lex(lex->thd)) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 5908c7d3cb8..a61cabe3581 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -714,34 +714,6 @@ bool add_select_to_union_list(LEX *lex, bool is_union_distinct, return FALSE; } -/** - @brief Initializes a SELECT_LEX for a query within parentheses (aka - braces). - - @return false if successful, true if an error was reported. In the latter - case parsing should stop. - */ -bool setup_select_in_parentheses(LEX *lex) -{ - SELECT_LEX * sel= lex->current_select; - /* - if (sel->set_braces(1)) - { - my_parse_error(lex->thd, ER_SYNTAX_ERROR); - return TRUE; - } - */ - DBUG_ASSERT(sel->braces); - if (sel->linkage == UNION_TYPE && - !sel->master_unit()->first_select()->braces && - sel->master_unit()->first_select()->linkage == - UNION_TYPE) - { - my_parse_error(lex->thd, ER_SYNTAX_ERROR); - return TRUE; - } - return FALSE; -} static bool add_create_index_prepare(LEX *lex, Table_ident *table) { @@ -8398,8 +8370,7 @@ select_paren: SELECT_SYM select_options_and_item_list select_part3 opt_select_lock_type { - if (setup_select_in_parentheses(Lex)) - MYSQL_YYABORT; + DBUG_ASSERT(Lex->current_select->braces); } | '(' select_paren ')' ; @@ -8415,8 +8386,7 @@ select_paren_union_query_term: SELECT_SYM select_options_and_item_list select_part3_union_query_term opt_select_lock_type { - if (setup_select_in_parentheses(Lex)) - MYSQL_YYABORT; + DBUG_ASSERT(Lex->current_select->braces); } | '(' select_paren_union_query_term ')' ; @@ -8432,8 +8402,7 @@ select_paren_view: SELECT_SYM select_options_and_item_list select_part3_view opt_select_lock_type { - if (setup_select_in_parentheses(Lex)) - MYSQL_YYABORT; + DBUG_ASSERT(Lex->current_select->braces); } | '(' select_paren_view ')' ; @@ -8449,8 +8418,7 @@ select_paren_derived: opt_limit_clause opt_select_lock_type { - if (setup_select_in_parentheses(Lex)) - MYSQL_YYABORT; + DBUG_ASSERT(Lex->current_select->braces); $$= Lex->current_select->master_unit()->first_select(); } | '(' select_paren_derived ')' { $$= $2; } @@ -11076,12 +11044,7 @@ union_list_derived: select_init2_derived: select_part2_derived { - LEX *lex= Lex; - if (lex->current_select->set_braces(0)) - { - my_parse_error(thd, ER_SYNTAX_ERROR); - MYSQL_YYABORT; - } + Select->set_braces(0); } ; @@ -11126,16 +11089,8 @@ select_derived: derived_query_specification: SELECT_SYM select_derived_init select_derived2 { - LEX *lex= Lex; - SELECT_LEX *sel= lex->current_select; if ($2) - { - if (sel->set_braces(1)) - { - my_parse_error(thd, ER_SYNTAX_ERROR); - MYSQL_YYABORT; - } - } + Select->set_braces(1); $$= NULL; } ; |