Commit bf573e21 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-10580 sql_mode=ORACLE: FOR loop statement

Fixed a crash when trying to use a FOR loop as a compound statement
outside of an SP. A bug in 051e415d8a251bd70e9b73619dbcc40f3c65371d.
parent 30bec863
......@@ -775,6 +775,18 @@ SELECT @v;
6
DROP PROCEDURE p1;
# Testing the FOR loop statement
CREATE TABLE t1 (a INT);
FOR i IN 1 .. 3
LOOP
INSERT INTO t1 VALUES (i);
END LOOP;
/
SELECT * FROM t1;
a
1
2
3
DROP TABLE t1;
CREATE FUNCTION f1 (lower_bound INT, upper_bound INT, lim INT) RETURN INT
AS
total INT := 0;
......
......@@ -847,6 +847,18 @@ DROP PROCEDURE p1;
--echo # Testing the FOR loop statement
CREATE TABLE t1 (a INT);
DELIMITER /;
FOR i IN 1 .. 3
LOOP
INSERT INTO t1 VALUES (i);
END LOOP;
/
DELIMITER ;/
SELECT * FROM t1;
DROP TABLE t1;
DELIMITER /;
--error ER_PARSE_ERROR
CREATE FUNCTION f1 (lower_bound INT, upper_bound INT, lim INT) RETURN INT
......
......@@ -3647,6 +3647,8 @@ sp_unlabeled_control:
| FOR_SYM
{
// See "The FOR LOOP statement" comments in sql_lex.cc
if (Lex->maybe_start_compound_statement(thd))
MYSQL_YYABORT;
Lex->sp_block_init(thd); // The outer DECLARE..BEGIN..END block
}
sp_for_loop_index_and_bounds
......
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