OSDN Git Service

In that case, attached is a patch which locates the beginning of the
authorBruce Momjian <bruce@momjian.us>
Sat, 17 Aug 2002 13:06:50 +0000 (13:06 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 17 Aug 2002 13:06:50 +0000 (13:06 +0000)
offending token more efficiently (per your suggestion of using
scanbuf). The new patch does the same as before:

template1=# select * frum pg_class;
ERROR:  parser: parse error at or near "frum" at character 10

It also implement's Tom's suggestion:

template1=# select * from pg_class where\g
ERROR:  parse: parse error at end of input

Gavin Sherry

src/backend/parser/scan.l

index c8e13c3..51e1aa4 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.98 2002/08/04 06:36:18 thomas Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.99 2002/08/17 13:06:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -582,8 +582,12 @@ other                      .
 void
 yyerror(const char *message)
 {
-       elog(ERROR, "parser: %s at or near \"%s\"", message,
-                token_start ? token_start : yytext);
+      if(yyleng == 1 && *yytext == YY_END_OF_BUFFER_CHAR)
+              elog(ERROR, "parser: %s at end of input",message);
+      else
+              elog(ERROR, "parser: %s at or near \"%s\" at character %i",
+                      message,token_start ? token_start : yytext,
+                      (unsigned int)(yytext - scanbuf + 1));
 }