List:Commits« Previous MessageNext Message »
From:marc.alff Date:April 22 2008 1:37am
Subject:bk commit into 6.0 tree (malff:1.2623) BUG#35936
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of malff.  When malff does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-04-21 17:37:29-06:00, malff@stripped. +4 -0
  Bug#35936 (Garbage in syntax error message)
  
  Before this fix, the default initialization of
  Lex_input_stream::lookahead_token was using the value END_OF_INPUT
  to represent that no lookahead token has been parsed.
  
  This choice was unfortunate, since END_OF_INPUT is a real token value
  that can be returned by the lexer, which caused confusion when a query contains
  the following tokens:
    <WITH> <END_OF_INPUT>
  which in turn happens when a (malformed) query ends with <WITH>.
  
  Changed the value that represents "no token" to an out-of-bound token value,
  (-1), that can not be returned by the lexer.

  mysql-test/r/parser.result@stripped, 2008-04-21 17:03:13-06:00,
malff@stripped. +8 -0
    Bug#35936 (Garbage in syntax error message)

  mysql-test/t/parser.test@stripped, 2008-04-21 17:03:13-06:00,
malff@stripped. +26 -1
    Bug#35936 (Garbage in syntax error message)

  sql/sql_lex.cc@stripped, 2008-04-21 17:03:14-06:00, malff@stripped. +3 -3
    Bug#35936 (Garbage in syntax error message)

  sql/sql_lex.h@stripped, 2008-04-21 17:03:14-06:00, malff@stripped. +6 -1
    Bug#35936 (Garbage in syntax error message)

diff -Nrup a/mysql-test/r/parser.result b/mysql-test/r/parser.result
--- a/mysql-test/r/parser.result	2008-03-26 20:28:21 -06:00
+++ b/mysql-test/r/parser.result	2008-04-21 17:03:13 -06:00
@@ -352,6 +352,14 @@ $$
 1
 1
 DROP PROCEDURE p26030;
+SHOW NEW MASTER FOR SLAVE WITH;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '' at line 1
+SHOW NEW MASTER FOR SLAVE WITH foo bar baz;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'foo bar baz' at line 1
+SHOW NEW MASTER FOR SLAVE WITH$$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '' at line 1
+SHOW NEW MASTER FOR SLAVE WITH;$$
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '' at line 1
 select pi(3.14);
 ERROR 42000: Incorrect parameter count in the call to native function 'pi'
 select tan();
diff -Nrup a/mysql-test/t/parser.test b/mysql-test/t/parser.test
--- a/mysql-test/t/parser.test	2008-03-27 12:21:24 -06:00
+++ b/mysql-test/t/parser.test	2008-04-21 17:03:13 -06:00
@@ -434,7 +434,32 @@ $$
 delimiter ;$$
 DROP PROCEDURE p26030;
 
-#=============================================================================
+#
+# Bug#35936 (Garbage in syntax error message)
+#
+
+# test that
+# - <WITH> <END_OF_INPUT>
+# - <WITH> <YYEOF>
+# are parsed properly during the LALR(2) lookup
+
+--error ER_PARSE_ERROR
+SHOW NEW MASTER FOR SLAVE WITH;
+
+--error ER_PARSE_ERROR
+SHOW NEW MASTER FOR SLAVE WITH foo bar baz;
+
+delimiter $$;
+
+--error ER_PARSE_ERROR
+SHOW NEW MASTER FOR SLAVE WITH$$
+
+--error ER_PARSE_ERROR
+SHOW NEW MASTER FOR SLAVE WITH;$$
+
+delimiter ;$$
+
+#============================================================================r
 # SYNTACTIC PARSER (bison)
 #=============================================================================
 
diff -Nrup a/sql/sql_lex.cc b/sql/sql_lex.cc
--- a/sql/sql_lex.cc	2008-04-21 01:30:29 -06:00
+++ b/sql/sql_lex.cc	2008-04-21 17:03:14 -06:00
@@ -125,7 +125,7 @@ Lex_input_stream::Lex_input_stream(THD *
   yylineno(1),
   yytoklen(0),
   yylval(NULL),
-  lookahead_token(END_OF_INPUT),
+  lookahead_token(-1),
   lookahead_yylval(NULL),
   m_ptr(buffer),
   m_tok_start(NULL),
@@ -736,14 +736,14 @@ int MYSQLlex(void *arg, void *yythd)
   YYSTYPE *yylval=(YYSTYPE*) arg;
   int token;
 
-  if (lip->lookahead_token != END_OF_INPUT)
+  if (lip->lookahead_token >= 0)
   {
     /*
       The next token was already parsed in advance,
       return it.
     */
     token= lip->lookahead_token;
-    lip->lookahead_token= END_OF_INPUT;
+    lip->lookahead_token= -1;
     *yylval= *(lip->lookahead_yylval);
     lip->lookahead_yylval= NULL;
     return token;
diff -Nrup a/sql/sql_lex.h b/sql/sql_lex.h
--- a/sql/sql_lex.h	2008-04-21 01:30:30 -06:00
+++ b/sql/sql_lex.h	2008-04-21 17:03:14 -06:00
@@ -1389,7 +1389,12 @@ public:
   /** Interface with bison, value of the last token parsed. */
   LEX_YYSTYPE yylval;
 
-  /** LALR(2) resolution, look ahead token.*/
+  /**
+    LALR(2) resolution, look ahead token.
+    Value of the next token to return, if any,
+    or -1, if no token was parsed in advance.
+    Note: 0 is a legal token, and represents YYEOF.
+  */
   int lookahead_token;
 
   /** LALR(2) resolution, value of the look ahead token.*/
Thread
bk commit into 6.0 tree (malff:1.2623) BUG#35936marc.alff22 Apr