summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-06-07 16:23:47 +0400
committerAlexander Barkov <bar@mariadb.com>2020-06-07 16:23:47 +0400
commitfad348a9a69211351c3b27b21ba03ef910c8f623 (patch)
tree87baa2f348d5c2f8c36920e065a72b7d2c709f2a
parent4612cb88fa8b391812db44327040a5878e5dbc44 (diff)
downloadmariadb-git-fad348a9a69211351c3b27b21ba03ef910c8f623.tar.gz
MDEV-22822 sql_mode="oracle" cannot declare without variable errors
-rw-r--r--mysql-test/suite/compat/oracle/r/parser.result34
-rw-r--r--mysql-test/suite/compat/oracle/t/parser.test47
-rw-r--r--sql/sql_yacc_ora.yy4
3 files changed, 83 insertions, 2 deletions
diff --git a/mysql-test/suite/compat/oracle/r/parser.result b/mysql-test/suite/compat/oracle/r/parser.result
index 1c60c1434a3..0b573027c6d 100644
--- a/mysql-test/suite/compat/oracle/r/parser.result
+++ b/mysql-test/suite/compat/oracle/r/parser.result
@@ -607,5 +607,39 @@ ERROR HY000: Unknown system variable 'password'
SELECT @@GLOBAL.role;
ERROR HY000: Unknown system variable 'role'
#
+# MDEV-22822 sql_mode="oracle" cannot declare without variable errors
+#
+# It's OK to have no declarations between DECLARE and BEGIN.
+#
+BEGIN
+DECLARE
+BEGIN
+NULL;
+END;
+EXCEPTION
+WHEN OTHERS THEN
+NULL;
+END;
+//
+DECLARE
+BEGIN
+NULL;
+EXCEPTION
+WHEN OTHERS THEN
+NULL;
+END;
+//
+BEGIN
+<<lab>>
+DECLARE
+BEGIN
+NULL;
+END;
+EXCEPTION
+WHEN OTHERS THEN
+NULL;
+END;
+//
+#
# End of 10.3 tests
#
diff --git a/mysql-test/suite/compat/oracle/t/parser.test b/mysql-test/suite/compat/oracle/t/parser.test
index 067fd9beb48..4d558c5d153 100644
--- a/mysql-test/suite/compat/oracle/t/parser.test
+++ b/mysql-test/suite/compat/oracle/t/parser.test
@@ -410,5 +410,52 @@ SELECT @@GLOBAL.role;
--echo #
+--echo # MDEV-22822 sql_mode="oracle" cannot declare without variable errors
+--echo #
+--echo # It's OK to have no declarations between DECLARE and BEGIN.
+--echo #
+
+DELIMITER //;
+BEGIN
+ DECLARE
+ BEGIN
+ NULL;
+ END;
+EXCEPTION
+WHEN OTHERS THEN
+ NULL;
+END;
+//
+DELIMITER ;//
+
+
+DELIMITER //;
+DECLARE
+BEGIN
+ NULL;
+EXCEPTION
+WHEN OTHERS THEN
+ NULL;
+END;
+//
+DELIMITER ;//
+
+
+DELIMITER //;
+BEGIN
+<<lab>>
+ DECLARE
+ BEGIN
+ NULL;
+ END;
+EXCEPTION
+WHEN OTHERS THEN
+ NULL;
+END;
+//
+DELIMITER ;//
+
+
+--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index 60ff19e06b2..942f7892f04 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -4463,7 +4463,7 @@ sp_labeled_block:
{
Lex->sp_block_init(thd, &$1);
}
- sp_decl_body_list
+ opt_sp_decl_body_list
{
if (unlikely(Lex->sp_block_with_exceptions_finalize_declarations(thd)))
MYSQL_YYABORT;
@@ -4505,7 +4505,7 @@ sp_unlabeled_block:
MYSQL_YYABORT;
Lex->sp_block_init(thd);
}
- sp_decl_body_list
+ opt_sp_decl_body_list
{
if (unlikely(Lex->sp_block_with_exceptions_finalize_declarations(thd)))
MYSQL_YYABORT;