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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: client side syntax error localisation for psql (v1)
Date: 2004-03-11 17:18:38
Message-ID: 20890.1079025518@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Fabien COELHO <coelho(at)cri(dot)ensmp(dot)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: ^
or
QUERY: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2004-03-11 17:33:43 Re: client side syntax error localisation for psql (v1)
Previous Message Fabien COELHO 2004-03-11 16:45:44 Re: client side syntax error localisation for psql (v1)