Skip to content

Commit

Permalink
MDEV-12390 Wrong error line numbers reported with sql_mode=IGNORE_SPACE
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Barkov committed Mar 29, 2017
1 parent 3f7455c commit c5520a3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
21 changes: 21 additions & 0 deletions mysql-test/r/sql_mode.result
Original file line number Diff line number Diff line change
Expand Up @@ -759,3 +759,24 @@ a b
1 NULL
1 NULL
DROP TABLE t1;
#
# MDEV-12390 Wrong error line numbers reported with sql_mode=IGNORE_SPACE
#
SET sql_mode=IGNORE_SPACE;
CREATE PROCEDURE p1()
BEGIN
SELECT 1+1;
syntax error;
END;
$$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'error;
END' at line 4
SET sql_mode=DEFAULT;
CREATE PROCEDURE p1()
BEGIN
SELECT 1+1;
syntax error;
END;
$$
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'error;
END' at line 4
Expand Down
27 changes: 27 additions & 0 deletions mysql-test/t/sql_mode.test
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,30 @@ ALTER TABLE t1 ADD b INT;
EXECUTE stmt;
SELECT * FROM t1;
DROP TABLE t1;

--echo #
--echo # MDEV-12390 Wrong error line numbers reported with sql_mode=IGNORE_SPACE
--echo #

SET sql_mode=IGNORE_SPACE;
DELIMITER $$;
--error ER_PARSE_ERROR
CREATE PROCEDURE p1()
BEGIN
SELECT 1+1;
syntax error;
END;
$$
DELIMITER ;$$


SET sql_mode=DEFAULT;
DELIMITER $$;
--error ER_PARSE_ERROR
CREATE PROCEDURE p1()
BEGIN
SELECT 1+1;
syntax error;
END;
$$
DELIMITER ;$$
5 changes: 4 additions & 1 deletion sql/sql_lex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,10 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
below by checking start != lex->ptr.
*/
for (; state_map[(uchar) c] == MY_LEX_SKIP ; c= lip->yyGet())
;
{
if (c == '\n')
lip->yylineno++;
}
}
if (start == lip->get_ptr() && c == '.' &&
ident_map[(uchar) lip->yyPeek()])
Expand Down

0 comments on commit c5520a3

Please sign in to comment.