Re: client side syntax error localisation for psql (v1) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: client side syntax error localisation for psql (v1)
Date
Msg-id 20890.1079025518@sss.pgh.pa.us
Whole thread Raw
In response to client side syntax error localisation for psql (v1)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: client side syntax error localisation for psql (v1)  (Fabien COELHO <coelho@cri.ensmp.fr>)
List 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 by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: Default Stats Revisited
Next
From: Fabien COELHO
Date:
Subject: Re: client side syntax error localisation for psql (v1)