There is a shift/reduce conflict in the grammar in sql_yacc.yy when parsing a query like this:
The parser does not know what the left parenthesis means, either it continues the data type specifying the length:
or it's a CHAR with no length (i.e. length==1) followed by a start of a subselect:
Note, the latter query is accepted by the parse, but it's syntactically is wrong. A correct query would be:
Fortunately, currently the wrong query returns an error anyway:
But it should be fixed to return a syntax error instead, because the RETURN keyword is obviously missing.
An idea for a fix:
The sp_proc_stmt rule in sql_yacc.yy should be split into two parts:
1. statements that are allowed in RETURN clause
2. statements that are not allowed in RETURN clause
Subselect should go into #2.
This will fix the error message, as well as remove some shift/reduce conflicts.