Re: add line number as prompt option to psql

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: add line number as prompt option to psql
Дата
Msg-id 20140711171935.GB6390@eldon.alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: add line number as prompt option to psql  (Sawada Masahiko <sawada.mshk@gmail.com>)
Ответы Re: add line number as prompt option to psql  (Sawada Masahiko <sawada.mshk@gmail.com>)
Список pgsql-hackers
Sawada Masahiko wrote:

> As you said, if line number reached UINT_MAX then I think that this
> case is too strange.
> I think INT_MAX is enough for line number.

My point is not whether 2 billion is a better number than 4 billion as a
maximum value.  My point is that wraparound of signed int is, I think,
not even defined in C, whereas wraparound of unsigned int is well
defined.  cur_line should be declared as unsigned int.  I don't trust
that INT_MAX+2 arithmetic.

Please don't use cur_line as a name for a global variable.  Something
like PSQLLineNumber seems more appropriate if it's going to be exposed
through prompt.h.  However, note that MainLoop() keeps state in local
variables and notes that it is reentrant; what happens to your cur_line
when a file is read by \i and similar?  I wonder if it should be part of
PsqlScanStateData instead ...

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services



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

Предыдущее
От: Sawada Masahiko
Дата:
Сообщение: Re: add line number as prompt option to psql
Следующее
От: Tomas Vondra
Дата:
Сообщение: Re: tweaking NTUP_PER_BUCKET