summaryrefslogtreecommitdiff
path: root/sql/sql_yacc.yy
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r--sql/sql_yacc.yy14
1 files changed, 14 insertions, 0 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index d2f7e73b2b8..b9e9b0126df 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1318,6 +1318,20 @@ sp_decls:
}
| sp_decls sp_decl ';'
{
+ /* We check for declarations out of (standard) order this way
+ because letting the grammar rules reflect it caused tricky
+ shift/reduce conflicts with the wrong result. (And we get
+ better error handling this way.) */
+ if (($2.vars || $2.conds) && ($1.curs || $1.hndlrs))
+ { /* Variable or condition following cursor or handler */
+ send_error(YYTHD, ER_SP_VARCOND_AFTER_CURSHNDLR);
+ YYABORT;
+ }
+ if ($2.curs && $1.hndlrs)
+ { /* Cursor following handler */
+ send_error(YYTHD, ER_SP_CURSOR_AFTER_HANDLER);
+ YYABORT;
+ }
$$.vars= $1.vars + $2.vars;
$$.conds= $1.conds + $2.conds;
$$.hndlrs= $1.hndlrs + $2.hndlrs;