Commit 6b97b0c5 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-9166 Wrong error message and shift/reduce conflicts in the RETURNS clause

parent d0dc7b3e
......@@ -779,7 +779,7 @@ drop procedure bug11394|
CREATE PROCEDURE BUG_12490() HELP CONTENTS;
ERROR 0A000: HELP is not allowed in stored procedures
CREATE FUNCTION BUG_12490() RETURNS INT HELP CONTENTS;
ERROR 0A000: HELP is not allowed in stored procedures
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'HELP CONTENTS' at line 1
CREATE TABLE t_bug_12490(a int);
CREATE TRIGGER BUG_12490 BEFORE UPDATE ON t_bug_12490 FOR EACH ROW HELP CONTENTS;
ERROR 0A000: HELP is not allowed in stored procedures
......
......@@ -1093,7 +1093,7 @@ delimiter ;|
#
--error ER_SP_BADSTATEMENT
CREATE PROCEDURE BUG_12490() HELP CONTENTS;
--error ER_SP_BADSTATEMENT
--error ER_PARSE_ERROR
CREATE FUNCTION BUG_12490() RETURNS INT HELP CONTENTS;
CREATE TABLE t_bug_12490(a int);
--error ER_SP_BADSTATEMENT
......
......@@ -994,10 +994,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%parse-param { THD *thd }
%lex-param { THD *thd }
/*
Currently there are 160 shift/reduce conflicts.
Currently there are 142 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
%expect 160
%expect 142
/*
Comments for TOKENS.
......@@ -1926,6 +1926,7 @@ END_OF_INPUT
%type <NONE> call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt
%type <NONE> sp_proc_stmt_statement sp_proc_stmt_return
sp_proc_stmt_in_returns_clause
%type <NONE> sp_proc_stmt_compound_ok
%type <NONE> sp_proc_stmt_if
%type <NONE> sp_labeled_control sp_unlabeled_control
......@@ -3652,18 +3653,31 @@ sp_opt_default:
| DEFAULT expr { $$ = $2; }
;
sp_proc_stmt:
sp_proc_stmt_statement
| sp_proc_stmt_return
/*
ps_proc_stmt_in_returns_clause is a statement that is allowed
in the RETURNS clause of a stored function definition directly,
without the BEGIN..END block.
It should not include any syntax structures starting with '(', to avoid
shift/reduce conflicts with the rule "field_type" and its sub-rules
that scan an optional length, like CHAR(1) or YEAR(4).
See MDEV-9166.
*/
sp_proc_stmt_in_returns_clause:
sp_proc_stmt_return
| sp_labeled_block
| sp_unlabeled_block
| sp_labeled_control
| sp_proc_stmt_compound_ok
;
sp_proc_stmt:
sp_proc_stmt_in_returns_clause
| sp_proc_stmt_statement
| sp_proc_stmt_leave
| sp_proc_stmt_iterate
| sp_proc_stmt_open
| sp_proc_stmt_fetch
| sp_proc_stmt_close
| sp_proc_stmt_compound_ok
;
sp_proc_stmt_compound_ok:
......@@ -16405,7 +16419,7 @@ sf_tail:
lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
}
sp_proc_stmt /* $15 */
sp_proc_stmt_in_returns_clause /* $15 */
{
LEX *lex= thd->lex;
sp_head *sp= lex->sphead;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment