Commit cfb63459 authored by Alexander Barkov's avatar Alexander Barkov

Fixed that 'FOR i IN 1..10' with no spaces around '..' returned a syntax error.

This is a fix for "MDEV-10580 sql_mode=ORACLE: FOR loop statement"
The tokenizer now treats digits followed by two dots (e.g. '1..')
as an integer number '1' followed by DOT_DOT_SYM.
Previously this sequence was treated as a double number '1.' followed by '.'.
parent bf573e21
......@@ -776,7 +776,7 @@ SELECT @v;
DROP PROCEDURE p1;
# Testing the FOR loop statement
CREATE TABLE t1 (a INT);
FOR i IN 1 .. 3
FOR i IN 1..3
LOOP
INSERT INTO t1 VALUES (i);
END LOOP;
......
......@@ -849,7 +849,7 @@ DROP PROCEDURE p1;
CREATE TABLE t1 (a INT);
DELIMITER /;
FOR i IN 1 .. 3
FOR i IN 1..3
LOOP
INSERT INTO t1 VALUES (i);
END LOOP;
......
......@@ -1705,8 +1705,13 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
return(IDENT_QUOTED);
}
case MY_LEX_INT_OR_REAL: // Complete int or incomplete real
if (c != '.')
{ // Found complete integer number.
if (c != '.' || lip->yyPeek() == '.')
{
/*
Found a complete integer number:
- the number is either not followed by a dot at all, or
- the number is followed by a double dot as in: FOR i IN 1..10
*/
yylval->lex_str=get_token(lip, 0, lip->yyLength());
return int_token(yylval->lex_str.str, (uint) yylval->lex_str.length);
}
......
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