In that case, attached is a patch which locates the beginning of the

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
This commit is contained in:
Bruce Momjian 2002-08-17 13:06:50 +00:00
parent 82119a696e
commit 54124240ae
1 changed files with 7 additions and 3 deletions

View 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));
}