Re: Patch for Improved Syntax Error Reporting

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Patch for Improved Syntax Error Reporting
Дата
Msg-id 13934.996786706@sss.pgh.pa.us
обсуждение исходный текст
Ответ на RE: Patch for Improved Syntax Error Reporting  (Dave Page <dpage@vale-housing.co.uk>)
Список pgsql-patches
Dave Page <dpage@vale-housing.co.uk> writes:
> I disagree. In pgAdmin's case, if the user enters an SQL query, pgAdmin will
> rewrite it to remove any formatting that the user has entered before it's
> sent to the backend. This means that the query sent may (== often is)
> shorter than the query entered by the user where carriage returns etc. have
> been removed, hence the index value would just be confusing to the user as
> it may well be wrong.

This strikes me as a perfect example of the situation where the frontend
application *must* take some of the responsibility for displaying a
proper location for a syntax error.  Once you've rewritten the query
like that, a patch such as Neil's original effort would be unlikely to
produce anything particularly helpful to the user.  For example: does
your reformatting include collapsing out whitespace, eg reducing
newlines to spaces?  If so, Neil's assumption that one line surrounding
the error point is the right amount of context will fail badly.

I think if you want to do that sort of thing then it's up to you to
maintain the mapping between what the user typed and what you actually
sent to the backend, so that you can reverse it to interpret the query
offset, and finally display an error that points at the right place in
text that the user really typed.

Memo to Neil: I believe you'll find that even psql does a certain amount
of this --- IIRC, it strips out SQL comments, for instance.

            regards, tom lane

В списке pgsql-patches по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Patch for Improved Syntax Error Reporting
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Revised Patch to allow multiple table locks in "Unison"