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

Поиск
Список
Период
Сортировка
От Fabien COELHO
Тема Re: client side syntax error localisation for psql (v1)
Дата
Msg-id Pine.LNX.4.58.0403120825500.12205@sablons.cri.ensmp.fr
обсуждение исходный текст
Ответ на Re: client side syntax error localisation for psql (v1)  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: client side syntax error localisation for psql (v1)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Dear Tom,

> > 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.

Yes, I partly agree. However the space above can be used nevertheless for
the extract, so it is not totally "lost":

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

> > 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.

Sure.

> 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.

Sure, but the current status of psql is to have no such thing, and
I'm not going to start terminal-dependent features in the software;-)
I just want to help my students with syntax errors.

As a compromise, I can suggest the following:

LINE 4: WHERE id=123 AND name LIKE 'calvin' GROP BY name...                                           ^

So "QUERY:" is dropped out. If there is very few lines, I can just
put "LINE:". I'll have to deal with the alignment problem, no big deal,
but not very nice either.

> > 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 "...".

Well, I know that "..." is 3 char long, so I can put a "   " in the
cursor line in that case. If it is a figure, the length depends on its
value.

> It's not going to add more than about one strlen() call to what you need
> to do.

I cannot strlen an integer value;-) I have to convert to a string, or
deal directly with the line number.

With my new current implementation, the line number is only shown if the
query is more than 3 lines.

-- 
Fabien Coelho - coelho@cri.ensmp.fr


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

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: [pgsql-www] The Name Game: postgresql.net vs.
Следующее
От: Fabien COELHO
Дата:
Сообщение: Re: client side syntax error localisation for psql (v1)