Hi, Oleksandr! On Dec 22, Oleksandr Byelkin wrote:
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a5a62ae..6611411 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -237,6 +237,11 @@ static sp_head *make_sp_head(THD *thd, sp_name *name,
static bool maybe_start_compound_statement(THD *thd) { + if (YYLIP->eof()) + { + my_parse_error(thd, ER_SYNTAX_ERROR); + return 1; + } no, I don't like that. Syntax errors should be issued by the parser, they should follow from the grammar, not be hard-coded in some explicit checks in the code.
The problem in the current grammar - as I see it, that a code block is executed before any keyword is matched. This code block assumes it's the sp_unlabeled_control rule, while it could be anything.
The fix would be to remove this code block and put this code after the first keyword is matched.
Here is the problem. It is unlabeled context so empty label should be pushed but it can not be done without that maybe_start_compound_statement() if move it all inside sp_control_content, then how to detect labeled or unlabeled...
So I have no any idea how it can be fixed.
Like the attached untested patch. I simply duplicated sp_control_content rule and merged sp_unlabeled_control into it. See how maybe_start_compound_statement() is executed only *after* the first keyword is matched. Of course, it's only to show the idea - the fix cannot be pushed that way. If I were fixing it, this patch would've been the first step, and the second step would be to merge this back into sp_control_content removing as much of the code duplication as possible. Regards, Sergei Chief Architect MariaDB and security@mariadb.org -- Vote for my Percona Live 2016 talks: https://www.percona.com/live/data-performance-conference-2016/sessions/maria... https://www.percona.com/live/data-performance-conference-2016/sessions/maria...