maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #09684
MDEV-8909 union parser cleanup
Hi Sergei,
Please review a patch for MDEV-8909.
It removes some old remainders that are not needed anymore.
Thanks.
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index adc443a..28add87 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -2455,7 +2455,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; }
@@ -2605,13 +2604,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 58fa7ec..0fc3613 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -530,7 +530,6 @@ class st_select_lex_node {
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();
@@ -936,7 +935,10 @@ class st_select_lex: public st_select_lex_node
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 7dc0ef4..01f1fdf 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -7433,22 +7433,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 be426ad..469472b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -711,34 +711,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)
{
@@ -8558,8 +8530,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 ')'
;
@@ -8575,8 +8546,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 ')'
;
@@ -8592,8 +8562,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 ')'
;
@@ -8609,8 +8578,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; }
@@ -11249,12 +11217,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);
}
;
@@ -11299,16 +11262,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;
}
;
Follow ups