Re: client side syntax error localisation for psql (v1)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: client side syntax error localisation for psql (v1)
Дата
Msg-id 20890.1079025518@sss.pgh.pa.us
обсуждение исходный текст
Ответ на client side syntax error localisation for psql (v1)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: client side syntax error localisation for psql (v1)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Список pgsql-hackers
Fabien COELHO <coelho@cri.ensmp.fr> writes:
>> The "on line N" bit seems just noise to me.

> It depends.

I can see that it would be useful in a very large query.  Perhaps
include it only when the query has more than N lines, for some N
like three to five or so?

Another possibility is to keep the cursor as just "^", and bury the
line info in the query extract.  For instance:

Short single-line query, no truncation needed:
QUERY: SELECT * FROM foo WHRE bar;QUERY:                   ^

Truncation on the right just adds ..., no other change needed:
QUERY: SELECT * FROM foo WHRE lots-of-conditions...QUERY:                   ^

When you truncate on the left, count the number of newlines removed,
and emit "LINE n" if there were any:
QUERY: LINE 4: FROM foo WHRE lots-of-conditions...QUERY:                  ^
orQUERY: LINE 4: ...FROM foo WHRE lots-of-conditions...QUERY:                     ^

(So "LINE n" would never say "LINE 1", only larger line numbers.)

Here I'm imagining that the leading ... gets inserted when text has been
removed after the start of the indicated line.  So another possible
output format is
QUERY: ...FROM foo WHRE lots-of-conditions...QUERY:             ^

if you removed some text but not any newlines from the start of the
query.

I think this wouldn't be terribly complex to implement, and it would
make things look fairly nice for both short and long queries.

One last point: it seems a bit odd to use QUERY: as the prefix for both
the query extract and the cursor line.  I don't have a suggestion what
to use instead, offhand.
        regards, tom lane


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

Предыдущее
От: "scott.marlowe"
Дата:
Сообщение: Re: Default Stats Revisited
Следующее
От: Fabien COELHO
Дата:
Сообщение: Re: client side syntax error localisation for psql (v1)