← Back to team overview

maria-developers team mailing list archive

Re: [Commits] 93a7c11: MDEV-8380: Subquery parse error

 

Hi, Oleksandr!

On Sep 14, Oleksandr Byelkin wrote:
> >> diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
> >> index 5e58ceb..f7eed09 100644
> >> --- a/sql/sql_parse.cc
> >> +++ b/sql/sql_parse.cc
> >> @@ -6932,11 +6932,28 @@ mysql_new_select(LEX *lex, bool move_down)
> >>     }
> >>     else
> >>     {
> >> +    bool const outer_most= (lex->current_select->master_unit() == &lex->unit);
> >> +    if (outer_most && lex->result)
> >> +    {
> >> +      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);
> >> +    }
> > why couldn't parser do it?
> because sometimes it allowed, sometimes no.

Of course. All syntax constructs are "sometimes allowed, sometimes not".
But normally the parser issues the sytnax error, not the code after it.

> >> @@ -8414,7 +8411,45 @@ select_init2:
> >>             union_clause
> >>           ;
> >>   
> >> +/*
> >> +  Theoretically we can merge all 3 right hand sides of the select_part2
> >> +  rule into one, however such a transformation adds one shift/reduce
> >> +  conflict more.
> >> +*/
> >>   select_part2:
> >> +          select_options_and_item_list
> >> +          opt_order_clause
> >> +          opt_limit_clause
> >> +          opt_select_lock_type
> >> +        | select_options_and_item_list into opt_select_lock_type
> >> +        | select_options_and_item_list
> >> +          opt_into
> >> +          from_clause
> >> +          opt_where_clause
> >> +          opt_group_clause
> >> +          opt_having_clause
> >> +          opt_order_clause
> >> +          opt_limit_clause
> >> +          opt_procedure_clause
> >> +          opt_into
> >> +          opt_select_lock_type
> > why not table_expression here?
> Maybe to make the following check possible (to avoid double INTO). Now 
> they rewrited this part made rules returning syntax constructions, but 
> it s too much changes for bugfix.

So, why the parser cannot check for duplicate INTO?

> >> +          {
> >> +            if ($2 && $10)
> >> +            {
> >> +              /* double "INTO" clause */
> >> +              my_error(ER_WRONG_USAGE, MYF(0), "INTO", "INTO");
> >> +              MYSQL_YYABORT;
> >> +            }
> >> +            if ($9 && ($2 || $10))
> >> +            {
> >> +              /* "INTO" with "PROCEDURE ANALYSE" */
> >> +              my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", "INTO");
> >> +              MYSQL_YYABORT;
> >> +            }
> >> +          }

Regards,
Sergei


References