Re: "long" type is not appropriate for counting tuples

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: "long" type is not appropriate for counting tuples
Дата
Msg-id 320ca812-4f15-bb83-5464-a5d821f19732@2ndquadrant.com
обсуждение исходный текст
Ответ на Re: "long" type is not appropriate for counting tuples  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: "long" type is not appropriate for counting tuples  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 2019-05-23 16:34, Tom Lane wrote:
> On the whole I think I could live with a policy that says "tuple counts
> shall be 'long long' when being passed around in code, but for persistent
> storage or wire-protocol transmission, use 'int64'".
> 
> An alternative and much narrower policy is to say it's okay to do this
> with an int64 value:
> 
>     printf("processed %lld tuples", (long long) count);
> 
> In such code, all we're assuming is long long >= 64 bits, which
> is completely safe per C99, and we dodge the need for a
> platform-varying format string.

Some combination of this seems quite reasonable.

Attached is a patch to implement this in a handful of cases that are
particularly verbose right now.  I think those are easy wins.

(Also a second patch that makes use of %zu for size_t where this was not
yet done.)

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Вложения

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

Предыдущее
От: Kyotaro Horiguchi
Дата:
Сообщение: pg_checksums has an untranslatable string.
Следующее
От: Robert Haas
Дата:
Сообщение: Re: "long" type is not appropriate for counting tuples