mirror of
https://github.com/MariaDB/server.git
synced 2025-08-30 11:22:14 +03:00
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)
This commit is contained in:
@@ -2457,7 +2457,6 @@ bool st_select_lex::mark_as_dependent(THD *thd, st_select_lex *last,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool st_select_lex_node::set_braces(bool value) { return 1; }
|
|
||||||
bool st_select_lex_node::inc_in_sum_expr() { return 1; }
|
bool st_select_lex_node::inc_in_sum_expr() { return 1; }
|
||||||
uint st_select_lex_node::get_in_sum_expr() { return 0; }
|
uint st_select_lex_node::get_in_sum_expr() { return 0; }
|
||||||
TABLE_LIST* st_select_lex_node::get_table_list() { 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()
|
bool st_select_lex::inc_in_sum_expr()
|
||||||
{
|
{
|
||||||
in_sum_expr++;
|
in_sum_expr++;
|
||||||
|
@@ -531,7 +531,6 @@ public:
|
|||||||
virtual st_select_lex* outer_select()= 0;
|
virtual st_select_lex* outer_select()= 0;
|
||||||
virtual st_select_lex* return_after_parsing()= 0;
|
virtual st_select_lex* return_after_parsing()= 0;
|
||||||
|
|
||||||
virtual bool set_braces(bool value);
|
|
||||||
virtual bool inc_in_sum_expr();
|
virtual bool inc_in_sum_expr();
|
||||||
virtual uint get_in_sum_expr();
|
virtual uint get_in_sum_expr();
|
||||||
virtual TABLE_LIST* get_table_list();
|
virtual TABLE_LIST* get_table_list();
|
||||||
@@ -955,7 +954,10 @@ public:
|
|||||||
|
|
||||||
bool mark_as_dependent(THD *thd, st_select_lex *last, Item *dependency);
|
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();
|
bool inc_in_sum_expr();
|
||||||
uint get_in_sum_expr();
|
uint get_in_sum_expr();
|
||||||
|
|
||||||
|
@@ -7468,22 +7468,16 @@ mysql_new_select(LEX *lex, bool move_down)
|
|||||||
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
|
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "INTO");
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
if (lex->proc_list.elements!=0)
|
|
||||||
{
|
// SELECT 1 FROM t1 PROCEDURE ANALYSE() UNION ... -- not possible
|
||||||
my_error(ER_WRONG_USAGE, MYF(0), "UNION",
|
DBUG_ASSERT(lex->proc_list.elements == 0);
|
||||||
"SELECT ... PROCEDURE ANALYSE()");
|
// SELECT 1 FROM t1 ORDER BY 1 UNION SELECT 1 FROM t1 -- not possible
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_ASSERT(!lex->current_select->order_list.first ||
|
||||||
}
|
lex->current_select->braces);
|
||||||
if (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 ||
|
||||||
my_error(ER_WRONG_USAGE, MYF(0), "UNION", "ORDER BY");
|
lex->current_select->braces);
|
||||||
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_lex->include_neighbour(lex->current_select);
|
select_lex->include_neighbour(lex->current_select);
|
||||||
SELECT_LEX_UNIT *unit= select_lex->master_unit();
|
SELECT_LEX_UNIT *unit= select_lex->master_unit();
|
||||||
if (!unit->fake_select_lex && unit->add_fake_select_lex(lex->thd))
|
if (!unit->fake_select_lex && unit->add_fake_select_lex(lex->thd))
|
||||||
|
@@ -714,34 +714,6 @@ bool add_select_to_union_list(LEX *lex, bool is_union_distinct,
|
|||||||
return FALSE;
|
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)
|
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
|
SELECT_SYM select_options_and_item_list select_part3
|
||||||
opt_select_lock_type
|
opt_select_lock_type
|
||||||
{
|
{
|
||||||
if (setup_select_in_parentheses(Lex))
|
DBUG_ASSERT(Lex->current_select->braces);
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
}
|
||||||
| '(' select_paren ')'
|
| '(' select_paren ')'
|
||||||
;
|
;
|
||||||
@@ -8415,8 +8386,7 @@ select_paren_union_query_term:
|
|||||||
SELECT_SYM select_options_and_item_list select_part3_union_query_term
|
SELECT_SYM select_options_and_item_list select_part3_union_query_term
|
||||||
opt_select_lock_type
|
opt_select_lock_type
|
||||||
{
|
{
|
||||||
if (setup_select_in_parentheses(Lex))
|
DBUG_ASSERT(Lex->current_select->braces);
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
}
|
||||||
| '(' select_paren_union_query_term ')'
|
| '(' select_paren_union_query_term ')'
|
||||||
;
|
;
|
||||||
@@ -8432,8 +8402,7 @@ select_paren_view:
|
|||||||
SELECT_SYM select_options_and_item_list select_part3_view
|
SELECT_SYM select_options_and_item_list select_part3_view
|
||||||
opt_select_lock_type
|
opt_select_lock_type
|
||||||
{
|
{
|
||||||
if (setup_select_in_parentheses(Lex))
|
DBUG_ASSERT(Lex->current_select->braces);
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
}
|
||||||
| '(' select_paren_view ')'
|
| '(' select_paren_view ')'
|
||||||
;
|
;
|
||||||
@@ -8449,8 +8418,7 @@ select_paren_derived:
|
|||||||
opt_limit_clause
|
opt_limit_clause
|
||||||
opt_select_lock_type
|
opt_select_lock_type
|
||||||
{
|
{
|
||||||
if (setup_select_in_parentheses(Lex))
|
DBUG_ASSERT(Lex->current_select->braces);
|
||||||
MYSQL_YYABORT;
|
|
||||||
$$= Lex->current_select->master_unit()->first_select();
|
$$= Lex->current_select->master_unit()->first_select();
|
||||||
}
|
}
|
||||||
| '(' select_paren_derived ')' { $$= $2; }
|
| '(' select_paren_derived ')' { $$= $2; }
|
||||||
@@ -11076,12 +11044,7 @@ union_list_derived:
|
|||||||
select_init2_derived:
|
select_init2_derived:
|
||||||
select_part2_derived
|
select_part2_derived
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
Select->set_braces(0);
|
||||||
if (lex->current_select->set_braces(0))
|
|
||||||
{
|
|
||||||
my_parse_error(thd, ER_SYNTAX_ERROR);
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -11126,16 +11089,8 @@ select_derived:
|
|||||||
derived_query_specification:
|
derived_query_specification:
|
||||||
SELECT_SYM select_derived_init select_derived2
|
SELECT_SYM select_derived_init select_derived2
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
|
||||||
SELECT_LEX *sel= lex->current_select;
|
|
||||||
if ($2)
|
if ($2)
|
||||||
{
|
Select->set_braces(1);
|
||||||
if (sel->set_braces(1))
|
|
||||||
{
|
|
||||||
my_parse_error(thd, ER_SYNTAX_ERROR);
|
|
||||||
MYSQL_YYABORT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$$= NULL;
|
$$= NULL;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
Reference in New Issue
Block a user