Skip to content

Commit 1f4f729

Browse files
author
Alexander Barkov
committed
sql_yacc.yy cleanup, to simplify further changes for MDEV-8909.
- Moving "SELECT_SYM select_init2_derived opt_table_expression" from query_term into a new separate rule query_specification, and using query_specification in the beginning of query_term. - query_term now does not have a %type, query_specification has a %type instead. This removes duplicate code that returns Lex->current_select->master_unit()->first_select();
1 parent b799449 commit 1f4f729

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

sql/sql_yacc.yy

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
19191919
%type <variable> internal_variable_name
19201920

19211921
%type <select_lex> subselect
1922-
get_select_lex query_term
1922+
get_select_lex
19231923
query_expression_body
19241924

19251925
%type <boolfunc2creator> comp_op
@@ -16359,24 +16359,33 @@ union_option:
1635916359
| ALL { $$=0; }
1636016360
;
1636116361

16362+
/*
16363+
Corresponds to the SQL Standard
16364+
<query specification> ::=
16365+
SELECT [ <set quantifier> ] <select list> <table expression>
16366+
16367+
Notes:
16368+
- We allow more options in addition to <set quantifier>
16369+
- <table expression> is optional in MariaDB
16370+
*/
16371+
query_specification:
16372+
SELECT_SYM select_init2_derived opt_table_expression
16373+
;
16374+
1636216375
query_term:
16363-
SELECT_SYM select_init2_derived
16364-
opt_table_expression
16376+
query_specification
1636516377
opt_order_clause
1636616378
opt_limit_clause
1636716379
opt_select_lock_type
16368-
{
16369-
$$= Lex->current_select->master_unit()->first_select();
16370-
}
1637116380
| '(' select_paren_derived ')'
1637216381
opt_union_order_or_limit
16373-
{
16374-
$$= Lex->current_select->master_unit()->first_select();
16375-
}
1637616382
;
1637716383

1637816384
query_expression_body:
1637916385
query_term
16386+
{
16387+
$$= Lex->current_select->master_unit()->first_select();
16388+
}
1638016389
| query_expression_body union_head_non_top query_term
1638116390
{
1638216391
Lex->pop_context();
@@ -16388,7 +16397,7 @@ query_expression_body:
1638816397
subselect:
1638916398
subselect_start opt_with_clause query_expression_body subselect_end
1639016399
{
16391-
$3->set_with_clause($2);
16400+
$3->set_with_clause($2);
1639216401
$$= $3;
1639316402
}
1639416403
;

0 commit comments

Comments
 (0)