Skip to content

Commit

Permalink
MDEV-10580 sql_mode=ORACLE: FOR loop statement
Browse files Browse the repository at this point in the history
Fixed a crash when trying to use a FOR loop as a compound statement
outside of an SP. A bug in 051e415.
  • Loading branch information
Alexander Barkov committed Apr 5, 2017
1 parent 30bec86 commit bf573e2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mysql-test/suite/compat/oracle/r/sp.result
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions mysql-test/suite/compat/oracle/t/sp.test
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions sql/sql_yacc_ora.yy
Expand Up @@ -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
Expand Down

0 comments on commit bf573e2

Please sign in to comment.