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 18:05:36
Message-ID: 21264.1079028336@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:
>> Another possibility is to keep the cursor as just "^", and bury the
>> line info in the query extract. For instance:

> Well, I want to preserve space for the query extract, that's where the
> context information is! If I put more information there, I'll have to
> reduce the extract length.

But in the form you are using, you have to reserve that space anyway.
Consider an error marker at the end of the line:

QUERY: select 'text that is long enough to be a problem':
QUERY: ^ on line 1

Having to leave space for "on line 1" at the right end is not better
than putting "line 1:" at the left end.

> Moreover the cursor line information content is small, so it seems better
> to put the line information there.

It seems confusing to me. The cursor is just a marker. Consider also
the next step up from this scheme: instead of assuming a dumb terminal,
suppose you can use color or underlining or reverse-video or some such.
Then you might want to do just one line of output:

QUERY: SELECT foo FROM bar WHRE baz;
----

where my underlining represents using the terminal's highlight ability.
With such a scheme, putting LINE n on the same line fits naturally.

> There is also an alignment issue here, as depending on the number of
> figures, the cursor line would have to be fixed accordingly.

Sure, but you have to buy into that anyway if you are going to do "...".
It's not going to add more than about one strlen() call to what you need
to do.

> There is also a localisation issue here, as the translation of both lines
> must match so that the alignment is kept. I thought that if it is the very
> same word, the translation should be the same.

Hmm, that's a good point, although perhaps you could insert a note to
translators to add space as needed to make the two strings the same
length.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message scott.marlowe 2004-03-11 18:06:40 Re: Default Stats Revisited
Previous Message Greg Stark 2004-03-11 17:51:09 Re: [pgsql-hackers-win32] fsync with sync, and Win32 unlink