From 781e54a86ac423c13b46317453f6d89a880c83cd Mon Sep 17 00:00:00 2001
From: halfspawn <j.brauge@qualiac.com>
Date: Tue, 28 Mar 2017 09:33:54 +0200
Subject: [PATCH] Correct yyline no when sql_mode include IGNORE_SPACE

---
 mysql-test/suite/compat/oracle/r/package.result           | 14 +++++++-------
 mysql-test/suite/compat/oracle/r/sp-cursor-decl.result    |  6 +++---
 mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result | 10 +++++-----
 mysql-test/suite/compat/oracle/r/sp-cursor.result         |  2 +-
 mysql-test/suite/compat/oracle/r/sp-row.result            |  2 +-
 mysql-test/suite/compat/oracle/r/sp.result                |  4 ++--
 sql/sql_lex.cc                                            |  6 ++++--
 7 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/mysql-test/suite/compat/oracle/r/package.result b/mysql-test/suite/compat/oracle/r/package.result
index 0ad77a8..84dad05 100644
--- a/mysql-test/suite/compat/oracle/r/package.result
+++ b/mysql-test/suite/compat/oracle/r/package.result
@@ -98,7 +98,7 @@ 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 ';
 FUNCTION f4 RETURN INT;
-END' at line 3
+END' at line 4
 #
 # Syntax error inside a CREATE PACKAGE, outside of a routine definition
 #
@@ -111,7 +111,7 @@ 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 'AS BEGIN RETURN 10; END;
 FUNCTION f4 RETURN INT;
-END' at line 3
+END' at line 4
 #
 # Syntax error inside a CREATE PACKAGE BODY, inside a routine definition
 #
@@ -121,7 +121,7 @@ FUNCTION f2 RETURN INT; -- Missing "AS BEGIN..END;"
 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 '; -- Missing "AS BEGIN..END;"
-END' at line 2
+END' at line 3
 #
 # Syntax error inside a CREATE PACKAGE BODY, outside a routine definition
 #
@@ -133,7 +133,7 @@ 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 'SOME SYNTAX ERROR;
 FUNCTION f2 RETURN INT AS BEGIN RETURN 10; END;
-END' at line 2
+END' at line 3
 #
 # Creating a new package
 #
@@ -191,7 +191,7 @@ FUNCTION f1 RETURN INT;
 PROCEDURE p1;
 END test2.test2
 $$
-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 '.test2' at line 3
+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 '.test2' at line 4
 CREATE PACKAGE test2 AS
 FUNCTION f1 RETURN INT;
 PROCEDURE p1;
@@ -220,7 +220,7 @@ END f1.f1;
 END test2;
 $$
 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 '.f1;
-END test2' at line 2
+END test2' at line 5
 CREATE PACKAGE BODY test2 AS
 FUNCTION f1 RETURN INT AS
 BEGIN
@@ -237,7 +237,7 @@ END p1.p1;
 END test2;
 $$
 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 '.p1;
-END test2' at line 2
+END test2' at line 5
 CREATE PACKAGE BODY test2 AS
 PROCEDURE p1 AS
 BEGIN
diff --git a/mysql-test/suite/compat/oracle/r/sp-cursor-decl.result b/mysql-test/suite/compat/oracle/r/sp-cursor-decl.result
index fe2f9dd..944426d 100644
--- a/mysql-test/suite/compat/oracle/r/sp-cursor-decl.result
+++ b/mysql-test/suite/compat/oracle/r/sp-cursor-decl.result
@@ -102,7 +102,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
 BEGIN
 var1:='';
 insert into t1 values (1);
-SELE' at line 6
+SELE' at line 10
 drop table t1;
 #
 # Condition after handler declaration
@@ -130,7 +130,7 @@ $$
 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 'divide_by_zero CONDITION FOR SQLSTATE '22012';
 BEGIN
 var1:='';
-insert into t1 va' at line 7
+insert into t1 va' at line 11
 drop table t1;
 #
 # Variable after handler declaration
@@ -158,7 +158,7 @@ $$
 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 'divide_by_zero CONDITION FOR SQLSTATE '22012';
 BEGIN
 var1:='';
-insert into t1 va' at line 7
+insert into t1 va' at line 11
 drop table t1;
 #
 # Variable after cursor (inner block)
diff --git a/mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result b/mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result
index ff41dac..288d449 100644
--- a/mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result
+++ b/mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result
@@ -992,7 +992,7 @@ $$
 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 'LOOP
 NULL;
 END LOOP;
-END' at line 3
+END' at line 6
 # IN followed by a quoted identifier: table.column
 CREATE PROCEDURE p1 AS
 CURSOR c1 IS SELECT 'test' AS a FROM DUAL;
@@ -1006,7 +1006,7 @@ $$
 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 'LOOP
 NULL;
 END LOOP;
-END' at line 3
+END' at line 6
 # IN followed by a quoted identifier: .table.column
 CREATE PROCEDURE p1 AS
 CURSOR c1 IS SELECT 'test' AS a FROM DUAL;
@@ -1020,7 +1020,7 @@ $$
 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 'LOOP
 NULL;
 END LOOP;
-END' at line 3
+END' at line 6
 # IN followed by a quoted identifier: schema.table.column
 CREATE PROCEDURE p1 AS
 CURSOR c1 IS SELECT 'test' AS a FROM DUAL;
@@ -1034,7 +1034,7 @@ $$
 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 'LOOP
 NULL;
 END LOOP;
-END' at line 3
+END' at line 6
 # IN followed by an unknown cursor name
 CREATE PROCEDURE p1 AS
 CURSOR c1 IS SELECT 'test' AS a FROM DUAL;
@@ -1178,7 +1178,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
 LOOP
 SELECT rec.a, rec.b;
 END LOOP;
-END' at line 1
+END' at line 3
 # Make sure "rec" is not visible after END LOOP
 CREATE PROCEDURE p1 AS
 BEGIN
diff --git a/mysql-test/suite/compat/oracle/r/sp-cursor.result b/mysql-test/suite/compat/oracle/r/sp-cursor.result
index 44e7996..bfade19 100644
--- a/mysql-test/suite/compat/oracle/r/sp-cursor.result
+++ b/mysql-test/suite/compat/oracle/r/sp-cursor.result
@@ -776,7 +776,7 @@ FETCH c INTO a, b;
 EXIT WHEN c%NOTFOUND;
 SELECT a, b;
 END LOOP;
-CLOSE ' at line 3
+CLOSE ' at line 5
 DROP TABLE t1;
 #
 # MDEV-10577 sql_mode=ORACLE: %TYPE in variable declarations
diff --git a/mysql-test/suite/compat/oracle/r/sp-row.result b/mysql-test/suite/compat/oracle/r/sp-row.result
index 5622e8e..d515fc9 100644
--- a/mysql-test/suite/compat/oracle/r/sp-row.result
+++ b/mysql-test/suite/compat/oracle/r/sp-row.result
@@ -13,7 +13,7 @@ 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 'ROW(a INT));
 BEGIN
-END' at line 2
+END' at line 3
 #
 # Returning the entire ROW parameter from a function
 #
diff --git a/mysql-test/suite/compat/oracle/r/sp.result b/mysql-test/suite/compat/oracle/r/sp.result
index 7629af5..5dd628d 100644
--- a/mysql-test/suite/compat/oracle/r/sp.result
+++ b/mysql-test/suite/compat/oracle/r/sp.result
@@ -667,7 +667,7 @@ RETURN;
 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 ';
-END' at line 1
+END' at line 4
 CREATE PROCEDURE p1 (a IN OUT INT)
 AS
 BEGIN
@@ -778,7 +778,7 @@ LOOP
 NULL
 END LOOP;
 RETURN total;
-END' at line 2
+END' at line 5
 CREATE FUNCTION f1 (lower_bound INT, upper_bound INT, lim INT) RETURN INT
 AS
 total INT := 0;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index a1cb146..7504ef9 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1547,8 +1547,10 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
           If we find a space then this can't be an identifier. We notice this
           below by checking start != lex->ptr.
         */
-        for (; state_map[(uchar) c] == MY_LEX_SKIP ; c= lip->yyGet())
-          ;
+        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()])
-- 
2.6.3.windows.1

