Andrus <kobruleht2@xxxxxx> writes: > Postgres returns unreadable syntax error messageges like > Syntax error at or near ')' > How to fix this so that 3 last tokens are returned in message like > Syntax error at or near ' i > )' Our take on this is that it's the client code's responsibility to present a useful error message using the error position info. Thus, libpq for example has support for turning that into postgres=# select (1 + 2)); ERROR: syntax error at or near ")" LINE 1: select (1 + 2)); ^ In a query spanning dozens of lines, that sort of localization could be way more useful than what you suggest. A driver that munges the user-supplied string is particularly on the hook to do something useful, since the server is certainly unable to reverse-engineer that. The fact that basic syntax error messages come out like that is an artifact of what the Bison parser generator does, it's not something that PG developers chose. (And, by the same token, it's difficult to get Bison to do something different.) I'm loath to expend server-side effort on doing better, when it's the client that knows how it's going to present the message and what's the best way to display a syntax error. pgAdmin, for example, has requirements completely different from text-based clients. Making the basic error message longer could actually be counterproductive for clients that are making an effort on this; for example, a message incorporating three or four source tokens might not fit on one line anymore. In short, I think you should take your complaint to the authors of whichever driver or application you're using. They really ought to try at least as hard as libpq+psql do. regards, tom lane